Skip to content

Commit fcf13b5

Browse files
committed
tests: kernel: adopt new sys_count_bits util function
Adopt new sys_count_bits helper from util.h and avoid having conflicting definition Signed-off-by: Benjamin Cabé <[email protected]> Signed-off-by: Emil Gydesen <[email protected]>
1 parent 1ee48cf commit fcf13b5

File tree

1 file changed

+1
-17
lines changed

1 file changed

+1
-17
lines changed

tests/kernel/common/src/bitarray.c

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -393,29 +393,13 @@ void alloc_and_free_predefined(void)
393393
"sys_bitarray_alloc() failed bits comparison");
394394
}
395395

396-
static inline size_t count_bits(uint32_t val)
397-
{
398-
/* Implements Brian Kernighan’s Algorithm
399-
* to count bits.
400-
*/
401-
402-
size_t cnt = 0;
403-
404-
while (val != 0) {
405-
val = val & (val - 1);
406-
cnt++;
407-
}
408-
409-
return cnt;
410-
}
411-
412396
size_t get_bitarray_popcnt(sys_bitarray_t *ba)
413397
{
414398
size_t popcnt = 0;
415399
unsigned int idx;
416400

417401
for (idx = 0; idx < ba->num_bundles; idx++) {
418-
popcnt += count_bits(ba->bundles[idx]);
402+
popcnt += sys_count_bits(&ba->bundles[idx], sizeof(uint32_t));
419403
}
420404

421405
return popcnt;

0 commit comments

Comments
 (0)