]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: use g_autofree to ensure automatic cleanup
authorShalini Chellathurai Saroja <shalini@linux.ibm.com>
Thu, 18 Jun 2020 08:25:14 +0000 (10:25 +0200)
committerAndrea Bolognani <abologna@redhat.com>
Fri, 26 Jun 2020 16:31:09 +0000 (18:31 +0200)
Signed-off-by: Bjoern Walk <bwalk@linux.ibm.com>
Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
src/conf/device_conf.c

index 4dbd5c1ac95c9062f04efce7adcc9651ade20e83..1d06981a617b84f2625ae0ec8ac7c25c3a1c9ff9 100644 (file)
@@ -53,9 +53,8 @@ virZPCIDeviceAddressParseXML(xmlNodePtr node,
                              virPCIDeviceAddressPtr addr)
 {
     virZPCIDeviceAddress def = { 0 };
-    char *uid;
-    char *fid;
-    int ret = -1;
+    g_autofree char *uid = NULL;
+    g_autofree char *fid = NULL;
 
     uid = virXMLPropString(node, "uid");
     fid = virXMLPropString(node, "fid");
@@ -64,27 +63,23 @@ virZPCIDeviceAddressParseXML(xmlNodePtr node,
         virStrToLong_uip(uid, NULL, 0, &def.uid) < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("Cannot parse <address> 'uid' attribute"));
-        goto cleanup;
+        return -1;
     }
 
     if (fid &&
         virStrToLong_uip(fid, NULL, 0, &def.fid) < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("Cannot parse <address> 'fid' attribute"));
-        goto cleanup;
+        return -1;
     }
 
     if (!virZPCIDeviceAddressIsEmpty(&def) &&
         !virZPCIDeviceAddressIsValid(&def))
-        goto cleanup;
+        return -1;
 
     addr->zpci = def;
-    ret = 0;
 
- cleanup:
-    VIR_FREE(uid);
-    VIR_FREE(fid);
-    return ret;
+    return 0;
 }
 
 void