Signed-off-by: Seeteena Thoufeek <s1seetee@linux.vnet.ibm.com>
---
src/qemu/qemu_agent.c | 19 ++++++-------------
1 file changed, 6 insertions(+), 13 deletions(-)
diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index 9ea2c59563..1583a4eee2 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -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;
-
- ret = 0;
+ return -1;
- cleanup:
- virJSONValueFree(cmd);
- virJSONValueFree(reply);
- VIR_FREE(password64);
- return ret;
+ return 0;
}
/* Returns: 0 on success
--
2.18.2
On 3/23/20 8:13 AM, Seeteena Thoufeek wrote:
> Signed-off-by: Seeteena Thoufeek <s1seetee@linux.vnet.ibm.com>
> ---
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
> src/qemu/qemu_agent.c | 19 ++++++-------------
> 1 file changed, 6 insertions(+), 13 deletions(-)
>
> diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
> index 9ea2c59563..1583a4eee2 100644
> --- a/src/qemu/qemu_agent.c
> +++ b/src/qemu/qemu_agent.c
> @@ -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;
> -
> - ret = 0;
> + return -1;
>
> - cleanup:
> - virJSONValueFree(cmd);
> - virJSONValueFree(reply);
> - VIR_FREE(password64);
> - return ret;
> + return 0;
> }
>
> /* Returns: 0 on success
>
On 23. 3. 2020 12:26, Daniel Henrique Barboza wrote: > > > On 3/23/20 8:13 AM, Seeteena Thoufeek wrote: >> Signed-off-by: Seeteena Thoufeek <s1seetee@linux.vnet.ibm.com> >> --- > > > Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com> And now pushed. Congratulations on your first libvirt contribution! Michal
© 2016 - 2026 Red Hat, Inc.