]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuMonitorGetChardevInfo: Use automatic memory management
authorTim Wiederhake <twiederh@redhat.com>
Tue, 6 Jul 2021 12:37:58 +0000 (14:37 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 13 Jul 2021 12:40:28 +0000 (14:40 +0200)
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_monitor.c

index cb59fc7b7bc2c58fcc539672a68fc225471350e4..769866e585268009d4e01c4c2ab3662c55d323c3 100644 (file)
@@ -2884,25 +2884,20 @@ int
 qemuMonitorGetChardevInfo(qemuMonitor *mon,
                           GHashTable **retinfo)
 {
-    GHashTable *info = NULL;
+    g_autoptr(GHashTable) info = NULL;
 
     VIR_DEBUG("retinfo=%p", retinfo);
 
-    QEMU_CHECK_MONITOR_GOTO(mon, error);
+    QEMU_CHECK_MONITOR(mon);
 
     if (!(info = virHashNew(qemuMonitorChardevInfoFree)))
-        goto error;
+        return -1;
 
     if (qemuMonitorJSONGetChardevInfo(mon, info) < 0)
-        goto error;
+        return -1;
 
-    *retinfo = info;
+    *retinfo = g_steal_pointer(&info);
     return 0;
-
- error:
-    virHashFree(info);
-    *retinfo = NULL;
-    return -1;
 }