]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
chcpu: check get_max_number_of_cpus() result properly
authorKarel Zak <kzak@redhat.com>
Wed, 1 Feb 2012 11:26:20 +0000 (12:26 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 1 Feb 2012 11:26:32 +0000 (12:26 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/chcpu.c
sys-utils/lscpu.c

index 475c1cec66a92359c36090de49ad0fbaa2971433..29b7ab8965f8f90abceac74e75359b2776a2ff64 100644 (file)
@@ -248,7 +248,7 @@ int main(int argc, char *argv[])
        textdomain(PACKAGE);
 
        maxcpus = get_max_number_of_cpus();
-       if (maxcpus <= 0)
+       if ((int) maxcpus <= 0)
                errx(EXIT_FAILURE, _("cannot determine NR_CPUS; aborting"));
        if (path_exist(_PATH_SYS_CPU_ONLINE))
                onlinecpus = path_cpulist(maxcpus, _PATH_SYS_CPU_ONLINE);
index a9ca2fe595ff18b2756aafe7722d3364372ac331..6a74c4eb787bea65bbf9e5138726d84849c154ae 100644 (file)
@@ -383,9 +383,10 @@ read_basicinfo(struct lscpu_desc *desc, struct lscpu_modifier *mod)
        else if (mod->system == SYSTEM_LIVE)
                /* the root is '/' so we are working with data from the current kernel */
                maxcpus = get_max_number_of_cpus();
-       else
-               /* we are reading some /sys snapshot instead of the real /sys,
-                * let's use any crazy number... */
+
+       if (maxcpus <= 0)
+               /* error or we are reading some /sys snapshot instead of the
+                * real /sys, let's use any crazy number... */
                maxcpus = desc->ncpus > 2048 ? desc->ncpus : 2048;
 
        /* get mask for online CPUs */