mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
secret: Alter cleanup path for virSecretObjListGetUUIDs
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>
This commit is contained in:
parent
eda1a62399
commit
1298822e2a
@ -626,8 +626,6 @@ virSecretObjListGetUUIDs(virSecretObjListPtr secrets,
|
|||||||
virSecretObjListACLFilter filter,
|
virSecretObjListACLFilter filter,
|
||||||
virConnectPtr conn)
|
virConnectPtr conn)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
struct virSecretObjListGetHelperData data = {
|
struct virSecretObjListGetHelperData data = {
|
||||||
.conn = conn, .filter = filter, .got = 0,
|
.conn = conn, .filter = filter, .got = 0,
|
||||||
.uuids = uuids, .nuuids = nuuids, .error = false };
|
.uuids = uuids, .nuuids = nuuids, .error = false };
|
||||||
@ -637,16 +635,14 @@ virSecretObjListGetUUIDs(virSecretObjListPtr secrets,
|
|||||||
virObjectUnlock(secrets);
|
virObjectUnlock(secrets);
|
||||||
|
|
||||||
if (data.error)
|
if (data.error)
|
||||||
goto cleanup;
|
goto error;
|
||||||
|
|
||||||
ret = data.got;
|
return data.got;
|
||||||
|
|
||||||
cleanup:
|
error:
|
||||||
if (ret < 0) {
|
while (data.got)
|
||||||
while (data.got)
|
VIR_FREE(data.uuids[--data.got]);
|
||||||
VIR_FREE(data.uuids[--data.got]);
|
return -1;
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user