b971b8
From db7c7611aa3f80aca75e557795a12354f6fde82c Mon Sep 17 00:00:00 2001
b971b8
Message-Id: <db7c7611aa3f80aca75e557795a12354f6fde82c@dist-git>
b971b8
From: Jiri Denemark <jdenemar@redhat.com>
b971b8
Date: Tue, 26 May 2020 10:59:09 +0200
b971b8
Subject: [PATCH] cpu_x86: Use g_auto* in x86ModelFromCPU
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 93f173adbecee92f9973745a2aca65a27c4aa8a6)
b971b8
b971b8
https://bugzilla.redhat.com/show_bug.cgi?id=1840010
b971b8
b971b8
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
b971b8
Message-Id: <f205d9dfe07f4009faaeb702cf6be1726306747b.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 10c5fbacf7..5215405755 100644
b971b8
--- a/src/cpu/cpu_x86.c
b971b8
+++ b/src/cpu/cpu_x86.c
b971b8
@@ -1173,7 +1173,7 @@ x86ModelFromCPU(const virCPUDef *cpu,
b971b8
                 virCPUx86MapPtr map,
b971b8
                 int policy)
b971b8
 {
b971b8
-    virCPUx86ModelPtr model = NULL;
b971b8
+    g_autoptr(virCPUx86Model) model = NULL;
b971b8
     size_t i;
b971b8
 
b971b8
     /* host CPU only contains required features; requesting other features
b971b8
@@ -1216,7 +1216,7 @@ x86ModelFromCPU(const virCPUDef *cpu,
b971b8
         if (!(feature = x86FeatureFind(map, cpu->features[i].name))) {
b971b8
             virReportError(VIR_ERR_INTERNAL_ERROR,
b971b8
                            _("Unknown CPU feature %s"), cpu->features[i].name);
b971b8
-            goto error;
b971b8
+            return NULL;
b971b8
         }
b971b8
 
b971b8
         if (policy == -1) {
b971b8
@@ -1224,7 +1224,7 @@ x86ModelFromCPU(const virCPUDef *cpu,
b971b8
             case VIR_CPU_FEATURE_FORCE:
b971b8
             case VIR_CPU_FEATURE_REQUIRE:
b971b8
                 if (x86DataAdd(&model->data, &feature->data) < 0)
b971b8
-                    goto error;
b971b8
+                    return NULL;
b971b8
                 break;
b971b8
 
b971b8
             case VIR_CPU_FEATURE_DISABLE:
b971b8
@@ -1238,15 +1238,11 @@ x86ModelFromCPU(const virCPUDef *cpu,
b971b8
                 break;
b971b8
             }
b971b8
         } else if (x86DataAdd(&model->data, &feature->data) < 0) {
b971b8
-            goto error;
b971b8
+            return NULL;
b971b8
         }
b971b8
     }
b971b8
 
b971b8
-    return model;
b971b8
-
b971b8
- error:
b971b8
-    x86ModelFree(model);
b971b8
-    return NULL;
b971b8
+    return g_steal_pointer(&model);
b971b8
 }
b971b8
 
b971b8
 
b971b8
-- 
b971b8
2.26.2
b971b8