secret: Change variable names for list traversals

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@redhat.com>
This commit is contained in:
John Ferlan 2017-04-19 08:34:04 -04:00
parent 1298822e2a
commit 4a24498c4a
2 changed files with 15 additions and 15 deletions

View File

@ -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;
}

View File

@ -76,7 +76,7 @@ virSecretObjListExport(virConnectPtr conn,
int
virSecretObjListGetUUIDs(virSecretObjListPtr secrets,
char **uuids,
int nuuids,
int maxuuids,
virSecretObjListACLFilter filter,
virConnectPtr conn);