[PATCH v2 05/11] secret: Alter cleanup path for virSecretObjListGetUUIDs

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

 



Rather than using "ret = -1" and cleanup processing, alter the return
path on failure to goto error and then just return the data.got.

In the error path, we no longer check for ret < 0, we just can free
anything added to the array and return -1 directly

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/conf/virsecretobj.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/src/conf/virsecretobj.c b/src/conf/virsecretobj.c
index f4ec4ff..b5a001d 100644
--- a/src/conf/virsecretobj.c
+++ b/src/conf/virsecretobj.c
@@ -626,8 +626,6 @@ virSecretObjListGetUUIDs(virSecretObjListPtr secrets,
                          virSecretObjListACLFilter filter,
                          virConnectPtr conn)
 {
-    int ret = -1;
-
     struct virSecretObjListGetHelperData data = {
         .conn = conn, .filter = filter, .got = 0,
         .uuids = uuids, .nuuids = nuuids, .error = false };
@@ -637,16 +635,14 @@ virSecretObjListGetUUIDs(virSecretObjListPtr secrets,
     virObjectUnlock(secrets);
 
     if (data.error)
-        goto cleanup;
+        goto error;
 
-    ret = data.got;
+    return data.got;
 
- cleanup:
-    if (ret < 0) {
-        while (data.got)
-            VIR_FREE(data.uuids[--data.got]);
-    }
-    return ret;
+ error:
+    while (data.got)
+        VIR_FREE(data.uuids[--data.got]);
+    return -1;
 }
 
 
-- 
2.9.3

--
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