[libvirt PATCH 3/6] qemu: refactor virQEMUCapsInit

Ján Tomko jtomko at redhat.com
Mon Aug 23 14:37:10 UTC 2021


Use g_auto and remove pointless labels.

Signed-off-by: Ján Tomko <jtomko at redhat.com>
---
 src/qemu/qemu_capabilities.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index a80c172d71..380d0a5694 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -1111,13 +1111,13 @@ virQEMUCapsProbeHostCPU(virArch hostArch,
 virCaps *
 virQEMUCapsInit(virFileCache *cache)
 {
-    virCaps *caps;
+    g_autoptr(virCaps) caps = NULL;
     size_t i;
     virArch hostarch = virArchFromHost();
 
     if ((caps = virCapabilitiesNew(hostarch,
                                    true, true)) == NULL)
-        goto error;
+        return NULL;
 
     if (virCapabilitiesInitCaches(caps) < 0)
         VIR_WARN("Failed to get host CPU cache info");
@@ -1145,13 +1145,9 @@ virQEMUCapsInit(virFileCache *cache)
         if (virQEMUCapsInitGuest(caps, cache,
                                  hostarch,
                                  i) < 0)
-            goto error;
+            return NULL;
 
-    return caps;
-
- error:
-    virObjectUnref(caps);
-    return NULL;
+    return g_steal_pointer(&caps);
 }
 
 
-- 
2.31.1




More information about the libvir-list mailing list