From 4f42e465cb060115e967f8097d9b63aaf65d08e4 Mon Sep 17 00:00:00 2001 From: David Sterba Date: Fri, 30 Oct 2015 15:34:55 +0100 Subject: [PATCH] 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 --- btrfs-image.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/btrfs-image.c b/btrfs-image.c index 20396ef7..d1d3d078 100644 --- a/btrfs-image.c +++ b/btrfs-image.c @@ -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;