summaryrefslogtreecommitdiff
path: root/platform/x11/detect_prime.cpp
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-06-19 13:57:03 +0200
committerGitHub <noreply@github.com>2019-06-19 13:57:03 +0200
commit082a2bcb9fae62ae35bff29d90d04ea1d15ca14a (patch)
tree1128c6caf697f9ccb3af4e92dd1d11c43843f34b /platform/x11/detect_prime.cpp
parent7fa941bfd8a1d81fc5c27c21635e60846efc52f4 (diff)
parentce1c840635ef2970259d5a88a65cac33d32837b6 (diff)
Merge pull request #29893 from capnm/capnm-posix-read-write-return
Linux: Check return values of posix read/write
Diffstat (limited to 'platform/x11/detect_prime.cpp')
-rw-r--r--platform/x11/detect_prime.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/platform/x11/detect_prime.cpp b/platform/x11/detect_prime.cpp
index 0fde2a0c04..26008feade 100644
--- a/platform/x11/detect_prime.cpp
+++ b/platform/x11/detect_prime.cpp
@@ -159,10 +159,11 @@ int detect_prime() {
if (!stat_loc) {
// No need to do anything complicated here. Anything less than
// PIPE_BUF will be delivered in one read() call.
- read(fdset[0], string, sizeof(string) - 1);
-
- vendors[i] = string;
- renderers[i] = string + strlen(string) + 1;
+ // Leave it 'Unknown' otherwise.
+ if (read(fdset[0], string, sizeof(string) - 1) > 0) {
+ vendors[i] = string;
+ renderers[i] = string + strlen(string) + 1;
+ }
}
close(fdset[0]);
@@ -190,8 +191,9 @@ int detect_prime() {
memcpy(&string, vendor, vendor_len);
memcpy(&string[vendor_len], renderer, renderer_len);
- write(fdset[1], string, vendor_len + renderer_len);
-
+ if (write(fdset[1], string, vendor_len + renderer_len) == -1) {
+ print_verbose("Couldn't write vendor/renderer string.");
+ }
close(fdset[1]);
exit(0);
}