render / rpms / libvirt

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