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

[libvirt PATCH 05/15] cpu: Use g_auto* in virCPUGetHost



Signed-off-by: Tim Wiederhake <twiederh redhat com>
---
 src/cpu/cpu.c | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c
index a84eb10cc4..69e4205e4b 100644
--- a/src/cpu/cpu.c
+++ b/src/cpu/cpu.c
@@ -378,7 +378,7 @@ virCPUGetHost(virArch arch,
               virDomainCapsCPUModelsPtr models)
 {
     struct cpuArchDriver *driver;
-    virCPUDefPtr cpu = NULL;
+    g_autoptr(virCPUDef) cpu = NULL;
 
     VIR_DEBUG("arch=%s, type=%s, nodeInfo=%p, models=%p",
               virArchToString(arch), virCPUTypeToString(type), nodeInfo,
@@ -400,7 +400,7 @@ virCPUGetHost(virArch arch,
             virReportError(VIR_ERR_INVALID_ARG,
                            _("cannot set topology for CPU type '%s'"),
                            virCPUTypeToString(type));
-            goto error;
+            return NULL;
         }
         cpu->type = type;
         break;
@@ -410,7 +410,7 @@ virCPUGetHost(virArch arch,
         virReportError(VIR_ERR_INVALID_ARG,
                        _("unsupported CPU type: %s"),
                        virCPUTypeToString(type));
-        goto error;
+        return NULL;
     }
 
     if (nodeInfo) {
@@ -424,9 +424,8 @@ virCPUGetHost(virArch arch,
      * filled in.
      */
     if (driver->getHost) {
-        if (driver->getHost(cpu, models) < 0 &&
-            !nodeInfo)
-            goto error;
+        if (driver->getHost(cpu, models) < 0 && !nodeInfo)
+            return NULL;
     } else if (nodeInfo) {
         VIR_DEBUG("cannot detect host CPU model for %s architecture",
                   virArchToString(arch));
@@ -434,14 +433,10 @@ virCPUGetHost(virArch arch,
         virReportError(VIR_ERR_NO_SUPPORT,
                        _("cannot detect host CPU model for %s architecture"),
                        virArchToString(arch));
-        goto error;
+        return NULL;
     }
 
-    return cpu;
-
- error:
-    virCPUDefFree(cpu);
-    return NULL;
+    return g_steal_pointer(&cpu);
 }
 
 
-- 
2.26.2


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