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>
This commit is contained in:
Olivier Gayot 2018-06-20 11:42:59 +02:00
parent 95c068358a
commit c64195d147
2 changed files with 2 additions and 2 deletions

View 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. */

View 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. */