]> xenbits.xensource.com Git - libvirt.git/commitdiff
cpu_x86: Use g_auto* in virCPUx86GetHost
authorJiri Denemark <jdenemar@redhat.com>
Wed, 25 Mar 2020 09:33:48 +0000 (10:33 +0100)
committerJiri Denemark <jdenemar@redhat.com>
Wed, 8 Apr 2020 15:41:01 +0000 (17:41 +0200)
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/cpu/cpu_x86.c

index 3bb212a9097a298654313356339601eb298b3b3d..50fdc76326e2d1c3ba5d047c9144d7a18ec9d5a9 100644 (file)
@@ -2637,18 +2637,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
@@ -2668,7 +2668,7 @@ virCPUx86GetHost(virCPUDefPtr cpu,
             };
 
             if (virCPUx86DataAdd(cpuData, &item) < 0)
-                goto cleanup;
+                return -1;
         }
     }
 
@@ -2684,8 +2684,6 @@ virCPUx86GetHost(virCPUDefPtr cpu,
         VIR_DEBUG("Host CPU does not support invariant TSC");
     }
 
- cleanup:
-    virCPUx86DataFree(cpuData);
     return ret;
 }
 #endif