libvirt/SOURCES/libvirt-cpu_x86-Use-g_auto-in-virCPUx86GetHost.patch
2021-09-10 11:57:33 +00:00

72 lines
2.1 KiB
Diff

From 0b64dac1a3a9ef9cdfe3446ebbe114da1ae86e97 Mon Sep 17 00:00:00 2001
Message-Id: <0b64dac1a3a9ef9cdfe3446ebbe114da1ae86e97@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Tue, 26 May 2020 10:59:19 +0200
Subject: [PATCH] cpu_x86: Use g_auto* in virCPUx86GetHost
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 4a7f6f43a2a6144780d7ab74b8a6f6b008a7aa9d)
https://bugzilla.redhat.com/show_bug.cgi?id=1840010
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <94056710375d491c42d12a46b20f670453c2a1c8.1590483392.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@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 0aebe534e6..1ade53a4a8 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
--
2.26.2