[libvirt PATCH 08/39] cpu_x86: Use g_auto* in x86DataToCPU

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
---
 src/cpu/cpu_x86.c | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index fce7a2b8c5..d0ef66f1e3 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -771,9 +771,9 @@ x86DataToCPU(const virCPUx86Data *data,
              virCPUx86MapPtr map,
              virDomainCapsCPUModelPtr hvModel)
 {
-    virCPUDefPtr cpu;
-    virCPUx86Data copy = VIR_CPU_X86_DATA_INIT;
-    virCPUx86Data modelData = VIR_CPU_X86_DATA_INIT;
+    g_autoptr(virCPUDef) cpu = NULL;
+    g_auto(virCPUx86Data) copy = VIR_CPU_X86_DATA_INIT;
+    g_auto(virCPUx86Data) modelData = VIR_CPU_X86_DATA_INIT;
     virCPUx86VendorPtr vendor;
 
     cpu = virCPUDefNew();
@@ -801,7 +801,7 @@ x86DataToCPU(const virCPUx86Data *data,
             if ((feature = x86FeatureFind(map, *blocker)) &&
                 !x86DataIsSubset(&copy, &feature->data))
                 if (x86DataAdd(&modelData, &feature->data) < 0)
-                    goto error;
+                    return NULL;
         }
     }
 
@@ -810,17 +810,9 @@ x86DataToCPU(const virCPUx86Data *data,
 
     if (x86DataToCPUFeatures(cpu, VIR_CPU_FEATURE_REQUIRE, &copy, map) ||
         x86DataToCPUFeatures(cpu, VIR_CPU_FEATURE_DISABLE, &modelData, map))
-        goto error;
-
- cleanup:
-    virCPUx86DataClear(&modelData);
-    virCPUx86DataClear(&copy);
-    return cpu;
+        return NULL;
 
- error:
-    virCPUDefFree(cpu);
-    cpu = NULL;
-    goto cleanup;
+    return g_steal_pointer(&cpu);
 }
 
 
-- 
2.26.0





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux