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:
parent
95c068358a
commit
c64195d147
@ -223,7 +223,7 @@ void print_cpu_temperature_info(yajl_gen json_gen, char *buffer, int zone, const
|
|||||||
asprintf(&thermal_zone, THERMAL_ZONE, zone);
|
asprintf(&thermal_zone, THERMAL_ZONE, zone);
|
||||||
else {
|
else {
|
||||||
static glob_t globbuf;
|
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");
|
die("glob() failed\n");
|
||||||
if (globbuf.gl_pathc == 0) {
|
if (globbuf.gl_pathc == 0) {
|
||||||
/* No glob matches, the specified path does not contain a wildcard. */
|
/* No glob matches, the specified path does not contain a wildcard. */
|
||||||
|
@ -24,7 +24,7 @@ bool process_runs(const char *path) {
|
|||||||
static glob_t globbuf;
|
static glob_t globbuf;
|
||||||
memset(pidbuf, 0, sizeof(pidbuf));
|
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");
|
die("glob() failed\n");
|
||||||
if (globbuf.gl_pathc == 0) {
|
if (globbuf.gl_pathc == 0) {
|
||||||
/* No glob matches, the specified path does not contain a wildcard. */
|
/* No glob matches, the specified path does not contain a wildcard. */
|
||||||
|
Loading…
Reference in New Issue
Block a user