]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virnumamock: Use automatic memory freeing for virBitmap
authorPeter Krempa <pkrempa@redhat.com>
Mon, 6 Dec 2021 13:10:40 +0000 (14:10 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 10 Dec 2021 15:36:24 +0000 (16:36 +0100)
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
tests/virnumamock.c

index 19c26d1e375f0aed0e3231f84d72972b7d803e4b..7f2653cb53d7cfa28d7a6b565af90db689339858 100644 (file)
@@ -63,29 +63,23 @@ virNumaIsAvailable(void)
 int
 virNumaGetMaxNode(void)
 {
-    int ret = -1;
-    virBitmap *map = NULL;
+    g_autoptr(virBitmap) map = NULL;
 
     if (virFileReadValueBitmap(&map, "%s/node/online", SYSFS_SYSTEM_PATH) < 0)
         return -1;
 
-    ret = virBitmapLastSetBit(map);
-    virBitmapFree(map);
-    return ret;
+    return virBitmapLastSetBit(map);
 }
 
 bool
 virNumaNodeIsAvailable(int node)
 {
-    bool ret = false;
-    virBitmap *map = NULL;
+    g_autoptr(virBitmap) map = NULL;
 
     if (virFileReadValueBitmap(&map, "%s/node/online", SYSFS_SYSTEM_PATH) < 0)
         return false;
 
-    ret = virBitmapIsBitSet(map, node);
-    virBitmapFree(map);
-    return ret;
+    return virBitmapIsBitSet(map, node);
 }
 
 int