]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: monitor: Refactor variable cleanup in qemuMonitorJSONQueryNamedBlockNodes
authorPeter Krempa <pkrempa@redhat.com>
Tue, 21 Jan 2020 15:33:12 +0000 (16:33 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 4 Mar 2020 13:39:24 +0000 (14:39 +0100)
Use g_autoptr to get rid of the cleanup section.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_monitor_json.c

index 50d93c0c7edf28231fdb18fbeeb33977a4b89807..a2f253f731dcc83efb9363f42699bde274664a83 100644 (file)
@@ -8742,26 +8742,19 @@ qemuMonitorJSONSetBlockThreshold(qemuMonitorPtr mon,
 virJSONValuePtr
 qemuMonitorJSONQueryNamedBlockNodes(qemuMonitorPtr mon)
 {
-    virJSONValuePtr cmd;
-    virJSONValuePtr reply = NULL;
-    virJSONValuePtr ret = NULL;
+    g_autoptr(virJSONValue) cmd = NULL;
+    g_autoptr(virJSONValue) reply = NULL;
 
     if (!(cmd = qemuMonitorJSONMakeCommand("query-named-block-nodes", NULL)))
         return NULL;
 
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
-        goto cleanup;
+        return NULL;
 
     if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_ARRAY) < 0)
-        goto cleanup;
-
-    ret = virJSONValueObjectStealArray(reply, "return");
-
- cleanup:
-    virJSONValueFree(cmd);
-    virJSONValueFree(reply);
+        return NULL;
 
-    return ret;
+    return virJSONValueObjectStealArray(reply, "return");
 }