From: Peter Krempa Date: Tue, 7 Dec 2021 16:22:26 +0000 (+0100) Subject: virHostCPUHasValidSubcoreConfiguration: Refactor cleanup X-Git-Tag: v8.0.0-rc1~315 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=20ddaa97976c1831bbfa969afd6ba56c0e159ba8;p=thirdparty%2Flibvirt.git virHostCPUHasValidSubcoreConfiguration: Refactor cleanup Use automatic memory freeing for the temporary bitmap and remove the pointless 'cleanup' section. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- 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; }