]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuMonitorJSONQueryBlockstats: Refactor cleanup
authorPeter Krempa <pkrempa@redhat.com>
Tue, 19 Oct 2021 13:05:21 +0000 (15:05 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 20 Oct 2021 11:43:37 +0000 (13:43 +0200)
Use automatic memory clearing and remove the cleanup label.

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

index e4f4dba79a594f432171810c4811481fb4649985..6cf36d251812869e2a445fe56bb35d36e755b22a 100644 (file)
@@ -2520,25 +2520,19 @@ qemuMonitorJSONGetOneBlockStatsInfo(virJSONValue *dev,
 virJSONValue *
 qemuMonitorJSONQueryBlockstats(qemuMonitor *mon)
 {
-    virJSONValue *cmd;
-    virJSONValue *reply = NULL;
-    virJSONValue *ret = NULL;
+    g_autoptr(virJSONValue) cmd = NULL;
+    g_autoptr(virJSONValue) reply = NULL;
 
     if (!(cmd = qemuMonitorJSONMakeCommand("query-blockstats", 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");
+        return NULL;
 
- cleanup:
-    virJSONValueFree(cmd);
-    virJSONValueFree(reply);
-    return ret;
+    return virJSONValueObjectStealArray(reply, "return");
 }