Re: [PATCH 1/3 V7] add nodeGetCPUmap() for getting available CPU IDs in a cpumap.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Mar 02, 2012 at 10:54:22AM +0800, Lai Jiangshan wrote:
> +/*
> + * Linux maintains cpu bit map. For example, if cpuid=5's flag is not set
> + * and max cpu is 7. The map file shows 0-4,6-7. This function parses
> + * it and returns cpumap.
> + */
> +static const char *
> +linuxParseCPUmap(int *max_cpuid, const char *path)
> +{
> +    char *map = NULL;
> +    char *str = NULL;
> +    int max_id, i;
> +
> +    if (virFileReadAll(path, 5 * VIR_DOMAIN_CPUMASK_LEN, &str) < 0) {
> +        virReportOOMError();
> +        goto error;
> +    }
> +
> +    if (VIR_ALLOC_N(map, VIR_DOMAIN_CPUMASK_LEN) < 0) {
> +        virReportOOMError();
> +        goto error;
> +    }
> +    if (virDomainCpuSetParse(str, 0, map,
> +                             VIR_DOMAIN_CPUMASK_LEN) < 0) {
> +        goto error;
> +    }
> +
> +    for (i = 0; i < VIR_DOMAIN_CPUMASK_LEN; i++) {
> +        if (map[i]) {
> +            max_id = i;
> +        }
> +    }
> +    *max_cpuid = max_id;

Please compile with './configure --enable-compile-warnings=error'.
The compiler spots that max_id could be used uninitialized here.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://et.redhat.com/~rjones/virt-top

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]