[libvirt] [PATCH 1/3] Add simple bitmap operations to utils

Jim Fehlig jfehlig at novell.com
Fri May 21 15:29:48 UTC 2010


Eric Blake wrote:
> On 05/20/2010 02:45 PM, Jim Fehlig wrote:
>   
>> +virBitmapPtr virBitmapAlloc(size_t size)
>> +{
>> +    virBitmapPtr bitmap;
>> +    size_t sz = (size + VIR_BITMAP_BITS_PER_UNIT - 1) /
>> +            VIR_BITMAP_BITS_PER_UNIT;
>>     
>
> Check for overflow:
> if (SIZE_MAX - VIR_BITMAP_BITS_PER_UNIT < size)
>     return NULL;
>
>   
>> +
>> +    if (VIR_ALLOC_N(bitmap, sizeof(virBitmap)) < 0)
>>     
>
> Use VIR_ALLOC(bitmap) - you want to allocate one bitmap object, not an
> array of bitmaps of length 'sizeof(virBitmap)'.
>   

Opps.  Copy and paste from bitmap->map.

This and your other comments are addressed in V3.

Regards,
Jim

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Add-simple-bitmap-operations-to-utils.patch
Type: text/x-patch
Size: 8188 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20100521/3e8fca7b/attachment-0001.bin>


More information about the libvir-list mailing list