[libvirt PATCH 06/10] qemuMonitorJSONGetAllBlockJobInfo: Use automatic memory management

Tim Wiederhake twiederh at redhat.com
Mon Jul 19 09:55:50 UTC 2021


Signed-off-by: Tim Wiederhake <twiederh at redhat.com>
---
 src/qemu/qemu_monitor_json.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 472308e1d3..59c5eedb0a 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -5069,12 +5069,12 @@ GHashTable *
 qemuMonitorJSONGetAllBlockJobInfo(qemuMonitor *mon,
                                   bool rawjobname)
 {
-    virJSONValue *cmd = NULL;
-    virJSONValue *reply = NULL;
+    g_autoptr(virJSONValue) cmd = NULL;
+    g_autoptr(virJSONValue) reply = NULL;
     virJSONValue *data;
     size_t nr_results;
     size_t i;
-    GHashTable *blockJobs = NULL;
+    g_autoptr(GHashTable) blockJobs = NULL;
 
     cmd = qemuMonitorJSONMakeCommand("query-block-jobs", NULL);
     if (!cmd)
@@ -5103,14 +5103,10 @@ qemuMonitorJSONGetAllBlockJobInfo(qemuMonitor *mon,
     }
 
  cleanup:
-    virJSONValueFree(cmd);
-    virJSONValueFree(reply);
-    return blockJobs;
+    return g_steal_pointer(&blockJobs);
 
  error:
-    virHashFree(blockJobs);
-    blockJobs = NULL;
-    goto cleanup;
+    return NULL;
 }
 
 
-- 
2.31.1




More information about the libvir-list mailing list