[libvirt PATCH 21/39] cpu_x86: Use g_auto* in virCPUx86GetHost

Jiri Denemark posted 39 patches 5 years, 10 months ago
[libvirt PATCH 21/39] cpu_x86: Use g_auto* in virCPUx86GetHost
Posted by Jiri Denemark 5 years, 10 months ago
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 src/cpu/cpu_x86.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 3b3a428ecd..7bd19a1676 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -2641,18 +2641,18 @@ static int
 virCPUx86GetHost(virCPUDefPtr cpu,
                  virDomainCapsCPUModelsPtr models)
 {
-    virCPUDataPtr cpuData = NULL;
-    int ret = -1;
+    g_autoptr(virCPUData) cpuData = NULL;
+    int ret;
 
     if (virCPUx86DriverInitialize() < 0)
-        goto cleanup;
+        return -1;
 
     if (!(cpuData = virCPUDataNew(archs[0])))
-        goto cleanup;
+        return -1;
 
     if (cpuidSet(CPUX86_BASIC, cpuData) < 0 ||
         cpuidSet(CPUX86_EXTENDED, cpuData) < 0)
-        goto cleanup;
+        return -1;
 
     /* Read the IA32_ARCH_CAPABILITIES MSR (0x10a) if supported.
      * This is best effort since there might be no way to read the MSR
@@ -2672,7 +2672,7 @@ virCPUx86GetHost(virCPUDefPtr cpu,
             };
 
             if (virCPUx86DataAdd(cpuData, &item) < 0)
-                goto cleanup;
+                return -1;
         }
     }
 
@@ -2688,8 +2688,6 @@ virCPUx86GetHost(virCPUDefPtr cpu,
         VIR_DEBUG("Host CPU does not support invariant TSC");
     }
 
- cleanup:
-    virCPUx86DataFree(cpuData);
     return ret;
 }
 #endif
-- 
2.26.0

Re: [libvirt PATCH 21/39] cpu_x86: Use g_auto* in virCPUx86GetHost
Posted by Ján Tomko 5 years, 10 months ago
On a Friday in 2020, Jiri Denemark wrote:
>Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
>---
> src/cpu/cpu_x86.c | 14 ++++++--------
> 1 file changed, 6 insertions(+), 8 deletions(-)
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano