]> xenbits.xensource.com Git - libvirt.git/commitdiff
virDomainRedirFilterUSBDevDefParseXML: Use g_auto*
authorTim Wiederhake <twiederh@redhat.com>
Tue, 4 May 2021 14:02:26 +0000 (16:02 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 6 May 2021 11:54:33 +0000 (13:54 +0200)
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/conf/domain_conf.c

index 51ced0f1c4848ad90a76a761b190fadf5caf4a41..926705aa54768a28fdd1f50107e77fdc200cb92a 100644 (file)
@@ -14505,7 +14505,7 @@ virDomainRedirFilterUSBVersionHelper(const char *version,
 static virDomainRedirFilterUSBDevDef *
 virDomainRedirFilterUSBDevDefParseXML(xmlNodePtr node)
 {
-    virDomainRedirFilterUSBDevDef *def;
+    g_autofree virDomainRedirFilterUSBDevDef *def = NULL;
     g_autofree char *version = NULL;
     virTristateBool allow;
 
@@ -14513,42 +14513,38 @@ virDomainRedirFilterUSBDevDefParseXML(xmlNodePtr node)
 
     def->usbClass = -1;
     if (virXMLPropInt(node, "class", 0, VIR_XML_PROP_NONE, &def->usbClass) < 0)
-        goto error;
+        return NULL;
 
     if (def->usbClass != -1 && def->usbClass &~ 0xFF) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("Invalid USB Class code 0x%x"), def->usbClass);
-        goto error;
+        return NULL;
     }
 
     def->vendor = -1;
     if (virXMLPropInt(node, "vendor", 0, VIR_XML_PROP_NONE, &def->vendor) < 0)
-        goto error;
+        return NULL;
 
     def->product = -1;
     if (virXMLPropInt(node, "product", 0, VIR_XML_PROP_NONE, &def->product) < 0)
-        goto error;
+        return NULL;
 
     version = virXMLPropString(node, "version");
     if (version) {
         if (STREQ(version, "-1"))
             def->version = -1;
         else if ((virDomainRedirFilterUSBVersionHelper(version, def)) < 0)
-            goto error;
+            return NULL;
     } else {
         def->version = -1;
     }
 
     if (virXMLPropTristateBool(node, "allow", VIR_XML_PROP_REQUIRED, &allow) < 0)
-        goto error;
+        return NULL;
 
     def->allow = allow == VIR_TRISTATE_BOOL_YES;
 
-    return def;
-
- error:
-    VIR_FREE(def);
-    return NULL;
+    return g_steal_pointer(&def);
 }
 
 static virDomainRedirFilterDef *