]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Use g_autoptr in qemuMonitorJSONSetCapabilities
authorJiri Denemark <jdenemar@redhat.com>
Fri, 19 Mar 2021 22:28:38 +0000 (23:28 +0100)
committerJiri Denemark <jdenemar@redhat.com>
Mon, 22 Mar 2021 11:44:18 +0000 (12:44 +0100)
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
src/qemu/qemu_monitor_json.c

index b669630bc878748e756cea8a541e28fff3f69eea..5e7f425495db2d05f5be5e1a74b944cd0244b3f8 100644 (file)
@@ -1644,23 +1644,20 @@ qemuMonitorJSONHumanCommand(qemuMonitorPtr mon,
 int
 qemuMonitorJSONSetCapabilities(qemuMonitorPtr mon)
 {
-    int ret = -1;
-    virJSONValuePtr cmd = qemuMonitorJSONMakeCommand("qmp_capabilities", NULL);
-    virJSONValuePtr reply = NULL;
-    if (!cmd)
+    g_autoptr(virJSONValue) cmd = NULL;
+    g_autoptr(virJSONValue) reply = NULL;
+
+    if (!(cmd = qemuMonitorJSONMakeCommand("qmp_capabilities",
+                                           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;
 }