mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
virsh: secret: Refactor cleanup in cmdSecretGetValue
Automatically clean the secret object and get rid of the cleanup label and 'ret' valiable. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
66770bc6f5
commit
1a552eccf1
@ -240,29 +240,23 @@ static const vshCmdOptDef opts_secret_get_value[] = {
|
||||
static bool
|
||||
cmdSecretGetValue(vshControl *ctl, const vshCmd *cmd)
|
||||
{
|
||||
virSecretPtr secret;
|
||||
g_autoptr(virshSecret) secret = NULL;
|
||||
VIR_AUTODISPOSE_STR base64 = NULL;
|
||||
unsigned char *value;
|
||||
size_t value_size;
|
||||
bool ret = false;
|
||||
|
||||
secret = virshCommandOptSecret(ctl, cmd, NULL);
|
||||
if (secret == NULL)
|
||||
if (!(secret = virshCommandOptSecret(ctl, cmd, NULL)))
|
||||
return false;
|
||||
|
||||
value = virSecretGetValue(secret, &value_size, 0);
|
||||
if (value == NULL)
|
||||
goto cleanup;
|
||||
if (!(value = virSecretGetValue(secret, &value_size, 0)))
|
||||
return false;
|
||||
|
||||
base64 = g_base64_encode(value, value_size);
|
||||
|
||||
vshPrint(ctl, "%s", base64);
|
||||
ret = true;
|
||||
|
||||
cleanup:
|
||||
VIR_DISPOSE_N(value, value_size);
|
||||
virshSecretFree(secret);
|
||||
return ret;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user