]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: refactor virQEMUCapsInit
authorJán Tomko <jtomko@redhat.com>
Mon, 23 Aug 2021 14:23:47 +0000 (16:23 +0200)
committerJán Tomko <jtomko@redhat.com>
Mon, 23 Aug 2021 15:35:06 +0000 (17:35 +0200)
Use g_auto and remove pointless labels.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
src/qemu/qemu_capabilities.c

index a80c172d71cdffa605b100e23c1258b857916dc1..380d0a56943bcd06d58dd284754bab4f8d7546a6 100644 (file)
@@ -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 caps;
+            return NULL;
 
- error:
-    virObjectUnref(caps);
-    return NULL;
+    return g_steal_pointer(&caps);
 }