virNodeDevCapsDefParseXML: Use g_autoptr
Signed-off-by: Tim Wiederhake <twiederh@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
27b09ff09f
commit
1f59f2fd3d
@ -1971,14 +1971,12 @@ virNodeDevCapsDefParseXML(xmlXPathContextPtr ctxt,
|
|||||||
int create,
|
int create,
|
||||||
const char *virt_type)
|
const char *virt_type)
|
||||||
{
|
{
|
||||||
virNodeDevCapsDef *caps;
|
g_autoptr(virNodeDevCapsDef) caps = g_new0(virNodeDevCapsDef, 1);
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
caps = g_new0(virNodeDevCapsDef, 1);
|
|
||||||
|
|
||||||
if (virXMLPropEnum(node, "type", virNodeDevCapTypeFromString,
|
if (virXMLPropEnum(node, "type", virNodeDevCapTypeFromString,
|
||||||
VIR_XML_PROP_REQUIRED, &caps->data.type) < 0)
|
VIR_XML_PROP_REQUIRED, &caps->data.type) < 0)
|
||||||
goto error;
|
return NULL;
|
||||||
|
|
||||||
switch (caps->data.type) {
|
switch (caps->data.type) {
|
||||||
case VIR_NODE_DEV_CAP_SYSTEM:
|
case VIR_NODE_DEV_CAP_SYSTEM:
|
||||||
@ -2050,12 +2048,9 @@ virNodeDevCapsDefParseXML(xmlXPathContextPtr ctxt,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto error;
|
return NULL;
|
||||||
return caps;
|
|
||||||
|
|
||||||
error:
|
return g_steal_pointer(&caps);
|
||||||
virNodeDevCapsDefFree(caps);
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user