mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-23 21:15:20 +00: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:
parent
8c53938e18
commit
b66744e466
@ -2274,10 +2274,9 @@ qemuAgentSetUserPassword(qemuAgentPtr agent,
|
|||||||
const char *password,
|
const char *password,
|
||||||
bool crypted)
|
bool crypted)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
g_autoptr(virJSONValue) cmd = NULL;
|
||||||
virJSONValuePtr cmd = NULL;
|
g_autoptr(virJSONValue) reply = NULL;
|
||||||
virJSONValuePtr reply = NULL;
|
g_autofree char *password64 = NULL;
|
||||||
char *password64 = NULL;
|
|
||||||
|
|
||||||
password64 = g_base64_encode((unsigned char *)password,
|
password64 = g_base64_encode((unsigned char *)password,
|
||||||
strlen(password));
|
strlen(password));
|
||||||
@ -2287,18 +2286,12 @@ qemuAgentSetUserPassword(qemuAgentPtr agent,
|
|||||||
"s:username", user,
|
"s:username", user,
|
||||||
"s:password", password64,
|
"s:password", password64,
|
||||||
NULL)))
|
NULL)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuAgentCommand(agent, cmd, &reply, agent->timeout) < 0)
|
if (qemuAgentCommand(agent, cmd, &reply, agent->timeout) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
virJSONValueFree(cmd);
|
|
||||||
virJSONValueFree(reply);
|
|
||||||
VIR_FREE(password64);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns: 0 on success
|
/* Returns: 0 on success
|
||||||
|
Loading…
x
Reference in New Issue
Block a user