]> git.sur5r.net Git - i3/i3status/commitdiff
Fix invalid handling of glob() errors on Linux
authorOlivier Gayot <olivier.gayot@sigexec.com>
Wed, 20 Jun 2018 09:42:59 +0000 (11:42 +0200)
committerOlivier Gayot <olivier.gayot@sigexec.com>
Wed, 20 Jun 2018 12:20:17 +0000 (14:20 +0200)
The manual of glob(3) says that the function returns 0 on successful
completion. Any other integer value should be considered an error, not
only negative integers.

In practice, *BSD systems use negative values but Linux uses positive
integers.

Signed-off-by: Olivier Gayot <olivier.gayot@sigexec.com>
src/print_cpu_temperature.c
src/process_runs.c

index 431664ed9d0f2ccbe47535b0945ef70f3a76619e..feae3ec8a8cb388fc3e8717554d4f851303d65ef 100644 (file)
@@ -223,7 +223,7 @@ void print_cpu_temperature_info(yajl_gen json_gen, char *buffer, int zone, const
         asprintf(&thermal_zone, THERMAL_ZONE, zone);
     else {
         static glob_t globbuf;
-        if (glob(path, GLOB_NOCHECK | GLOB_TILDE, NULL, &globbuf) < 0)
+        if (glob(path, GLOB_NOCHECK | GLOB_TILDE, NULL, &globbuf) != 0)
             die("glob() failed\n");
         if (globbuf.gl_pathc == 0) {
             /* No glob matches, the specified path does not contain a wildcard. */
index b5e8f110c5ac2cd77e9be07ceea7ce2ecbe39c42..da2dba150139f931560e0c8615abd020fc5b47fb 100644 (file)
@@ -24,7 +24,7 @@ bool process_runs(const char *path) {
     static glob_t globbuf;
     memset(pidbuf, 0, sizeof(pidbuf));
 
-    if (glob(path, GLOB_NOCHECK | GLOB_TILDE, NULL, &globbuf) < 0)
+    if (glob(path, GLOB_NOCHECK | GLOB_TILDE, NULL, &globbuf) != 0)
         die("glob() failed\n");
     if (globbuf.gl_pathc == 0) {
         /* No glob matches, the specified path does not contain a wildcard. */