mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-08 12:41:29 +00:00
virbitmaptest: test13: Refactor memory cleanup
Move scope of variables and get rid of the 'cleanup' section. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
e2d13d607f
commit
5642508732
@ -670,37 +670,27 @@ test12(const void *opaque G_GNUC_UNUSED)
|
|||||||
static int
|
static int
|
||||||
test13(const void *opaque G_GNUC_UNUSED)
|
test13(const void *opaque G_GNUC_UNUSED)
|
||||||
{
|
{
|
||||||
virBitmapPtr map = NULL;
|
|
||||||
const char *strings[] = { "1234feebee", "000c0fefe" };
|
const char *strings[] = { "1234feebee", "000c0fefe" };
|
||||||
char *str = NULL;
|
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
for (i = 0; i < G_N_ELEMENTS(strings); i++) {
|
for (i = 0; i < G_N_ELEMENTS(strings); i++) {
|
||||||
map = virBitmapNewString(strings[i]);
|
g_autoptr(virBitmap) map = NULL;
|
||||||
if (!map)
|
g_autofree char *str = NULL;
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
str = virBitmapToString(map);
|
if (!(map = virBitmapNewString(strings[i])))
|
||||||
if (!str)
|
return -1;
|
||||||
goto cleanup;
|
|
||||||
|
if (!(str = virBitmapToString(map)))
|
||||||
|
return -1;
|
||||||
|
|
||||||
if (STRNEQ(strings[i], str)) {
|
if (STRNEQ(strings[i], str)) {
|
||||||
fprintf(stderr, "\n expected bitmap string '%s' actual string "
|
fprintf(stderr, "\n expected bitmap string '%s' actual string "
|
||||||
"'%s'\n", strings[i], str);
|
"'%s'\n", strings[i], str);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
VIR_FREE(str);
|
|
||||||
virBitmapFree(map);
|
|
||||||
map = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
cleanup:
|
|
||||||
VIR_FREE(str);
|
|
||||||
virBitmapFree(map);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef TEST_MAP
|
#undef TEST_MAP
|
||||||
|
Loading…
x
Reference in New Issue
Block a user