[PATCH 2/5] qemu_process.c: modernize qemuProcessQMPNew()

Daniel Henrique Barboza danielhb413 at gmail.com
Fri Jul 17 21:15:53 UTC 2020


Use g_autoptr() and remove the 'cleanup' label.

Signed-off-by: Daniel Henrique Barboza <danielhb413 at gmail.com>
---
 src/qemu/qemu_process.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 70fc24b993..a11eedda16 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -8395,8 +8395,7 @@ qemuProcessQMPNew(const char *binary,
                   gid_t runGid,
                   bool forceTCG)
 {
-    qemuProcessQMPPtr ret = NULL;
-    qemuProcessQMPPtr proc = NULL;
+    g_autoptr(qemuProcessQMP) proc = NULL;
     const char *threadSuffix;
     g_autofree char *threadName = NULL;
 
@@ -8404,7 +8403,7 @@ qemuProcessQMPNew(const char *binary,
               binary, libDir, runUid, runGid, forceTCG);
 
     if (VIR_ALLOC(proc) < 0)
-        goto cleanup;
+        return NULL;
 
     proc->binary = g_strdup(binary);
     proc->libDir = g_strdup(libDir);
@@ -8421,13 +8420,9 @@ qemuProcessQMPNew(const char *binary,
     threadName = g_strdup_printf("qmp-%s", threadSuffix);
 
     if (!(proc->eventThread = virEventThreadNew(threadName)))
-        goto cleanup;
-
-    ret = g_steal_pointer(&proc);
+        return NULL;
 
- cleanup:
-    qemuProcessQMPFree(proc);
-    return ret;
+    return g_steal_pointer(&proc);
 }
 
 
-- 
2.26.2




More information about the libvir-list mailing list