render / rpms / libvirt

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