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