mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-01 17:35:17 +00:00
virbitmaptest: Resolve Coverity errors
test1: Need to check for bitmap before using as well as free it properly test2: need to check for bitsString2 before using it.
This commit is contained in:
parent
dd36cc3f97
commit
9ff3876cc8
@ -29,26 +29,33 @@ static int test1(const void *data ATTRIBUTE_UNUSED)
|
|||||||
int size;
|
int size;
|
||||||
int bit;
|
int bit;
|
||||||
bool result;
|
bool result;
|
||||||
|
int ret = -1;
|
||||||
|
|
||||||
size = 1024;
|
size = 1024;
|
||||||
bit = 100;
|
bit = 100;
|
||||||
bitmap = virBitmapNew(size);
|
if (!(bitmap = virBitmapNew(size)))
|
||||||
|
goto error;
|
||||||
|
|
||||||
if (virBitmapSetBit(bitmap, bit) < 0)
|
if (virBitmapSetBit(bitmap, bit) < 0)
|
||||||
return -1;
|
goto error;
|
||||||
|
|
||||||
if (virBitmapGetBit(bitmap, bit, &result) < 0)
|
if (virBitmapGetBit(bitmap, bit, &result) < 0)
|
||||||
return -1;
|
goto error;
|
||||||
|
|
||||||
if (!result)
|
if (!result)
|
||||||
return -1;
|
goto error;
|
||||||
|
|
||||||
if (virBitmapGetBit(bitmap, bit + 1, &result) < 0)
|
if (virBitmapGetBit(bitmap, bit + 1, &result) < 0)
|
||||||
return -1;
|
goto error;
|
||||||
|
|
||||||
if (result)
|
if (result)
|
||||||
return -1;
|
goto error;
|
||||||
|
|
||||||
return 0;
|
ret = 0;
|
||||||
|
|
||||||
|
error:
|
||||||
|
virBitmapFree(bitmap);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -102,7 +109,8 @@ static int test2(const void *data ATTRIBUTE_UNUSED)
|
|||||||
if (virBitmapCountBits(bitmap) != 48)
|
if (virBitmapCountBits(bitmap) != 48)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
bitsString2 = virBitmapFormat(bitmap);
|
if (!(bitsString2 = virBitmapFormat(bitmap)))
|
||||||
|
goto error;
|
||||||
if (strcmp(bitsString1, bitsString2))
|
if (strcmp(bitsString1, bitsString2))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user