lib/test_bitmap: Correct test data offsets for 32-bit
Subsystems (2)
PATCH 1/2 lib/test_bitmap: Correct test data offsets for 32-bit
On 32-bit platform the size of long is only 32 bits which makes wrong offset in the array of 64 bit size.
Calculate offset based on BITS_PER_LONG.
--- lib/test_bitmap.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
lib/test_bitmap.c +5 -4
@@ -275,22 +275,23 @@ static void __init test_copy(void)static void __init test_replace (void ) {unsigned int nbits =64 ; +unsigned int step =DIV_ROUND_UP (nbits,BITS_PER_LONG );DECLARE_BITMAP (bmap,1024 );bitmap_zero (bmap,1024 ); -bitmap_replace (bmap, &exp2[0 ], &exp2[1 ], exp2_to_exp3_mask, nbits); +bitmap_replace (bmap, &exp2[0 * step], &exp2[1 * step], exp2_to_exp3_mask, nbits);expect_eq_bitmap (bmap, exp3_0_1, nbits);bitmap_zero (bmap,1024 ); -bitmap_replace (bmap, &exp2[1 ], &exp2[0 ], exp2_to_exp3_mask, nbits); +bitmap_replace (bmap, &exp2[1 * step], &exp2[0 * step], exp2_to_exp3_mask, nbits);expect_eq_bitmap (bmap, exp3_1_0, nbits);bitmap_fill (bmap,1024 ); -bitmap_replace (bmap, &exp2[0 ], &exp2[1 ], exp2_to_exp3_mask, nbits); +bitmap_replace (bmap, &exp2[0 * step], &exp2[1 * step], exp2_to_exp3_mask, nbits);expect_eq_bitmap (bmap, exp3_0_1, nbits);bitmap_fill (bmap,1024 ); -bitmap_replace (bmap, &exp2[1 ], &exp2[0 ], exp2_to_exp3_mask, nbits); +bitmap_replace (bmap, &exp2[1 * step], &exp2[0 * step], exp2_to_exp3_mask, nbits);expect_eq_bitmap (bmap, exp3_1_0, nbits); }
Signature · 1 line
2.24.1
PATCH 2/2 lib/test_bitmap: Fix address space when test user buffer
Force address space to avoid the following warning:
lib/test_bitmap.c:461:53: warning: incorrect type in argument 1 (different address spaces)lib/test_bitmap.c:461:53: expected char const [noderef] <asn:1> *ubuflib/test_bitmap.c:461:53: got char const *in
--- lib/test_bitmap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
lib/test_bitmap.c +2 -1
@@ -458,7 +458,8 @@ static void __init __test_bitmap_parse(int is_user)set_fs (KERNEL_DS ); time =ktime_get (); - err =bitmap_parse_user (test.in, len, bmap, test.nbits); + err =bitmap_parse_user ((__force const char __user *)test.in, len, + bmap, test.nbits); time =ktime_get () - time;set_fs (orig_fs); }else {
Signature · 1 line
2.24.1
Yury Norov
maintainerQuoted 17 lines · Andy Shevchenko
On 32-bit platform the size of long is only 32 bits which makes wrong offset in the array of 64 bit size.
Calculate offset based on
BITS_PER_LONG.Fixes 30544ed5de43 ("lib/bitmap: introduce bitmap_replace() helper")Reported-by Guenter Roeck <[email protected]>Signed-off-by Andy Shevchenko <[email protected]>--- lib/test_bitmap.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)lib/test_bitmap.c +0
-0
lib/test_bitmap.c static void __init test_copy(void) · line 278
Quoted 4 lines
lib/test_bitmap.c +1
-0@@ -275,22 +275,23 @@ static void __init test_copy(void)static void __init test_replace (void ) {unsigned int nbits =64 ; +unsigned int step =DIV_ROUND_UP (nbits,BITS_PER_LONG );
Step is already defined in this file:
#define step (sizeof(u64) / sizeof(unsigned long))
to avoid the same problem in other test cases. Introducing another variant of it looks messy.
lib/test_bitmap.c static void __init test_copy(void) · line 283
Quoted 6 lines
lib/test_bitmap.c +1
-1DECLARE_BITMAP (bmap,1024 );bitmap_zero (bmap,1024 ); -bitmap_replace (bmap, &exp2[0 ], &exp2[1 ], exp2_to_exp3_mask, nbits); +bitmap_replace (bmap, &exp2[0 * step], &exp2[1 * step], exp2_to_exp3_mask, nbits);expect_eq_bitmap (bmap, exp3_0_1, nbits);
If nbits is always 64, why don't you pass 64 directly?
Yury
Quoted 18 lines
lib/test_bitmap.c +3
-3bitmap_zero (bmap,1024 ); -bitmap_replace (bmap, &exp2[1 ], &exp2[0 ], exp2_to_exp3_mask, nbits); +bitmap_replace (bmap, &exp2[1 * step], &exp2[0 * step], exp2_to_exp3_mask, nbits);expect_eq_bitmap (bmap, exp3_1_0, nbits);bitmap_fill (bmap,1024 ); -bitmap_replace (bmap, &exp2[0 ], &exp2[1 ], exp2_to_exp3_mask, nbits); +bitmap_replace (bmap, &exp2[0 * step], &exp2[1 * step], exp2_to_exp3_mask, nbits);expect_eq_bitmap (bmap, exp3_0_1, nbits);bitmap_fill (bmap,1024 ); -bitmap_replace (bmap, &exp2[1 ], &exp2[0 ], exp2_to_exp3_mask, nbits); +bitmap_replace (bmap, &exp2[1 * step], &exp2[0 * step], exp2_to_exp3_mask, nbits);expect_eq_bitmap (bmap, exp3_1_0, nbits); }Signature · 1 line
2.24.1
Quoted 10 lines · Yury Norov
Quoted 8 lines · Andy Shevchenko
On 32-bit platform the size of long is only 32 bits which makes wrong offset in the array of 64 bit size.
Calculate offset based on
BITS_PER_LONG.Fixes 30544ed5de43 ("lib/bitmap: introduce bitmap_replace() helper")Reported-by Guenter Roeck <[email protected]>Signed-off-by Andy Shevchenko <[email protected]>
Quoted 5 lines
lib/test_bitmap.c static void __init test_copy(void) · line 278
Quoted 2 lines
lib/test_bitmap.c +1
-0unsigned int nbits =64 ; +unsigned int step =DIV_ROUND_UP (nbits,BITS_PER_LONG );Step is already defined in this file:
#define step (sizeof(u64) / sizeof(unsigned long))
...and later undefined.
Quoted 2 lines
to avoid the same problem in other test cases. Introducing another variant of it looks messy.
I don't see any problem.
Quoted 9 lines
lib/test_bitmap.c static void __init test_copy(void) · line 283
Quoted 7 lines
lib/test_bitmap.c +1
-1DECLARE_BITMAP (bmap,1024 );bitmap_zero (bmap,1024 ); -bitmap_replace (bmap, &exp2[0 ], &exp2[1 ], exp2_to_exp3_mask, nbits); +bitmap_replace (bmap, &exp2[0 * step], &exp2[1 * step], exp2_to_exp3_mask, nbits);expect_eq_bitmap (bmap, exp3_0_1, nbits);If nbits is always 64, why don't you pass 64 directly?
We may use any setting. For now it's 64, but nothing prevents us to extend to, let's say, 75.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Yury Norov
maintainerQuoted 17 lines · Andy Shevchenko
Quoted 10 lines · Yury Norov
Quoted 8 lines · Andy Shevchenko
On 32-bit platform the size of long is only 32 bits which makes wrong offset in the array of 64 bit size.
Calculate offset based on
BITS_PER_LONG.Fixes 30544ed5de43 ("lib/bitmap: introduce bitmap_replace() helper")Reported-by Guenter Roeck <[email protected]>Signed-off-by Andy Shevchenko <[email protected]>Quoted 5 lines
lib/test_bitmap.c static void __init test_copy(void) · line 278
Quoted 2 lines
lib/test_bitmap.c +1
-0unsigned int nbits =64 ; +unsigned int step =DIV_ROUND_UP (nbits,BITS_PER_LONG );Step is already defined in this file:
#define step (sizeof(u64) / sizeof(unsigned long))
Quoted 6 lines
...and later undefined.
Quoted 2 lines
to avoid the same problem in other test cases. Introducing another variant of it looks messy.
I don't see any problem.
The problem is that you reimplement the functionality instead of reuse.
Quoted 16 lines
Quoted 8 lines
lib/test_bitmap.c static void __init test_copy(void) · line 283
Quoted 6 lines
lib/test_bitmap.c +1
-1DECLARE_BITMAP (bmap,1024 );bitmap_zero (bmap,1024 ); -bitmap_replace (bmap, &exp2[0 ], &exp2[1 ], exp2_to_exp3_mask, nbits); +bitmap_replace (bmap, &exp2[0 * step], &exp2[1 * step], exp2_to_exp3_mask, nbits);expect_eq_bitmap (bmap, exp3_0_1, nbits);If nbits is always 64, why don't you pass 64 directly?
We may use any setting. For now it's 64, but nothing prevents us to extend to, let's say, 75.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 20 lines · Yury Norov
Quoted 19 lines · Andy Shevchenko
Quoted 10 lines · Yury Norov
Quoted 8 lines · Andy Shevchenko
On 32-bit platform the size of long is only 32 bits which makes wrong offset in the array of 64 bit size.
Calculate offset based on
BITS_PER_LONG.Fixes 30544ed5de43 ("lib/bitmap: introduce bitmap_replace() helper")Reported-by Guenter Roeck <[email protected]>Signed-off-by Andy Shevchenko <[email protected]>Quoted 5 lines
lib/test_bitmap.c static void __init test_copy(void) · line 278
Quoted 2 lines
lib/test_bitmap.c +1
-0unsigned int nbits =64 ; +unsigned int step =DIV_ROUND_UP (nbits,BITS_PER_LONG );Step is already defined in this file:
#define step (sizeof(u64) / sizeof(unsigned long))...and later undefined.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
to avoid the same problem in other test cases. Introducing another variant of it looks messy.
I don't see any problem.
The problem is that you reimplement the functionality instead of reuse.
I may not reuse by the reason I mentioned above. The definition of step works only for 64 bits, we may modify test case for any amount of bits to be tested.
I'll rename the variable to something else to reduce confusion.
Quoted 17 lines
Quoted 17 lines
Quoted 9 lines
lib/test_bitmap.c static void __init test_copy(void) · line 283
Quoted 7 lines
lib/test_bitmap.c +1
-1DECLARE_BITMAP (bmap,1024 );bitmap_zero (bmap,1024 ); -bitmap_replace (bmap, &exp2[0 ], &exp2[1 ], exp2_to_exp3_mask, nbits); +bitmap_replace (bmap, &exp2[0 * step], &exp2[1 * step], exp2_to_exp3_mask, nbits);expect_eq_bitmap (bmap, exp3_0_1, nbits);If nbits is always 64, why don't you pass 64 directly?
We may use any setting. For now it's 64, but nothing prevents us to extend to, let's say, 75.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Signature · 2 lines
With Best Regards, Andy Shevchenko