render / rpms / libvirt

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