summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Gayot <olivier.gayot@sigexec.com>2018-06-20 11:42:59 +0200
committerOlivier Gayot <olivier.gayot@sigexec.com>2018-06-20 14:20:17 +0200
commitc64195d14728aa82e280d022e9f7ceff71cfc6c1 (patch)
treec4670a6e9fac2bdf2ea60f9f9fa4e6f7e57cc181
parent95c068358acb303ab01ab8dc372f893aec5fe1b0 (diff)
Fix invalid handling of glob() errors on Linux
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>
-rw-r--r--src/print_cpu_temperature.c2
-rw-r--r--src/process_runs.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/src/print_cpu_temperature.c b/src/print_cpu_temperature.c
index 431664e..feae3ec 100644
--- a/src/print_cpu_temperature.c
+++ b/src/print_cpu_temperature.c
@@ -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. */
diff --git a/src/process_runs.c b/src/process_runs.c
index b5e8f11..da2dba1 100644
--- a/src/process_runs.c
+++ b/src/process_runs.c
@@ -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. */