]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuMonitorJSONBlockJobCancel: Refactor cleanup
authorPeter Krempa <pkrempa@redhat.com>
Tue, 20 Apr 2021 14:16:56 +0000 (16:16 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 26 Apr 2021 15:22:52 +0000 (17:22 +0200)
Use automatic memory freeing and remove the cleanup section.

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

index 652034472ac688b8343caa1a7f3024bb9f16b29b..8f3ccb0c63607f16f0f2cffc10ed88f8386747f2 100644 (file)
@@ -5219,9 +5219,8 @@ int
 qemuMonitorJSONBlockJobCancel(qemuMonitor *mon,
                               const char *jobname)
 {
-    int ret = -1;
-    virJSONValue *cmd = NULL;
-    virJSONValue *reply = NULL;
+    g_autoptr(virJSONValue) cmd = NULL;
+    g_autoptr(virJSONValue) reply = NULL;
 
     if (!(cmd = qemuMonitorJSONMakeCommand("block-job-cancel",
                                            "s:device", jobname,
@@ -5229,17 +5228,12 @@ qemuMonitorJSONBlockJobCancel(qemuMonitor *mon,
         return -1;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return -1;
 
     if (qemuMonitorJSONBlockJobError(cmd, reply, jobname) < 0)
-        goto cleanup;
-
-    ret = 0;
+        return -1;
 
- cleanup:
-    virJSONValueFree(cmd);
-    virJSONValueFree(reply);
-    return ret;
+    return 0;
 }