[PATCH 13/36] virHostCPUCountThreadSiblings: Refactor cleanup

Peter Krempa pkrempa at redhat.com
Thu Dec 9 12:18:18 UTC 2021


Use automatic memory freeing for the temporary bitmap and remove the
pointless 'cleanup' section.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/util/virhostcpu.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c
index 67b6910626..ad75eb5843 100644
--- a/src/util/virhostcpu.c
+++ b/src/util/virhostcpu.c
@@ -271,17 +271,12 @@ virHostCPUGetSiblingsList(unsigned int cpu)
 static unsigned long
 virHostCPUCountThreadSiblings(unsigned int cpu)
 {
-    virBitmap *siblings_map;
-    unsigned long ret = 0;
+    g_autoptr(virBitmap) siblings_map = NULL;

     if (!(siblings_map = virHostCPUGetSiblingsList(cpu)))
-        goto cleanup;
-
-    ret = virBitmapCountBits(siblings_map);
+        return 0;

- cleanup:
-    virBitmapFree(siblings_map);
-    return ret;
+    return virBitmapCountBits(siblings_map);
 }

 /* parses a node entry, returning number of processors in the node and
-- 
2.31.1




More information about the libvir-list mailing list