From 20ddaa97976c1831bbfa969afd6ba56c0e159ba8 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Tue, 7 Dec 2021 17:22:26 +0100 Subject: [PATCH] virHostCPUHasValidSubcoreConfiguration: Refactor cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use automatic memory freeing for the temporary bitmap and remove the pointless 'cleanup' section. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- src/util/virhostcpu.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c index ad75eb5843..a8d8b34a39 100644 --- a/src/util/virhostcpu.c +++ b/src/util/virhostcpu.c @@ -450,31 +450,25 @@ virHostCPUParseNode(const char *node, static bool virHostCPUHasValidSubcoreConfiguration(int threads_per_subcore) { - virBitmap *online_cpus = NULL; + g_autoptr(virBitmap) online_cpus = NULL; int cpu = -1; - bool ret = false; /* No point in checking if subcores are not in use */ if (threads_per_subcore <= 0) - goto cleanup; + return false; if (!(online_cpus = virHostCPUGetOnlineBitmap())) - goto cleanup; + return false; while ((cpu = virBitmapNextSetBit(online_cpus, cpu)) >= 0) { /* A single online secondary thread is enough to * make the configuration invalid */ if (cpu % threads_per_subcore != 0) - goto cleanup; + return false; } - ret = true; - - cleanup: - virBitmapFree(online_cpus); - - return ret; + return true; }