render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
a41c76
From 5f9b035adcf2813beb6cc82200b745f5e34acd8d Mon Sep 17 00:00:00 2001
a41c76
Message-Id: <5f9b035adcf2813beb6cc82200b745f5e34acd8d@dist-git>
a41c76
From: Jiri Denemark <jdenemar@redhat.com>
a41c76
Date: Tue, 26 May 2020 10:59:25 +0200
a41c76
Subject: [PATCH] cpu_x86: Use g_auto* in virCPUx86ExpandFeatures
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 ff6897c84504a3e663759d710968ad1f72bc9208)
a41c76
a41c76
https://bugzilla.redhat.com/show_bug.cgi?id=1840010
a41c76
a41c76
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
a41c76
Message-Id: <d82daa166403fda2bcd89c68478162b45d8b9711.1590483392.git.jdenemar@redhat.com>
a41c76
Reviewed-by: Ján Tomko <jtomko@redhat.com>
a41c76
---
a41c76
 src/cpu/cpu_x86.c | 22 ++++++++--------------
a41c76
 1 file changed, 8 insertions(+), 14 deletions(-)
a41c76
a41c76
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
a41c76
index c4654c8d4c..917cf857a6 100644
a41c76
--- a/src/cpu/cpu_x86.c
a41c76
+++ b/src/cpu/cpu_x86.c
a41c76
@@ -3055,30 +3055,29 @@ static int
a41c76
 virCPUx86ExpandFeatures(virCPUDefPtr cpu)
a41c76
 {
a41c76
     virCPUx86MapPtr map;
a41c76
-    virCPUDefPtr expanded = NULL;
a41c76
-    virCPUx86ModelPtr model = NULL;
a41c76
+    g_autoptr(virCPUDef) expanded = NULL;
a41c76
+    g_autoptr(virCPUx86Model) model = NULL;
a41c76
     bool host = cpu->type == VIR_CPU_TYPE_HOST;
a41c76
     size_t i;
a41c76
-    int ret = -1;
a41c76
 
a41c76
     if (!(map = virCPUx86GetMap()))
a41c76
-        goto cleanup;
a41c76
+        return -1;
a41c76
 
a41c76
     if (!(expanded = virCPUDefCopy(cpu)))
a41c76
-        goto cleanup;
a41c76
+        return -1;
a41c76
 
a41c76
     virCPUDefFreeFeatures(expanded);
a41c76
 
a41c76
     if (!(model = x86ModelFind(map, cpu->model))) {
a41c76
         virReportError(VIR_ERR_INTERNAL_ERROR,
a41c76
                        _("unknown CPU model %s"), cpu->model);
a41c76
-        goto cleanup;
a41c76
+        return -1;
a41c76
     }
a41c76
 
a41c76
     if (!(model = x86ModelCopy(model)) ||
a41c76
         x86DataToCPUFeatures(expanded, host ? -1 : VIR_CPU_FEATURE_REQUIRE,
a41c76
                              &model->data, map) < 0)
a41c76
-        goto cleanup;
a41c76
+        return -1;
a41c76
 
a41c76
     for (i = 0; i < cpu->nfeatures; i++) {
a41c76
         virCPUFeatureDefPtr f = cpu->features + i;
a41c76
@@ -3089,17 +3088,12 @@ virCPUx86ExpandFeatures(virCPUDefPtr cpu)
a41c76
             continue;
a41c76
 
a41c76
         if (virCPUDefUpdateFeature(expanded, f->name, f->policy) < 0)
a41c76
-            goto cleanup;
a41c76
+            return -1;
a41c76
     }
a41c76
 
a41c76
     virCPUDefFreeModel(cpu);
a41c76
 
a41c76
-    ret = virCPUDefCopyModel(cpu, expanded, false);
a41c76
-
a41c76
- cleanup:
a41c76
-    virCPUDefFree(expanded);
a41c76
-    x86ModelFree(model);
a41c76
-    return ret;
a41c76
+    return virCPUDefCopyModel(cpu, expanded, false);
a41c76
 }
a41c76
 
a41c76
 
a41c76
-- 
a41c76
2.26.2
a41c76