1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-25 01:34:11 +03:00

qemu: Use g_autofree and g_autoptr in qemuAgentSetUserPassword

Signed-off-by: Seeteena Thoufeek <s1seetee@linux.vnet.ibm.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Seeteena Thoufeek 2020-03-23 16:43:59 +05:30 committed by Michal Privoznik
parent 8c53938e18
commit b66744e466

View File

@ -2274,10 +2274,9 @@ qemuAgentSetUserPassword(qemuAgentPtr agent,
const char *password,
bool crypted)
{
int ret = -1;
virJSONValuePtr cmd = NULL;
virJSONValuePtr reply = NULL;
char *password64 = NULL;
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
g_autofree char *password64 = NULL;
password64 = g_base64_encode((unsigned char *)password,
strlen(password));
@ -2287,18 +2286,12 @@ qemuAgentSetUserPassword(qemuAgentPtr agent,
"s:username", user,
"s:password", password64,
NULL)))
goto cleanup;
return -1;
if (qemuAgentCommand(agent, cmd, &reply, agent->timeout) < 0)
goto cleanup;
return -1;
ret = 0;
cleanup:
virJSONValueFree(cmd);
virJSONValueFree(reply);
VIR_FREE(password64);
return ret;
return 0;
}
/* Returns: 0 on success