On a Friday in 2020, Peter Krempa wrote:
Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- tests/virbitmaptest.c | 73 ++++++++++++++----------------------------- 1 file changed, 24 insertions(+), 49 deletions(-) diff --git a/tests/virbitmaptest.c b/tests/virbitmaptest.c index 1578cd0612..bfca208a7f 100644 --- a/tests/virbitmaptest.c +++ b/tests/virbitmaptest.c @@ -185,7 +181,7 @@ test4(const void *data G_GNUC_UNUSED) 1, 5, 11, 13, 19, 21, 23, 24, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39 }; - virBitmapPtr bitmap = NULL; + g_autoptr(virBitmap) bitmap = NULL;
Here, bitmap is also freed in the middle of the function (it seems these are three independent tests squashed into one function)
ssize_t i, j; if (G_N_ELEMENTS(bitsPos) + G_N_ELEMENTS(bitsPosInv) != size) @@ -285,11 +281,9 @@ test4(const void *data G_GNUC_UNUSED) if (virBitmapNextClearBit(bitmap, -1) != -1) goto error; - virBitmapFree(bitmap); return 0; error: - virBitmapFree(bitmap); return -1; } @@ -298,14 +292,14 @@ static int test5(const void *v G_GNUC_UNUSED) { char data[] = {0x01, 0x02, 0x00, 0x00, 0x04}; - unsigned char *data2 = NULL; + g_autofree unsigned char *data2 = NULL; int len2; int bits[] = {0, 9, 34}; - virBitmapPtr bitmap; + g_autoptr(virBitmap) bitmap = NULL; size_t i; ssize_t j; int ret = -1;
- char *str = NULL; + g_autofree char *str = NULL;
This one is also freed in the middle.
bitmap = virBitmapNewData(data, sizeof(data)); if (!bitmap) @@ -347,9 +341,6 @@ test5(const void *v G_GNUC_UNUSED) ret = 0; error: - VIR_FREE(str); - virBitmapFree(bitmap); - VIR_FREE(data2); return ret; } @@ -358,8 +349,8 @@ test5(const void *v G_GNUC_UNUSED) static int test6(const void *v G_GNUC_UNUSED) { - virBitmapPtr bitmap = NULL; - char *str = NULL; + g_autoptr(virBitmap) bitmap = NULL; + g_autofree char *str = NULL;
Same here.
int size = 64; int ret = -1; @@ -631,7 +610,7 @@ test11(const void *opaque) static int test12(const void *opaque G_GNUC_UNUSED) { - virBitmapPtr map = virBitmapNewEmpty(); + g_autoptr(virBitmap) map = virBitmapNewEmpty();
`map` is freed in the middle of the function.
int ret = -1; TEST_MAP(0, ""); @@ -661,7 +640,6 @@ test12(const void *opaque G_GNUC_UNUSED) ret = 0; cleanup: - virBitmapFree(map); return ret; }
Jano
Attachment:
signature.asc
Description: PGP signature