]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virHostCPUHasValidSubcoreConfiguration: Refactor cleanup
authorPeter Krempa <pkrempa@redhat.com>
Tue, 7 Dec 2021 16:22:26 +0000 (17:22 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 10 Dec 2021 15:36:24 +0000 (16:36 +0100)
Use automatic memory freeing for the temporary bitmap and remove the
pointless 'cleanup' section.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/util/virhostcpu.c

index ad75eb5843627c8742dc337f228fa3b01159e237..a8d8b34a39a44a93a0749d1207e092cede17f9d9 100644 (file)
@@ -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;
 }