[libvirt PATCH 23/39] cpu_x86: Use g_auto* in x86UpdateHostModel

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


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

diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index ccbae3dabd..9f6027ec5c 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -2821,17 +2821,16 @@ static int
 x86UpdateHostModel(virCPUDefPtr guest,
                    const virCPUDef *host)
 {
-    virCPUDefPtr updated = NULL;
+    g_autoptr(virCPUDef) updated = NULL;
     size_t i;
-    int ret = -1;
 
     if (!(updated = virCPUDefCopyWithoutModel(host)))
-        goto cleanup;
+        return -1;
 
     updated->type = VIR_CPU_TYPE_GUEST;
     updated->mode = VIR_CPU_MODE_CUSTOM;
     if (virCPUDefCopyModel(updated, host, true) < 0)
-        goto cleanup;
+        return -1;
 
     if (guest->vendor_id) {
         VIR_FREE(updated->vendor_id);
@@ -2842,18 +2841,15 @@ x86UpdateHostModel(virCPUDefPtr guest,
         if (virCPUDefUpdateFeature(updated,
                                    guest->features[i].name,
                                    guest->features[i].policy) < 0)
-            goto cleanup;
+            return -1;
     }
 
     virCPUDefStealModel(guest, updated,
                         guest->mode == VIR_CPU_MODE_CUSTOM);
     guest->mode = VIR_CPU_MODE_CUSTOM;
     guest->match = VIR_CPU_MATCH_EXACT;
-    ret = 0;
 
- cleanup:
-    virCPUDefFree(updated);
-    return ret;
+    return 0;
 }
 
 
-- 
2.26.0




More information about the libvir-list mailing list