[PATCH 10/23] qemuRefreshVirtioChannelState: Automatically free GHashTable and refactor cleanup

Peter Krempa pkrempa at redhat.com
Tue Nov 30 14:31:54 UTC 2021


Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/qemu/qemu_process.c | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index c355a39e15..8dface7ec0 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -2245,25 +2245,19 @@ qemuRefreshVirtioChannelState(virQEMUDriver *driver,
                               qemuDomainAsyncJob asyncJob)
 {
     qemuDomainObjPrivate *priv = vm->privateData;
-    GHashTable *info = NULL;
-    int ret = -1;
+    g_autoptr(GHashTable) info = NULL;
+    int rc;

     if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
-        goto cleanup;
-
-    ret = qemuMonitorGetChardevInfo(priv->mon, &info);
-    if (qemuDomainObjExitMonitor(driver, vm) < 0)
-        ret = -1;
+        return -1;

-    if (ret < 0)
-        goto cleanup;
+    rc = qemuMonitorGetChardevInfo(priv->mon, &info);
+    if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0)
+        return -1;

     qemuProcessRefreshChannelVirtioState(driver, vm, info, false);
-    ret = 0;

- cleanup:
-    virHashFree(info);
-    return ret;
+    return 0;
 }


-- 
2.31.1




More information about the libvir-list mailing list