]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuMonitorJSONSetMigrationCapabilities: Refactor cleanup
authorPeter Krempa <pkrempa@redhat.com>
Mon, 30 Nov 2020 14:27:44 +0000 (15:27 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 8 Jan 2021 08:17:25 +0000 (09:17 +0100)
Use automatic memory freeing and remove the 'cleanup' label and 'ret'
variable.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_monitor_json.c

index 0660c37e1ea6a5950bbf92b6c319dbdc09db6cc8..cb31df30192bef8b24f23fb90aaab5476306b16b 100644 (file)
@@ -6974,27 +6974,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;
 }