lib: use correct format string for find-bit tests
PATCH 1/1 lib: use correct format string for find-bit tests
The cycles_t definition is architecture specific, which causes a link error on all architectures that use a 'long long' or 'int' type for it:
lib/test_find_bit.c: In function 'test_find_last_bit':include/linux/kern_levels.h:5:18: error: format '%ld' expects argument of type 'long int', but argument 2 has type 'cycles_t {aka long long unsigned int}' [-Werror=format=]
This adds an explicit cast to 'u64' for it, which lets us use '%llu' everywhere.
--- lib/test_find_bit.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
lib/test_find_bit.c +8 -5
@@ -51,7 +51,8 @@ static int __init test_find_first_bit(void *bitmap, unsigned long len)__clear_bit (i, bitmap); } cycles =get_cycles () - cycles; -pr_err ("find_first_bit:\t\t%ld cycles,\t%ld iterations\n" , cycles, cnt); +pr_err ("find_first_bit:\t\t%llu cycles,\t%ld iterations\n" , + (u64 )cycles, cnt);return 0 ; }
@@ -65,7 +66,8 @@ static int __init test_find_next_bit(const void *bitmap, unsigned long len)for (cnt = i =0 ; i <BITMAP_LEN ; cnt++) i =find_next_bit (bitmap,BITMAP_LEN , i) +1 ; cycles =get_cycles () - cycles; -pr_err ("find_next_bit:\t\t%ld cycles,\t%ld iterations\n" , cycles, cnt); +pr_err ("find_next_bit:\t\t%llu cycles,\t%ld iterations\n" , + (u64 )cycles, cnt);return 0 ; }
@@ -79,8 +81,8 @@ static int __init test_find_next_zero_bit(const void *bitmap, unsigned long len)for (cnt = i =0 ; i <BITMAP_LEN ; cnt++) i =find_next_zero_bit (bitmap, len, i) +1 ; cycles =get_cycles () - cycles; -pr_err ("find_next_zero_bit:\t%ld cycles,\t%ld iterations\n" , - cycles, cnt); +pr_err ("find_next_zero_bit:\t%llu cycles,\t%ld iterations\n" , + (u64 )cycles, cnt);return 0 ; }
@@ -99,7 +101,8 @@ static int __init test_find_last_bit(const void *bitmap, unsigned long len) len = l; }while (len); cycles =get_cycles () - cycles; -pr_err ("find_last_bit:\t\t%ld cycles,\t%ld iterations\n" , cycles, cnt); +pr_err ("find_last_bit:\t\t%llu cycles,\t%ld iterations\n" , + (u64 )cycles, cnt);return 0 ; }
Signature · 1 line
2.9.0
Quoted 4 lines · Arnd Bergmann
The
cycles_tdefinition is architecture specific, which causes a link error on all architectures that use a 'long long' or 'int' type for it:
Quoted 8 lines
lib/test_find_bit.c: In function 'test_find_last_bit':include/linux/kern_levels.h:5:18: error: format '%ld' expects argument of type 'long int', but argument 2 has type 'cycles_t{aka long long unsigned int}' [-Werror=format=]This adds an explicit cast to 'u64' for it, which lets us use '%llu' everywhere.
Fixes 09588b1f1d58 ("lib: test module for find_*_bit() functions")Signed-off-by Arnd Bergmann <[email protected]>
Hi Arnd,
patch looks OK. Thank you.