render / rpms / libvirt

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