From: Jiri Denemark Date: Wed, 25 Mar 2020 09:33:48 +0000 (+0100) Subject: cpu_x86: Use g_auto* in virCPUx86GetHost X-Git-Tag: v6.3.0-rc1~187 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4a7f6f43a2a6144780d7ab74b8a6f6b008a7aa9d;p=thirdparty%2Flibvirt.git cpu_x86: Use g_auto* in virCPUx86GetHost Signed-off-by: Jiri Denemark Reviewed-by: Ján Tomko --- diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 3bb212a909..50fdc76326 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -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