[PATCH libvirt v2 1/5] conf: use g_autofree to ensure automatic cleanup

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Bjoern Walk <bwalk@xxxxxxxxxxxxx>
Signed-off-by: Shalini Chellathurai Saroja <shalini@xxxxxxxxxxxxx>
Reviewed-by: Boris Fiuczynski <fiuczy@xxxxxxxxxxxxx>
---
 src/conf/device_conf.c | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c
index 4dbd5c1a..1d06981a 100644
--- a/src/conf/device_conf.c
+++ b/src/conf/device_conf.c
@@ -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
-- 
2.25.4




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux