mbpfan-josie

Report error when failing to set fan speed

References #155.

ac099c8bd27d052e12aca53986a7e92e8dc3a241
Andrew Gaul <andrew@gaul.org> · 2018-08-20T15:27 · browse files at this commit

parents: 8c89a67

diff --git a/src/mbpfan.c b/src/mbpfan.c
index 4e20529..8a4ac1e 100644
--- a/src/mbpfan.c
+++ b/src/mbpfan.c
@@ -376,7 +376,10 @@ void set_fan_speed(t_fans* fans, int speed)
         if(tmp->file != NULL) {
             char buf[16];
             int len = snprintf(buf, sizeof(buf), "%d", speed);
-            pwrite(fileno(tmp->file), buf, len, /*offset=*/ 0);
+            int res = pwrite(fileno(tmp->file), buf, len, /*offset=*/ 0);
+            if (res == -1) {
+                perror("Could not set fan speed");
+            }
         }
 
         tmp = tmp->next;