mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-01 17:35:17 +00:00
Use g_autofree in affected functions
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@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
2c426d2e30
commit
9302e249db
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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:
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user