]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virNodeDevCapsDefParseXML: Use g_autoptr
authorTim Wiederhake <twiederh@redhat.com>
Mon, 10 May 2021 12:48:40 +0000 (14:48 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 11 May 2021 12:04:06 +0000 (14:04 +0200)
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/conf/node_device_conf.c

index b3d5bc15155cc2e62e631d45093ddad257e1b2c5..04014f75dc127ff359e09937a70c9c9e3ddf2b4e 100644 (file)
@@ -1971,14 +1971,12 @@ virNodeDevCapsDefParseXML(xmlXPathContextPtr ctxt,
                           int create,
                           const char *virt_type)
 {
-    virNodeDevCapsDef *caps;
+    g_autoptr(virNodeDevCapsDef) caps = g_new0(virNodeDevCapsDef, 1);
     int ret = -1;
 
-    caps = g_new0(virNodeDevCapsDef, 1);
-
     if (virXMLPropEnum(node, "type", virNodeDevCapTypeFromString,
                        VIR_XML_PROP_REQUIRED, &caps->data.type) < 0)
-        goto error;
+        return NULL;
 
     switch (caps->data.type) {
     case VIR_NODE_DEV_CAP_SYSTEM:
@@ -2050,12 +2048,9 @@ virNodeDevCapsDefParseXML(xmlXPathContextPtr ctxt,
     }
 
     if (ret < 0)
-        goto error;
-    return caps;
+        return NULL;
 
- error:
-    virNodeDevCapsDefFree(caps);
-    return NULL;
+    return g_steal_pointer(&caps);
 }