From e34270519e3da1c2b28d6c52fe2037e7c24d89ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Cab=C3=A9?= Date: Tue, 18 Mar 2025 06:46:35 +0100 Subject: [PATCH] tests: kernel: adopt new count_bits util function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adopt new count_bits helper from util.h and avoid having conflicting definition Signed-off-by: Benjamin Cabé --- tests/kernel/common/src/bitarray.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/tests/kernel/common/src/bitarray.c b/tests/kernel/common/src/bitarray.c index a7a7be02a01..5847f57027a 100644 --- a/tests/kernel/common/src/bitarray.c +++ b/tests/kernel/common/src/bitarray.c @@ -355,29 +355,13 @@ void alloc_and_free_predefined(void) "sys_bitarray_alloc() failed bits comparison"); } -static inline size_t count_bits(uint32_t val) -{ - /* Implements Brian Kernighan’s Algorithm - * to count bits. - */ - - size_t cnt = 0; - - while (val != 0) { - val = val & (val - 1); - cnt++; - } - - return cnt; -} - size_t get_bitarray_popcnt(sys_bitarray_t *ba) { size_t popcnt = 0; unsigned int idx; for (idx = 0; idx < ba->num_bundles; idx++) { - popcnt += count_bits(ba->bundles[idx]); + popcnt += count_bits(&ba->bundles[idx], sizeof(uint32_t)); } return popcnt;