render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
a41c76
From e9b93240af4c391414b301c7a4a20837bc09b109 Mon Sep 17 00:00:00 2001
a41c76
Message-Id: <e9b93240af4c391414b301c7a4a20837bc09b109@dist-git>
a41c76
From: Jiri Denemark <jdenemar@redhat.com>
a41c76
Date: Tue, 26 May 2020 10:59:15 +0200
a41c76
Subject: [PATCH] cpu_x86: Use g_auto* in x86Decode
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 9bb9cbf6761ecf985fe9cf8a18030a8aff9b448b)
a41c76
a41c76
https://bugzilla.redhat.com/show_bug.cgi?id=1840010
a41c76
a41c76
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
a41c76
Message-Id: <1414d86a79eb63d5600cf494455411814cbf10f7.1590483392.git.jdenemar@redhat.com>
a41c76
Reviewed-by: Ján Tomko <jtomko@redhat.com>
a41c76
---
a41c76
 src/cpu/cpu_x86.c | 24 +++++++-----------------
a41c76
 1 file changed, 7 insertions(+), 17 deletions(-)
a41c76
a41c76
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
a41c76
index c111ff45d4..dba4165527 100644
a41c76
--- a/src/cpu/cpu_x86.c
a41c76
+++ b/src/cpu/cpu_x86.c
a41c76
@@ -2032,15 +2032,12 @@ x86Decode(virCPUDefPtr cpu,
a41c76
           const char *preferred,
a41c76
           bool migratable)
a41c76
 {
a41c76
-    int ret = -1;
a41c76
     virCPUx86MapPtr map;
a41c76
     virCPUx86ModelPtr candidate;
a41c76
     virCPUDefPtr cpuCandidate;
a41c76
     virCPUx86ModelPtr model = NULL;
a41c76
-    virCPUDefPtr cpuModel = NULL;
a41c76
-    virCPUx86Data data = VIR_CPU_X86_DATA_INIT;
a41c76
-    virCPUx86Data copy = VIR_CPU_X86_DATA_INIT;
a41c76
-    virCPUx86Data features = VIR_CPU_X86_DATA_INIT;
a41c76
+    g_autoptr(virCPUDef) cpuModel = NULL;
a41c76
+    g_auto(virCPUx86Data) data = VIR_CPU_X86_DATA_INIT;
a41c76
     virCPUx86VendorPtr vendor;
a41c76
     virDomainCapsCPUModelPtr hvModel = NULL;
a41c76
     g_autofree char *sigs = NULL;
a41c76
@@ -2054,7 +2051,7 @@ x86Decode(virCPUDefPtr cpu,
a41c76
     x86DataCopy(&data, cpuData);
a41c76
 
a41c76
     if (!(map = virCPUx86GetMap()))
a41c76
-        goto cleanup;
a41c76
+        return -1;
a41c76
 
a41c76
     vendor = x86DataToVendor(&data, map);
a41c76
     signature = x86DataToSignature(&data);
a41c76
@@ -2073,7 +2070,7 @@ x86Decode(virCPUDefPtr cpu,
a41c76
                     virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
a41c76
                                    _("CPU model %s is not supported by hypervisor"),
a41c76
                                    preferred);
a41c76
-                    goto cleanup;
a41c76
+                    return -1;
a41c76
                 } else {
a41c76
                     VIR_WARN("Preferred CPU model %s not allowed by"
a41c76
                              " hypervisor; closest supported model will be"
a41c76
@@ -2096,7 +2093,7 @@ x86Decode(virCPUDefPtr cpu,
a41c76
         }
a41c76
 
a41c76
         if (!(cpuCandidate = x86DataToCPU(&data, candidate, map, hvModel)))
a41c76
-            goto cleanup;
a41c76
+            return -1;
a41c76
         cpuCandidate->type = cpu->type;
a41c76
 
a41c76
         if ((rc = x86DecodeUseCandidate(model, cpuModel,
a41c76
@@ -2115,7 +2112,7 @@ x86Decode(virCPUDefPtr cpu,
a41c76
     if (!cpuModel) {
a41c76
         virReportError(VIR_ERR_INTERNAL_ERROR,
a41c76
                        "%s", _("Cannot find suitable CPU model for given data"));
a41c76
-        goto cleanup;
a41c76
+        return -1;
a41c76
     }
a41c76
 
a41c76
     /* Remove non-migratable features if requested
a41c76
@@ -2149,14 +2146,7 @@ x86Decode(virCPUDefPtr cpu,
a41c76
     cpu->nfeatures_max = cpuModel->nfeatures_max;
a41c76
     cpuModel->nfeatures_max = 0;
a41c76
 
a41c76
-    ret = 0;
a41c76
-
a41c76
- cleanup:
a41c76
-    virCPUDefFree(cpuModel);
a41c76
-    virCPUx86DataClear(&data);
a41c76
-    virCPUx86DataClear(©);
a41c76
-    virCPUx86DataClear(&features);
a41c76
-    return ret;
a41c76
+    return 0;
a41c76
 }
a41c76
 
a41c76
 static int
a41c76
-- 
a41c76
2.26.2
a41c76