[PATCH v1 09/18] use VIR_AUTOFREE in src/util/virfcp.c

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

 



Modify code to use VIR_AUTOFREE macro wherever required.

Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@xxxxxxxxx>
---
 src/util/virfcp.c | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/src/util/virfcp.c b/src/util/virfcp.c
index 7660ba7..b703744 100644
--- a/src/util/virfcp.c
+++ b/src/util/virfcp.c
@@ -40,16 +40,12 @@
 bool
 virFCIsCapableRport(const char *rport)
 {
-    bool ret = false;
-    char *path = NULL;
+    VIR_AUTOFREE(char *) path = NULL;
 
     if (virBuildPath(&path, SYSFS_FC_RPORT_PATH, rport) < 0)
         return false;
 
-    ret = virFileExists(path);
-    VIR_FREE(path);
-
-    return ret;
+    return virFileExists(path);
 }
 
 int
@@ -57,8 +53,8 @@ virFCReadRportValue(const char *rport,
                     const char *entry,
                     char **result)
 {
-    int ret = -1;
-    char *buf = NULL, *p = NULL;
+    VIR_AUTOFREE(char *) buf = NULL;
+    char *p = NULL;
 
     if (virFileReadValueString(&buf, "%s/%s/%s",
                                SYSFS_FC_RPORT_PATH, rport, entry) < 0) {
@@ -69,13 +65,9 @@ virFCReadRportValue(const char *rport,
         *p = '\0';
 
     if (VIR_STRDUP(*result, buf) < 0)
-        goto cleanup;
-
-    ret = 0;
+        return -1;
 
- cleanup:
-    VIR_FREE(buf);
-    return ret;
+    return 0;
 }
 
 #else
-- 
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