diff options
author | Lasse Collin <lasse.collin@tukaani.org> | 2009-09-05 01:20:29 +0300 |
---|---|---|
committer | Lasse Collin <lasse.collin@tukaani.org> | 2009-09-05 01:20:29 +0300 |
commit | 60ccb80c9c4a0d771acc5b7d9d6f32b17fed1071 (patch) | |
tree | 7b769ed2608f10e82dce96e82115bfa0d4db11fb /src/common/cpucores.h | |
parent | Mention in INSTALL that --enable-small doesn't modify CFLAGS. (diff) | |
download | xz-60ccb80c9c4a0d771acc5b7d9d6f32b17fed1071.tar.xz |
Use sysctl() != -1 instead of !sysctl() to check if
the function call succeeded.
NetBSD 4.0 returns positive values on success, but
NetBSD Current and FreeBSD return zero. OpenBSD's
man page doesn't tell what sysctl() returns on
success. All these BSDs return -1 on error.
Thanks to Robert Elz and Thomas Klausner.
Diffstat (limited to 'src/common/cpucores.h')
-rw-r--r-- | src/common/cpucores.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/common/cpucores.h b/src/common/cpucores.h index 330cd9c9..370c3cec 100644 --- a/src/common/cpucores.h +++ b/src/common/cpucores.h @@ -40,7 +40,7 @@ cpucores(void) int name[2] = { CTL_HW, HW_NCPU }; int cpus; size_t cpus_size = sizeof(cpus); - if (!sysctl(name, 2, &cpus, &cpus_size, NULL, 0) + if (sysctl(name, 2, &cpus, &cpus_size, NULL, 0) != -1 && cpus_size == sizeof(cpus) && cpus > 0) ret = (uint32_t)(cpus); #endif |