Blob Blame History Raw
From db7c7611aa3f80aca75e557795a12354f6fde82c Mon Sep 17 00:00:00 2001
Message-Id: <db7c7611aa3f80aca75e557795a12354f6fde82c@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Tue, 26 May 2020 10:59:09 +0200
Subject: [PATCH] cpu_x86: Use g_auto* in x86ModelFromCPU
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 93f173adbecee92f9973745a2aca65a27c4aa8a6)

https://bugzilla.redhat.com/show_bug.cgi?id=1840010

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <f205d9dfe07f4009faaeb702cf6be1726306747b.1590483392.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@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 10c5fbacf7..5215405755 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -1173,7 +1173,7 @@ x86ModelFromCPU(const virCPUDef *cpu,
                 virCPUx86MapPtr map,
                 int policy)
 {
-    virCPUx86ModelPtr model = NULL;
+    g_autoptr(virCPUx86Model) model = NULL;
     size_t i;
 
     /* host CPU only contains required features; requesting other features
@@ -1216,7 +1216,7 @@ x86ModelFromCPU(const virCPUDef *cpu,
         if (!(feature = x86FeatureFind(map, cpu->features[i].name))) {
             virReportError(VIR_ERR_INTERNAL_ERROR,
                            _("Unknown CPU feature %s"), cpu->features[i].name);
-            goto error;
+            return NULL;
         }
 
         if (policy == -1) {
@@ -1224,7 +1224,7 @@ x86ModelFromCPU(const virCPUDef *cpu,
             case VIR_CPU_FEATURE_FORCE:
             case VIR_CPU_FEATURE_REQUIRE:
                 if (x86DataAdd(&model->data, &feature->data) < 0)
-                    goto error;
+                    return NULL;
                 break;
 
             case VIR_CPU_FEATURE_DISABLE:
@@ -1238,15 +1238,11 @@ x86ModelFromCPU(const virCPUDef *cpu,
                 break;
             }
         } else if (x86DataAdd(&model->data, &feature->data) < 0) {
-            goto error;
+            return NULL;
         }
     }
 
-    return model;
-
- error:
-    x86ModelFree(model);
-    return NULL;
+    return g_steal_pointer(&model);
 }
 
 
-- 
2.26.2