gpu: nvgpu: unit: posix_bitops: fix fls() tests

The fls() test assumed fls(1)=0, but really fls(1)=1, etc.

Bug found as result of JIRA NVGPU-1042.

Change-Id: I8d0ffe53277f4923a970b46788165ef03b385703
Signed-off-by: Philip Elcan <pelcan@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1828362
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: svc-misra-checker <svc-misra-checker@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Alex Waterman <alexw@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Philip Elcan
2018-09-17 11:42:33 -04:00
committed by mobile promotions
parent 8c4b073537
commit fa7394037c

View File

@@ -110,20 +110,20 @@ static int test_fls(struct unit_module *m, struct gk20a *g, void *args)
unsigned long i;
CHECK_FLS_WORD(single_ulong_maps[0], 0UL);
CHECK_FLS_WORD(single_ulong_maps[1], BITS_PER_LONG - 1UL);
CHECK_FLS_WORD(single_ulong_maps[2], 31UL);
CHECK_FLS_WORD(single_ulong_maps[3], 23UL);
CHECK_FLS_WORD(single_ulong_maps[4], 31UL);
CHECK_FLS_WORD(single_ulong_maps[5], 15UL);
CHECK_FLS_WORD(single_ulong_maps[6], 31UL);
CHECK_FLS_WORD(single_ulong_maps[7], 0UL);
CHECK_FLS_WORD(single_ulong_maps[8], 31UL);
CHECK_FLS_WORD(single_ulong_maps[9], 16UL);
CHECK_FLS_WORD(single_ulong_maps[1], BITS_PER_LONG);
CHECK_FLS_WORD(single_ulong_maps[2], 32UL);
CHECK_FLS_WORD(single_ulong_maps[3], 24UL);
CHECK_FLS_WORD(single_ulong_maps[4], 32UL);
CHECK_FLS_WORD(single_ulong_maps[5], 16UL);
CHECK_FLS_WORD(single_ulong_maps[6], 32UL);
CHECK_FLS_WORD(single_ulong_maps[7], 1UL);
CHECK_FLS_WORD(single_ulong_maps[8], 32UL);
CHECK_FLS_WORD(single_ulong_maps[9], 17UL);
#undef CHECK_FLS_WORD
for (i = 0; i < BITS_PER_LONG; i++) {
if (fls(BIT(i)) != i)
if (fls(BIT(i)) != (i+1))
unit_return_fail(m, "fls(1 << %lu) != %lu! [%lu]\n",
i, i, fls(BIT(i)));
}