tests: ztest: fixed off-by-one in sys_bitfield_find_first_clear
Calling __builtin_ffsl(neg_bitmap) returns first bit set in the word,
e.g. 4 if bitmap is 11111000. As this must translate to zero-based index
3, one must be subtracted from the result.
Signed-off-by: Morten Priess <mtpr@oticon.com>
diff --git a/tests/ztest/src/ztest_mock.c b/tests/ztest/src/ztest_mock.c
index af1cbc3..808d360 100644
--- a/tests/ztest/src/ztest_mock.c
+++ b/tests/ztest/src/ztest_mock.c
@@ -72,7 +72,7 @@
else if (neg_bitmap == ~0UL) /* first bit */
return cnt * BITS_PER_UL;
else
- return cnt * BITS_PER_UL + __builtin_ffsl(neg_bitmap);
+ return cnt * BITS_PER_UL + __builtin_ffsl(neg_bitmap) - 1;
}
return -1;
}