]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Use g_autofree and g_autoptr in qemuAgentSetUserPassword
authorSeeteena Thoufeek <s1seetee@linux.vnet.ibm.com>
Mon, 23 Mar 2020 11:13:59 +0000 (16:43 +0530)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 23 Mar 2020 13:16:20 +0000 (14:16 +0100)
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>
src/qemu/qemu_agent.c

index 6ff5b11374b566af61c2da6474becc788d8ad46a..0141ddcb5b2af8c39499fae2ba119386c408a54c 100644 (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;
-
-    ret = 0;
+        return -1;
 
- cleanup:
-    virJSONValueFree(cmd);
-    virJSONValueFree(reply);
-    VIR_FREE(password64);
-    return ret;
+    return 0;
 }
 
 /* Returns: 0 on success