[PATCH v2 06/11] secret: Change variable names for list traversals

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

 



Rather than 'nuuids' it should be 'maxuuids' and rather than 'got'
it should be 'nuuids'.  Alter the logic of the list traversal to
utilize those names.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/conf/virsecretobj.c | 28 ++++++++++++++--------------
 src/conf/virsecretobj.h |  2 +-
 2 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/src/conf/virsecretobj.c b/src/conf/virsecretobj.c
index b5a001d..eae735f 100644
--- a/src/conf/virsecretobj.c
+++ b/src/conf/virsecretobj.c
@@ -436,9 +436,9 @@ virSecretObjListAdd(virSecretObjListPtr secrets,
 struct virSecretObjListGetHelperData {
     virConnectPtr conn;
     virSecretObjListACLFilter filter;
-    int got;
-    char **uuids;
     int nuuids;
+    char **uuids;
+    int maxuuids;
     bool error;
 };
 
@@ -455,7 +455,7 @@ virSecretObjListGetHelper(void *payload,
     if (data->error)
         return 0;
 
-    if (data->nuuids >= 0 && data->got == data->nuuids)
+    if (data->maxuuids >= 0 && data->nuuids == data->maxuuids)
         return 0;
 
     virObjectLock(obj);
@@ -473,10 +473,10 @@ virSecretObjListGetHelper(void *payload,
         }
 
         virUUIDFormat(def->uuid, uuidstr);
-        data->uuids[data->got] = uuidstr;
+        data->uuids[data->nuuids] = uuidstr;
     }
 
-    data->got++;
+    data->nuuids++;
 
  cleanup:
     virObjectUnlock(obj);
@@ -490,14 +490,14 @@ virSecretObjListNumOfSecrets(virSecretObjListPtr secrets,
                              virConnectPtr conn)
 {
     struct virSecretObjListGetHelperData data = {
-        .conn = conn, .filter = filter, .got = 0,
-        .uuids = NULL, .nuuids = -1, .error = false };
+        .conn = conn, .filter = filter, .nuuids = 0,
+        .uuids = NULL, .maxuuids = -1, .error = false };
 
     virObjectLock(secrets);
     virHashForEach(secrets->objs, virSecretObjListGetHelper, &data);
     virObjectUnlock(secrets);
 
-    return data.got;
+    return data.nuuids;
 }
 
 
@@ -622,13 +622,13 @@ virSecretObjListExport(virConnectPtr conn,
 int
 virSecretObjListGetUUIDs(virSecretObjListPtr secrets,
                          char **uuids,
-                         int nuuids,
+                         int maxuuids,
                          virSecretObjListACLFilter filter,
                          virConnectPtr conn)
 {
     struct virSecretObjListGetHelperData data = {
-        .conn = conn, .filter = filter, .got = 0,
-        .uuids = uuids, .nuuids = nuuids, .error = false };
+        .conn = conn, .filter = filter, .nuuids = 0,
+        .uuids = uuids, .maxuuids = maxuuids, .error = false };
 
     virObjectLock(secrets);
     virHashForEach(secrets->objs, virSecretObjListGetHelper, &data);
@@ -637,11 +637,11 @@ virSecretObjListGetUUIDs(virSecretObjListPtr secrets,
     if (data.error)
         goto error;
 
-    return data.got;
+    return data.nuuids;
 
  error:
-    while (data.got)
-        VIR_FREE(data.uuids[--data.got]);
+    while (--data.nuuids)
+        VIR_FREE(data.uuids[data.nuuids]);
     return -1;
 }
 
diff --git a/src/conf/virsecretobj.h b/src/conf/virsecretobj.h
index 8038faa..2cba731 100644
--- a/src/conf/virsecretobj.h
+++ b/src/conf/virsecretobj.h
@@ -76,7 +76,7 @@ virSecretObjListExport(virConnectPtr conn,
 int
 virSecretObjListGetUUIDs(virSecretObjListPtr secrets,
                          char **uuids,
-                         int nuuids,
+                         int maxuuids,
                          virSecretObjListACLFilter filter,
                          virConnectPtr conn);
 
-- 
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