b971b8
From 2545e373c4a5b08836742742960244ece2586545 Mon Sep 17 00:00:00 2001
b971b8
Message-Id: <2545e373c4a5b08836742742960244ece2586545@dist-git>
b971b8
From: Jiri Denemark <jdenemar@redhat.com>
b971b8
Date: Tue, 26 May 2020 10:59:21 +0200
b971b8
Subject: [PATCH] cpu_x86: Use g_auto* in x86UpdateHostModel
b971b8
MIME-Version: 1.0
b971b8
Content-Type: text/plain; charset=UTF-8
b971b8
Content-Transfer-Encoding: 8bit
b971b8
b971b8
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
b971b8
Reviewed-by: Ján Tomko <jtomko@redhat.com>
b971b8
(cherry picked from commit 2f9d15b495efdd9e63c07cd6fda611701e71ee46)
b971b8
b971b8
https://bugzilla.redhat.com/show_bug.cgi?id=1840010
b971b8
b971b8
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
b971b8
Message-Id: <f39c8eb1774d8c9af13a8af47689f8759ce57cb3.1590483392.git.jdenemar@redhat.com>
b971b8
Reviewed-by: Ján Tomko <jtomko@redhat.com>
b971b8
---
b971b8
 src/cpu/cpu_x86.c | 14 +++++---------
b971b8
 1 file changed, 5 insertions(+), 9 deletions(-)
b971b8
b971b8
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
b971b8
index 6e7311694d..98f7863b6f 100644
b971b8
--- a/src/cpu/cpu_x86.c
b971b8
+++ b/src/cpu/cpu_x86.c
b971b8
@@ -2817,17 +2817,16 @@ static int
b971b8
 x86UpdateHostModel(virCPUDefPtr guest,
b971b8
                    const virCPUDef *host)
b971b8
 {
b971b8
-    virCPUDefPtr updated = NULL;
b971b8
+    g_autoptr(virCPUDef) updated = NULL;
b971b8
     size_t i;
b971b8
-    int ret = -1;
b971b8
 
b971b8
     if (!(updated = virCPUDefCopyWithoutModel(host)))
b971b8
-        goto cleanup;
b971b8
+        return -1;
b971b8
 
b971b8
     updated->type = VIR_CPU_TYPE_GUEST;
b971b8
     updated->mode = VIR_CPU_MODE_CUSTOM;
b971b8
     if (virCPUDefCopyModel(updated, host, true) < 0)
b971b8
-        goto cleanup;
b971b8
+        return -1;
b971b8
 
b971b8
     if (guest->vendor_id) {
b971b8
         VIR_FREE(updated->vendor_id);
b971b8
@@ -2838,18 +2837,15 @@ x86UpdateHostModel(virCPUDefPtr guest,
b971b8
         if (virCPUDefUpdateFeature(updated,
b971b8
                                    guest->features[i].name,
b971b8
                                    guest->features[i].policy) < 0)
b971b8
-            goto cleanup;
b971b8
+            return -1;
b971b8
     }
b971b8
 
b971b8
     virCPUDefStealModel(guest, updated,
b971b8
                         guest->mode == VIR_CPU_MODE_CUSTOM);
b971b8
     guest->mode = VIR_CPU_MODE_CUSTOM;
b971b8
     guest->match = VIR_CPU_MATCH_EXACT;
b971b8
-    ret = 0;
b971b8
 
b971b8
- cleanup:
b971b8
-    virCPUDefFree(updated);
b971b8
-    return ret;
b971b8
+    return 0;
b971b8
 }
b971b8
 
b971b8
 
b971b8
-- 
b971b8
2.26.2
b971b8