mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 19:32:19 +00:00
conf: domain: Refactor cleanup in virSysinfoParseXML
Use automatic pointer freeing to remove the 'error' label. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
789d302e8d
commit
75849b7503
@ -12394,7 +12394,7 @@ virSysinfoParseXML(xmlNodePtr node,
|
|||||||
bool uuid_generated)
|
bool uuid_generated)
|
||||||
{
|
{
|
||||||
VIR_XPATH_NODE_AUTORESTORE(ctxt)
|
VIR_XPATH_NODE_AUTORESTORE(ctxt)
|
||||||
virSysinfoDef *def;
|
g_autoptr(virSysinfoDef) def = g_new0(virSysinfoDef, 1);
|
||||||
|
|
||||||
ctxt->node = node;
|
ctxt->node = node;
|
||||||
|
|
||||||
@ -12404,32 +12404,26 @@ virSysinfoParseXML(xmlNodePtr node,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
def = g_new0(virSysinfoDef, 1);
|
|
||||||
|
|
||||||
if (virXMLPropEnum(node, "type", virSysinfoTypeFromString,
|
if (virXMLPropEnum(node, "type", virSysinfoTypeFromString,
|
||||||
VIR_XML_PROP_REQUIRED, &def->type) < 0)
|
VIR_XML_PROP_REQUIRED, &def->type) < 0)
|
||||||
goto error;
|
return NULL;
|
||||||
|
|
||||||
switch (def->type) {
|
switch (def->type) {
|
||||||
case VIR_SYSINFO_SMBIOS:
|
case VIR_SYSINFO_SMBIOS:
|
||||||
if (virSysinfoParseSMBIOSDef(def, ctxt, domUUID, uuid_generated) < 0)
|
if (virSysinfoParseSMBIOSDef(def, ctxt, domUUID, uuid_generated) < 0)
|
||||||
goto error;
|
return NULL;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_SYSINFO_FWCFG:
|
case VIR_SYSINFO_FWCFG:
|
||||||
if (virSysinfoParseFWCfgDef(def, node, ctxt) < 0)
|
if (virSysinfoParseFWCfgDef(def, node, ctxt) < 0)
|
||||||
goto error;
|
return NULL;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_SYSINFO_LAST:
|
case VIR_SYSINFO_LAST:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return def;
|
return g_steal_pointer(&def);
|
||||||
|
|
||||||
error:
|
|
||||||
virSysinfoDefFree(def);
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int
|
unsigned int
|
||||||
|
Loading…
x
Reference in New Issue
Block a user