summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorMartin Capitanio <capnm@capitanio.org>2019-06-19 10:41:07 +0200
committerMartin Capitanio <capnm@capitanio.org>2019-06-19 11:57:38 +0200
commitce1c840635ef2970259d5a88a65cac33d32837b6 (patch)
treecf75bc5c38cc606ab768281e77cdf5fb1ac4840b /platform
parentd2f38dbb28053e47cd6a0f8b368ade5c19d5ca70 (diff)
Linux: Check return values of posix read/write
Fixes #29849, for real this time.
Diffstat (limited to 'platform')
-rw-r--r--platform/x11/detect_prime.cpp14
-rw-r--r--platform/x11/joypad_linux.cpp4
2 files changed, 11 insertions, 7 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);
}
diff --git a/platform/x11/joypad_linux.cpp b/platform/x11/joypad_linux.cpp
index 3e9e8033e8..21c3b0ac91 100644
--- a/platform/x11/joypad_linux.cpp
+++ b/platform/x11/joypad_linux.cpp
@@ -414,7 +414,9 @@ void JoypadLinux::joypad_vibration_start(int p_id, float p_weak_magnitude, float
play.type = EV_FF;
play.code = effect.id;
play.value = 1;
- write(joy.fd, (const void *)&play, sizeof(play));
+ if (write(joy.fd, (const void *)&play, sizeof(play)) == -1) {
+ print_verbose("Couldn't write to Joypad device.");
+ }
joy.ff_effect_id = effect.id;
joy.ff_effect_timestamp = p_timestamp;