a41c76
From caedf791f3486b5b3ed1ef54e9c25e7c97b3a39a Mon Sep 17 00:00:00 2001
a41c76
Message-Id: <caedf791f3486b5b3ed1ef54e9c25e7c97b3a39a@dist-git>
a41c76
From: Jiri Denemark <jdenemar@redhat.com>
a41c76
Date: Tue, 26 May 2020 10:59:06 +0200
a41c76
Subject: [PATCH] cpu_x86: Use g_auto* in x86DataToCPU
a41c76
MIME-Version: 1.0
a41c76
Content-Type: text/plain; charset=UTF-8
a41c76
Content-Transfer-Encoding: 8bit
a41c76
a41c76
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
a41c76
Reviewed-by: Ján Tomko <jtomko@redhat.com>
a41c76
(cherry picked from commit 4f2fdad36db2da1aa139470846b3f60f65da8424)
a41c76
a41c76
https://bugzilla.redhat.com/show_bug.cgi?id=1840010
a41c76
a41c76
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
a41c76
Message-Id: <6f88b9d54c70352f9e4aeadd515cd9f4a599545a.1590483392.git.jdenemar@redhat.com>
a41c76
Reviewed-by: Ján Tomko <jtomko@redhat.com>
a41c76
---
a41c76
 src/cpu/cpu_x86.c | 20 ++++++--------------
a41c76
 1 file changed, 6 insertions(+), 14 deletions(-)
a41c76
a41c76
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
a41c76
index 48f36c2bfc..310dfcbcb3 100644
a41c76
--- a/src/cpu/cpu_x86.c
a41c76
+++ b/src/cpu/cpu_x86.c
a41c76
@@ -771,9 +771,9 @@ x86DataToCPU(const virCPUx86Data *data,
a41c76
              virCPUx86MapPtr map,
a41c76
              virDomainCapsCPUModelPtr hvModel)
a41c76
 {
a41c76
-    virCPUDefPtr cpu;
a41c76
-    virCPUx86Data copy = VIR_CPU_X86_DATA_INIT;
a41c76
-    virCPUx86Data modelData = VIR_CPU_X86_DATA_INIT;
a41c76
+    g_autoptr(virCPUDef) cpu = NULL;
a41c76
+    g_auto(virCPUx86Data) copy = VIR_CPU_X86_DATA_INIT;
a41c76
+    g_auto(virCPUx86Data) modelData = VIR_CPU_X86_DATA_INIT;
a41c76
     virCPUx86VendorPtr vendor;
a41c76
 
a41c76
     cpu = virCPUDefNew();
a41c76
@@ -801,7 +801,7 @@ x86DataToCPU(const virCPUx86Data *data,
a41c76
             if ((feature = x86FeatureFind(map, *blocker)) &&
a41c76
                 !x86DataIsSubset(&copy, &feature->data))
a41c76
                 if (x86DataAdd(&modelData, &feature->data) < 0)
a41c76
-                    goto error;
a41c76
+                    return NULL;
a41c76
         }
a41c76
     }
a41c76
 
a41c76
@@ -810,17 +810,9 @@ x86DataToCPU(const virCPUx86Data *data,
a41c76
 
a41c76
     if (x86DataToCPUFeatures(cpu, VIR_CPU_FEATURE_REQUIRE, &copy, map) ||
a41c76
         x86DataToCPUFeatures(cpu, VIR_CPU_FEATURE_DISABLE, &modelData, map))
a41c76
-        goto error;
a41c76
-
a41c76
- cleanup:
a41c76
-    virCPUx86DataClear(&modelData);
a41c76
-    virCPUx86DataClear(©);
a41c76
-    return cpu;
a41c76
+        return NULL;
a41c76
 
a41c76
- error:
a41c76
-    virCPUDefFree(cpu);
a41c76
-    cpu = NULL;
a41c76
-    goto cleanup;
a41c76
+    return g_steal_pointer(&cpu);
a41c76
 }
a41c76
 
a41c76
 
a41c76
-- 
a41c76
2.26.2
a41c76