fbe740
From 2631931d1dc94aeab384d92bd00866de912c9b7d Mon Sep 17 00:00:00 2001
fbe740
Message-Id: <2631931d1dc94aeab384d92bd00866de912c9b7d@dist-git>
fbe740
From: Jiri Denemark <jdenemar@redhat.com>
fbe740
Date: Tue, 26 May 2020 10:59:22 +0200
fbe740
Subject: [PATCH] cpu_x86: Use g_auto* in virCPUx86Update
fbe740
MIME-Version: 1.0
fbe740
Content-Type: text/plain; charset=UTF-8
fbe740
Content-Transfer-Encoding: 8bit
fbe740
fbe740
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
fbe740
Reviewed-by: Ján Tomko <jtomko@redhat.com>
fbe740
(cherry picked from commit e0244a786db265647ab6c1c37ca3852876e4b0a3)
fbe740
fbe740
https://bugzilla.redhat.com/show_bug.cgi?id=1840010
fbe740
fbe740
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
fbe740
Message-Id: <1d8ad3e099081c35a41e1013458fa52d8fb4fae0.1590483392.git.jdenemar@redhat.com>
fbe740
Reviewed-by: Ján Tomko <jtomko@redhat.com>
fbe740
---
fbe740
 src/cpu/cpu_x86.c | 15 +++++----------
fbe740
 1 file changed, 5 insertions(+), 10 deletions(-)
fbe740
fbe740
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
fbe740
index 98f7863b6f..1f7a8802f6 100644
fbe740
--- a/src/cpu/cpu_x86.c
fbe740
+++ b/src/cpu/cpu_x86.c
fbe740
@@ -2853,9 +2853,8 @@ static int
fbe740
 virCPUx86Update(virCPUDefPtr guest,
fbe740
                 const virCPUDef *host)
fbe740
 {
fbe740
-    virCPUx86ModelPtr model = NULL;
fbe740
+    g_autoptr(virCPUx86Model) model = NULL;
fbe740
     virCPUx86MapPtr map;
fbe740
-    int ret = -1;
fbe740
     size_t i;
fbe740
 
fbe740
     if (!host) {
fbe740
@@ -2868,14 +2867,14 @@ virCPUx86Update(virCPUDefPtr guest,
fbe740
         return -1;
fbe740
 
fbe740
     if (!(model = x86ModelFromCPU(host, map, -1)))
fbe740
-        goto cleanup;
fbe740
+        return -1;
fbe740
 
fbe740
     for (i = 0; i < guest->nfeatures; i++) {
fbe740
         if (guest->features[i].policy == VIR_CPU_FEATURE_OPTIONAL) {
fbe740
             int supported = x86FeatureInData(guest->features[i].name,
fbe740
                                              &model->data, map);
fbe740
             if (supported < 0)
fbe740
-                goto cleanup;
fbe740
+                return -1;
fbe740
             else if (supported)
fbe740
                 guest->features[i].policy = VIR_CPU_FEATURE_REQUIRE;
fbe740
             else
fbe740
@@ -2885,13 +2884,9 @@ virCPUx86Update(virCPUDefPtr guest,
fbe740
 
fbe740
     if (guest->mode == VIR_CPU_MODE_HOST_MODEL ||
fbe740
         guest->match == VIR_CPU_MATCH_MINIMUM)
fbe740
-        ret = x86UpdateHostModel(guest, host);
fbe740
-    else
fbe740
-        ret = 0;
fbe740
+        return x86UpdateHostModel(guest, host);
fbe740
 
fbe740
- cleanup:
fbe740
-    x86ModelFree(model);
fbe740
-    return ret;
fbe740
+    return 0;
fbe740
 }
fbe740
 
fbe740
 
fbe740
-- 
fbe740
2.26.2
fbe740