btrfs-progs: image: fix bogus check after cpu on-line detection

Comparing unsigned type for <= 0 does not make much sense, we should
really check the signed value returned by sysconf.

Resolves-coverity-id: 1324536
Signed-off-by: David Sterba <dsterba@suse.com>
master
David Sterba 2015-10-30 15:34:55 +01:00
parent c9bddcacbc
commit 4f42e465cb
1 changed files with 5 additions and 3 deletions

View File

@ -2787,9 +2787,11 @@ int main(int argc, char *argv[])
if (compress_level > 0 || create == 0) {
if (num_threads == 0) {
num_threads = sysconf(_SC_NPROCESSORS_ONLN);
if (num_threads <= 0)
num_threads = 1;
long tmp = sysconf(_SC_NPROCESSORS_ONLN);
if (tmp <= 0)
tmp = 1;
num_threads = tmp;
}
} else {
num_threads = 0;