qemumonitorjsontest: testBlockNodeNameDetect: Automatically free GHashTable

Additionally we no longer need the cleanup section.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
Peter Krempa 2021-11-30 11:49:24 +01:00
parent dc38b4c5bf
commit e28f5ddc56

View File

@ -2490,24 +2490,23 @@ testBlockNodeNameDetect(const void *opaque)
g_autofree char *actual = NULL; g_autofree char *actual = NULL;
g_autoptr(virJSONValue) namedNodesJson = NULL; g_autoptr(virJSONValue) namedNodesJson = NULL;
g_autoptr(virJSONValue) blockstatsJson = NULL; g_autoptr(virJSONValue) blockstatsJson = NULL;
GHashTable *nodedata = NULL; g_autoptr(GHashTable) nodedata = NULL;
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
int ret = -1;
resultFile = g_strdup_printf("%s/%s%s.result", abs_srcdir, pathprefix, resultFile = g_strdup_printf("%s/%s%s.result", abs_srcdir, pathprefix,
testname); testname);
if (!(namedNodesJson = virTestLoadFileJSON(pathprefix, testname, if (!(namedNodesJson = virTestLoadFileJSON(pathprefix, testname,
"-named-nodes.json", NULL))) "-named-nodes.json", NULL)))
goto cleanup; return -1;
if (!(blockstatsJson = virTestLoadFileJSON(pathprefix, testname, if (!(blockstatsJson = virTestLoadFileJSON(pathprefix, testname,
"-blockstats.json", NULL))) "-blockstats.json", NULL)))
goto cleanup; return -1;
if (!(nodedata = qemuBlockNodeNameGetBackingChain(namedNodesJson, if (!(nodedata = qemuBlockNodeNameGetBackingChain(namedNodesJson,
blockstatsJson))) blockstatsJson)))
goto cleanup; return -1;
virHashForEachSorted(nodedata, testBlockNodeNameDetectFormat, &buf); virHashForEachSorted(nodedata, testBlockNodeNameDetectFormat, &buf);
@ -2516,14 +2515,9 @@ testBlockNodeNameDetect(const void *opaque)
actual = virBufferContentAndReset(&buf); actual = virBufferContentAndReset(&buf);
if (virTestCompareToFile(actual, resultFile) < 0) if (virTestCompareToFile(actual, resultFile) < 0)
goto cleanup; return -1;
ret = 0; return 0;
cleanup:
virHashFree(nodedata);
return ret;
} }