Add g_autofree to functions changed in previous commits doing g_auto cleanup for libxml2-related variables, where it could lead to removal of a label. Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx> --- src/conf/virstorageobj.c | 3 +-- tests/cputest.c | 9 +++------ tests/metadatatest.c | 3 +-- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c index f8b85494c0..1f6fedba13 100644 --- a/src/conf/virstorageobj.c +++ b/src/conf/virstorageobj.c @@ -1641,7 +1641,7 @@ virStoragePoolObjLoadState(virStoragePoolObjList *pools, const char *stateDir, const char *name) { - char *stateFile = NULL; + g_autofree char *stateFile = NULL; virStoragePoolObj *obj = NULL; g_autoptr(xmlDoc) xml = NULL; g_autoptr(xmlXPathContext) ctxt = NULL; @@ -1686,7 +1686,6 @@ virStoragePoolObjLoadState(virStoragePoolObjList *pools, obj->active = true; cleanup: - VIR_FREE(stateFile); return obj; } diff --git a/tests/cputest.c b/tests/cputest.c index d19ded4b40..14606f5864 100644 --- a/tests/cputest.c +++ b/tests/cputest.c @@ -70,7 +70,7 @@ static virQEMUDriver driver; static virCPUDef * cpuTestLoadXML(virArch arch, const char *name) { - char *xml = NULL; + g_autofree char *xml = NULL; g_autoptr(xmlDoc) doc = NULL; g_autoptr(xmlXPathContext) ctxt = NULL; virCPUDef *cpu = NULL; @@ -84,7 +84,6 @@ cpuTestLoadXML(virArch arch, const char *name) virCPUDefParseXML(ctxt, NULL, VIR_CPU_TYPE_AUTO, &cpu, false); cleanup: - VIR_FREE(xml); return cpu; } @@ -94,10 +93,10 @@ cpuTestLoadMultiXML(virArch arch, const char *name, unsigned int *count) { - char *xml = NULL; + g_autofree char *xml = NULL; g_autoptr(xmlDoc) doc = NULL; g_autoptr(xmlXPathContext) ctxt = NULL; - xmlNodePtr *nodes = NULL; + g_autofree xmlNodePtr *nodes = NULL; virCPUDef **cpus = NULL; int n; size_t i; @@ -126,8 +125,6 @@ cpuTestLoadMultiXML(virArch arch, *count = n; cleanup: - VIR_FREE(xml); - VIR_FREE(nodes); return cpus; cleanup_cpus: diff --git a/tests/metadatatest.c b/tests/metadatatest.c index 2bcb0a1225..2c560c27c1 100644 --- a/tests/metadatatest.c +++ b/tests/metadatatest.c @@ -60,7 +60,7 @@ getMetadataFromXML(virDomainPtr dom) g_autoptr(xmlXPathContext) ctxt = NULL; xmlNodePtr node; - char *xml = NULL; + g_autofree char *xml = NULL; char *ret = NULL; if (!(xml = virDomainGetXMLDesc(dom, 0))) @@ -75,7 +75,6 @@ getMetadataFromXML(virDomainPtr dom) ret = virXMLNodeToString(node->doc, node); cleanup: - VIR_FREE(xml); return ret; } -- 2.31.1