[PATCH 03/24] qemuMonitorJSONSetMigrationCapabilities: Refactor cleanup

Peter Krempa pkrempa at redhat.com
Mon Nov 30 18:55:16 UTC 2020


Use automatic memory freeing and remove the 'cleanup' label and 'ret'
variable.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/qemu/qemu_monitor_json.c | 24 +++++++++---------------
 1 file changed, 9 insertions(+), 15 deletions(-)

diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index fe5c26f37f..8fd53a565d 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -7133,27 +7133,21 @@ int
 qemuMonitorJSONSetMigrationCapabilities(qemuMonitorPtr mon,
                                         virJSONValuePtr *caps)
 {
-    int ret = -1;
-    virJSONValuePtr cmd = NULL;
-    virJSONValuePtr reply = NULL;
+    g_autoptr(virJSONValue) cmd = NULL;
+    g_autoptr(virJSONValue) reply = NULL;

-    cmd = qemuMonitorJSONMakeCommand("migrate-set-capabilities",
-                                     "a:capabilities", caps,
-                                     NULL);
-    if (!cmd)
-        goto cleanup;
+    if (!(cmd = qemuMonitorJSONMakeCommand("migrate-set-capabilities",
+                                           "a:capabilities", caps,
+                                           NULL)))
+        return -1;

     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;

     if (qemuMonitorJSONCheckError(cmd, reply) < 0)
-        goto cleanup;
+        return -1;

-    ret = 0;
- cleanup:
-    virJSONValueFree(cmd);
-    virJSONValueFree(reply);
-    return ret;
+    return 0;
 }


-- 
2.28.0




More information about the libvir-list mailing list