]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
secret: Alter cleanup path for virSecretObjListGetUUIDs
authorJohn Ferlan <jferlan@redhat.com>
Tue, 25 Apr 2017 13:51:29 +0000 (09:51 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Wed, 26 Apr 2017 17:27:15 +0000 (13:27 -0400)
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@redhat.com>
src/conf/virsecretobj.c

index f4ec4fffd9a84a736fa8a0c58fee21f87a6d7252..b5a001d7f57a6c84b421a3d49e373a682c746cbb 100644 (file)
@@ -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;
 }