mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
secret: Remove need for local configFile and base64File in ObjectAdd
Rather than assign to a local variable, let's just assign directly to the object using the error path for cleanup. Signed-off-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
2d3c7122c8
commit
7ca17da9f2
@ -335,7 +335,6 @@ virSecretObjListAdd(virSecretObjListPtr secrets,
|
|||||||
virSecretDefPtr objdef;
|
virSecretDefPtr objdef;
|
||||||
virSecretObjPtr ret = NULL;
|
virSecretObjPtr ret = NULL;
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||||
char *configFile = NULL, *base64File = NULL;
|
|
||||||
|
|
||||||
virObjectLock(secrets);
|
virObjectLock(secrets);
|
||||||
|
|
||||||
@ -384,22 +383,20 @@ virSecretObjListAdd(virSecretObjListPtr secrets,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!(obj = virSecretObjNew()))
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
/* Generate the possible configFile and base64File strings
|
/* Generate the possible configFile and base64File strings
|
||||||
* using the configDir, uuidstr, and appropriate suffix
|
* using the configDir, uuidstr, and appropriate suffix
|
||||||
*/
|
*/
|
||||||
if (!(configFile = virFileBuildPath(configDir, uuidstr, ".xml")) ||
|
if (!(obj->configFile = virFileBuildPath(configDir, uuidstr, ".xml")) ||
|
||||||
!(base64File = virFileBuildPath(configDir, uuidstr, ".base64")))
|
!(obj->base64File = virFileBuildPath(configDir, uuidstr, ".base64")))
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if (!(obj = virSecretObjNew()))
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virHashAddEntry(secrets->objs, uuidstr, obj) < 0)
|
if (virHashAddEntry(secrets->objs, uuidstr, obj) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
obj->def = newdef;
|
obj->def = newdef;
|
||||||
VIR_STEAL_PTR(obj->configFile, configFile);
|
|
||||||
VIR_STEAL_PTR(obj->base64File, base64File);
|
|
||||||
virObjectRef(obj);
|
virObjectRef(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -408,8 +405,6 @@ virSecretObjListAdd(virSecretObjListPtr secrets,
|
|||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virSecretObjEndAPI(&obj);
|
virSecretObjEndAPI(&obj);
|
||||||
VIR_FREE(configFile);
|
|
||||||
VIR_FREE(base64File);
|
|
||||||
virObjectUnlock(secrets);
|
virObjectUnlock(secrets);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user