virDomainXMLOptionPtr xmlopt,
unsigned int flags)
{
- xmlDocPtr xml;
- xmlXPathContextPtr ctxt = NULL;
- virDomainDiskDefPtr disk = NULL;
+ VIR_AUTOPTR(xmlDoc) xml = NULL;
+ VIR_AUTOPTR(xmlXPathContext) ctxt = NULL;
virSecurityLabelDefPtr *seclabels = NULL;
size_t nseclabels = 0;
if (!(xml = virXMLParseStringCtxt(xmlStr, _("(disk_definition)"), &ctxt)))
- goto cleanup;
+ return NULL;
if (!virXMLNodeNameEqual(ctxt->node, "disk")) {
virReportError(VIR_ERR_XML_ERROR,
_("expecting root element of 'disk', not '%s'"),
ctxt->node->name);
- goto cleanup;
+ return NULL;
}
if (def) {
nseclabels = def->nseclabels;
}
- disk = virDomainDiskDefParseXML(xmlopt, ctxt->node, ctxt,
+ return virDomainDiskDefParseXML(xmlopt, ctxt->node, ctxt,
seclabels, nseclabels, flags);
-
- cleanup:
- xmlFreeDoc(xml);
- xmlXPathFreeContext(ctxt);
- return disk;
}
virStoragePoolDefParseSourceString(const char *srcSpec,
int pool_type)
{
- xmlDocPtr doc = NULL;
+ VIR_AUTOPTR(xmlDoc) doc = NULL;
xmlNodePtr node = NULL;
- xmlXPathContextPtr xpath_ctxt = NULL;
- virStoragePoolSourcePtr ret = NULL;
+ VIR_AUTOPTR(xmlXPathContext) xpath_ctxt = NULL;
VIR_AUTOPTR(virStoragePoolSource) def = NULL;
if (!(doc = virXMLParseStringCtxt(srcSpec,
_("(storage_source_specification)"),
&xpath_ctxt)))
- goto cleanup;
+ return NULL;
if (VIR_ALLOC(def) < 0)
- goto cleanup;
+ return NULL;
if (!(node = virXPathNode("/source", xpath_ctxt))) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("root element was not source"));
- goto cleanup;
+ return NULL;
}
if (virStoragePoolDefParseSource(xpath_ctxt, def, pool_type,
node) < 0)
- goto cleanup;
-
- VIR_STEAL_PTR(ret, def);
- cleanup:
- xmlFreeDoc(doc);
- xmlXPathFreeContext(xpath_ctxt);
+ return NULL;
- return ret;
+ VIR_RETURN_PTR(def);
}