[PATCH v3 01/11] util: iscsi: use VIR_AUTOFREE instead of VIR_FREE for scalar types

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

 



Add another usage for VIR_AUTOFREE macro which was left in the
commit ec3e878, thereby dropping a VIR_FREE call and and a cleanup
section.

Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@xxxxxxxxx>
---
 src/util/viriscsi.c | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/src/util/viriscsi.c b/src/util/viriscsi.c
index c805ffc..cf07968 100644
--- a/src/util/viriscsi.c
+++ b/src/util/viriscsi.c
@@ -208,9 +208,10 @@ static int
 virStorageBackendCreateIfaceIQN(const char *initiatoriqn,
                                 char **ifacename)
 {
-    int ret = -1, exitstatus = -1;
+    int exitstatus = -1;
+    VIR_AUTOPTR(virCommand) cmd = NULL;
+    VIR_AUTOFREE(char *) iface_name = NULL;
     VIR_AUTOFREE(char *) temp_ifacename = NULL;
-    VIR_AUTOPTR(virCommand) cmd = NULL;
 
     if (virAsprintf(&temp_ifacename,
                     "libvirt-iface-%08llx",
@@ -233,7 +234,7 @@ virStorageBackendCreateIfaceIQN(const char *initiatoriqn,
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("Failed to run command '%s' to create new iscsi interface"),
                        ISCSIADM);
-        goto cleanup;
+        return -1;
     }
     virCommandFree(cmd);
 
@@ -252,26 +253,23 @@ virStorageBackendCreateIfaceIQN(const char *initiatoriqn,
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("Failed to run command '%s' to update iscsi interface with IQN '%s'"),
                        ISCSIADM, initiatoriqn);
-        goto cleanup;
+        return -1;
     }
 
     /* Check again to make sure the interface was created. */
-    if (virStorageBackendIQNFound(initiatoriqn, ifacename) != IQN_FOUND) {
+    if (virStorageBackendIQNFound(initiatoriqn, &iface_name) != IQN_FOUND) {
         VIR_DEBUG("Failed to find interface '%s' with IQN '%s' "
                   "after attempting to create it",
                   &temp_ifacename[0], initiatoriqn);
-        goto cleanup;
+        return -1;
     } else {
         VIR_DEBUG("Interface '%s' with IQN '%s' was created successfully",
-                  *ifacename, initiatoriqn);
+                  iface_name, initiatoriqn);
     }
 
-    ret = 0;
+    VIR_STEAL_PTR(*ifacename, iface_name);
 
- cleanup:
-    if (ret != 0)
-        VIR_FREE(*ifacename);
-    return ret;
+    return 0;
 }
 
 
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[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