On 12/14/2013 10:21 AM, lijun wrote:
> Hi all,
>     As qemu core dump cause by "sockets=2,cores=3,threads=2", so add
> this patch to check whether cores and threads is a power of 2.

> +/**
> + * This function will return whether @num is power of 2.
> + *
> + * Returns: 1 indicate @num is power of 2, 0 indicate @num is not.
> + */
> +static int is_2_power(int num)
> +{
> +    if (num < 0 || num > 256)
> +        return 1;
> +
> +    return !(num & (num - 1));
> +}

Please don't reinvent qemu-common.h's is_power_of_2.  Furthermore, your
function is more than just a power-of-2 check, it is also a range check.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to