summaryrefslogtreecommitdiff
path: root/btrfs-image.c
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2015-10-30 15:34:55 +0100
committerDavid Sterba <dsterba@suse.com>2015-11-02 15:10:14 +0100
commit4f42e465cb060115e967f8097d9b63aaf65d08e4 (patch)
treea113a3602ce6d6754c256b4b691a26031fa3ecc1 /btrfs-image.c
parentc9bddcacbc6cad10e65a305e9382648346bbe896 (diff)
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>
Diffstat (limited to 'btrfs-image.c')
-rw-r--r--btrfs-image.c8
1 files 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;