[libvirt PATCH 13/39] cpu_x86: Use g_auto* in virCPUx86LoadMap

Jiri Denemark jdenemar at redhat.com
Fri Mar 27 13:43:42 UTC 2020


Signed-off-by: Jiri Denemark <jdenemar at redhat.com>
---
 src/cpu/cpu_x86.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index fc94c029e4..ba269df66d 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -1559,18 +1559,14 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(virCPUx86Map, x86MapFree);
 static virCPUx86MapPtr
 virCPUx86LoadMap(void)
 {
-    virCPUx86MapPtr map;
+    g_autoptr(virCPUx86Map) map = NULL;
 
     map = g_new0(virCPUx86Map, 1);
 
     if (cpuMapLoad("x86", x86VendorParse, x86FeatureParse, x86ModelParse, map) < 0)
-        goto error;
-
-    return map;
+        return NULL;
 
- error:
-    x86MapFree(map);
-    return NULL;
+    return g_steal_pointer(&map);
 }
 
 
-- 
2.26.0




More information about the libvir-list mailing list