linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/2] lib/test_bitmap: Correct test data offsets for 32-bit
@ 2020-01-08 18:46 Andy Shevchenko
  2020-01-08 18:46 ` [PATCH v1 2/2] lib/test_bitmap: Fix address space when test user buffer Andy Shevchenko
  2020-01-08 19:24 ` [PATCH v1 1/2] lib/test_bitmap: Correct test data offsets for 32-bit Yury Norov
  0 siblings, 2 replies; 6+ messages in thread
From: Andy Shevchenko @ 2020-01-08 18:46 UTC (permalink / raw)
  To: Rasmus Villemoes, Yury Norov, linux-kernel, Andrew Morton, Guenter Roeck
  Cc: 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 <linux@roeck-us.net>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 lib/test_bitmap.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/lib/test_bitmap.c b/lib/test_bitmap.c
index 5cb35a734462..af522577a76e 100644
--- a/lib/test_bitmap.c
+++ b/lib/test_bitmap.c
@@ -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);
 }
 
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-01-09 10:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-08 18:46 [PATCH v1 1/2] lib/test_bitmap: Correct test data offsets for 32-bit Andy Shevchenko
2020-01-08 18:46 ` [PATCH v1 2/2] lib/test_bitmap: Fix address space when test user buffer Andy Shevchenko
2020-01-08 19:24 ` [PATCH v1 1/2] lib/test_bitmap: Correct test data offsets for 32-bit Yury Norov
2020-01-08 20:26   ` Andy Shevchenko
2020-01-08 20:43     ` Yury Norov
2020-01-09 10:27       ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).