mbpfan-josie

Handle corner-case where no sensors and fans are detected [fixes #42]

b037ec210f18253d49ebbd565e9738bd273f7863
Daniel Graziotin <daniel@ineed.coffee> · 2014-06-29T12:52 · browse files at this commit

parents: 473a12f

diff --git a/src/mbpfan.c b/src/mbpfan.c
index 3e7cb6e..1ea439a 100755
--- a/src/mbpfan.c
+++ b/src/mbpfan.c
@@ -212,6 +212,12 @@ t_sensors *retrieve_sensors()
         }
     }
 
+    if (!sensors_found > 0){
+        syslog(LOG_INFO, "mbpfan could not detect any temp sensor. Please contact the developer.\n");
+        printf("mbpfan could not detect any temp sensor. Please contact the developer.\n");
+        exit(EXIT_FAILURE);
+    }
+
     return sensors_head;
 }
 
@@ -296,6 +302,12 @@ t_fans *retrieve_fans()
         }
     }
 
+    if (!fans_found > 0){
+        syslog(LOG_INFO, "mbpfan could not detect any fan. Please contact the developer.\n");
+        printf("mbpfan could not detect any fan. Please contact the developer.\n");
+        exit(EXIT_FAILURE);
+    }
+
 
     return fans_head;
 }