mirror of https://gitee.com/openkylin/libvirt.git
conf: domain: Refactor cleanup in virDomainDefParseNode
Use VIR_AUTOPTR for temporary locals and get rid of the cleanup label. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
parent
f02b4fc4ea
commit
db2c3c80c2
|
@ -21558,32 +21558,26 @@ virDomainDefParseNode(xmlDocPtr xml,
|
||||||
void *parseOpaque,
|
void *parseOpaque,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
xmlXPathContextPtr ctxt = NULL;
|
VIR_AUTOPTR(xmlXPathContext) ctxt = NULL;
|
||||||
virDomainDefPtr def = NULL;
|
VIR_AUTOPTR(virDomainDef) def = NULL;
|
||||||
virDomainDefPtr ret = NULL;
|
|
||||||
|
|
||||||
if (!(ctxt = virXMLXPathContextNew(xml)))
|
if (!(ctxt = virXMLXPathContextNew(xml)))
|
||||||
goto cleanup;
|
return NULL;
|
||||||
|
|
||||||
ctxt->node = root;
|
ctxt->node = root;
|
||||||
|
|
||||||
if (!(def = virDomainDefParseXML(xml, ctxt, caps, xmlopt, flags)))
|
if (!(def = virDomainDefParseXML(xml, ctxt, caps, xmlopt, flags)))
|
||||||
goto cleanup;
|
return NULL;
|
||||||
|
|
||||||
/* callback to fill driver specific domain aspects */
|
/* callback to fill driver specific domain aspects */
|
||||||
if (virDomainDefPostParse(def, caps, flags, xmlopt, parseOpaque) < 0)
|
if (virDomainDefPostParse(def, caps, flags, xmlopt, parseOpaque) < 0)
|
||||||
goto cleanup;
|
return NULL;
|
||||||
|
|
||||||
/* validate configuration */
|
/* validate configuration */
|
||||||
if (virDomainDefValidate(def, caps, flags, xmlopt) < 0)
|
if (virDomainDefValidate(def, caps, flags, xmlopt) < 0)
|
||||||
goto cleanup;
|
return NULL;
|
||||||
|
|
||||||
VIR_STEAL_PTR(ret, def);
|
VIR_RETURN_PTR(def);
|
||||||
|
|
||||||
cleanup:
|
|
||||||
virDomainDefFree(def);
|
|
||||||
xmlXPathFreeContext(ctxt);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue