Skip to content

Commit 69334ca

Browse files
andy-shevtorvalds
authored andcommitted
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. Link: http://lkml.kernel.org/r/[email protected] Fixes: 30544ed ("lib/bitmap: introduce bitmap_replace() helper") Signed-off-by: Andy Shevchenko <[email protected]> Reported-by: Guenter Roeck <[email protected]> Cc: Rasmus Villemoes <[email protected]> Cc: Yury Norov <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 39bed42 commit 69334ca

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/test_bitmap.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,22 +275,23 @@ static void __init test_copy(void)
275275
static void __init test_replace(void)
276276
{
277277
unsigned int nbits = 64;
278+
unsigned int nlongs = DIV_ROUND_UP(nbits, BITS_PER_LONG);
278279
DECLARE_BITMAP(bmap, 1024);
279280

280281
bitmap_zero(bmap, 1024);
281-
bitmap_replace(bmap, &exp2[0], &exp2[1], exp2_to_exp3_mask, nbits);
282+
bitmap_replace(bmap, &exp2[0 * nlongs], &exp2[1 * nlongs], exp2_to_exp3_mask, nbits);
282283
expect_eq_bitmap(bmap, exp3_0_1, nbits);
283284

284285
bitmap_zero(bmap, 1024);
285-
bitmap_replace(bmap, &exp2[1], &exp2[0], exp2_to_exp3_mask, nbits);
286+
bitmap_replace(bmap, &exp2[1 * nlongs], &exp2[0 * nlongs], exp2_to_exp3_mask, nbits);
286287
expect_eq_bitmap(bmap, exp3_1_0, nbits);
287288

288289
bitmap_fill(bmap, 1024);
289-
bitmap_replace(bmap, &exp2[0], &exp2[1], exp2_to_exp3_mask, nbits);
290+
bitmap_replace(bmap, &exp2[0 * nlongs], &exp2[1 * nlongs], exp2_to_exp3_mask, nbits);
290291
expect_eq_bitmap(bmap, exp3_0_1, nbits);
291292

292293
bitmap_fill(bmap, 1024);
293-
bitmap_replace(bmap, &exp2[1], &exp2[0], exp2_to_exp3_mask, nbits);
294+
bitmap_replace(bmap, &exp2[1 * nlongs], &exp2[0 * nlongs], exp2_to_exp3_mask, nbits);
294295
expect_eq_bitmap(bmap, exp3_1_0, nbits);
295296
}
296297

0 commit comments

Comments
 (0)