Skip to content

Commit f8ee436

Browse files
musamaanjumakpm00
authored andcommitted
selftests/mm: mremap_test: fix build warning
Use 2 separate variables of types int and unsigned long long instead of confusing them. This corrects the correct print format for each of them and removes the build warning: warning: format `%d' expects argument of type `int', but argument 2 has type `long long unsigned int' Link: https://lkml.kernel.org/r/20240112071851.612930-1-usama.anjum@collabora.com Fixes: a4cb3b2 ("selftests: mm: add a test for remapping to area immediately after existing mapping") Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com> Cc: Joel Fernandes (Google) <joel@joelfernandes.org> Cc: Lorenzo Stoakes <lstoakes@gmail.com> Cc: Shuah Khan <shuah@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 19d3e22 commit f8ee436

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

tools/testing/selftests/mm/mremap_test.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,8 @@ static long long remap_region(struct config c, unsigned int threshold_mb,
360360
char pattern_seed)
361361
{
362362
void *addr, *src_addr, *dest_addr, *dest_preamble_addr;
363-
unsigned long long i;
363+
int d;
364+
unsigned long long t;
364365
struct timespec t_start = {0, 0}, t_end = {0, 0};
365366
long long start_ns, end_ns, align_mask, ret, offset;
366367
unsigned long long threshold;
@@ -378,8 +379,8 @@ static long long remap_region(struct config c, unsigned int threshold_mb,
378379

379380
/* Set byte pattern for source block. */
380381
srand(pattern_seed);
381-
for (i = 0; i < threshold; i++)
382-
memset((char *) src_addr + i, (char) rand(), 1);
382+
for (t = 0; t < threshold; t++)
383+
memset((char *) src_addr + t, (char) rand(), 1);
383384

384385
/* Mask to zero out lower bits of address for alignment */
385386
align_mask = ~(c.dest_alignment - 1);
@@ -420,8 +421,8 @@ static long long remap_region(struct config c, unsigned int threshold_mb,
420421

421422
/* Set byte pattern for the dest preamble block. */
422423
srand(pattern_seed);
423-
for (i = 0; i < c.dest_preamble_size; i++)
424-
memset((char *) dest_preamble_addr + i, (char) rand(), 1);
424+
for (d = 0; d < c.dest_preamble_size; d++)
425+
memset((char *) dest_preamble_addr + d, (char) rand(), 1);
425426
}
426427

427428
clock_gettime(CLOCK_MONOTONIC, &t_start);
@@ -437,14 +438,14 @@ static long long remap_region(struct config c, unsigned int threshold_mb,
437438

438439
/* Verify byte pattern after remapping */
439440
srand(pattern_seed);
440-
for (i = 0; i < threshold; i++) {
441+
for (t = 0; t < threshold; t++) {
441442
char c = (char) rand();
442443

443-
if (((char *) dest_addr)[i] != c) {
444+
if (((char *) dest_addr)[t] != c) {
444445
ksft_print_msg("Data after remap doesn't match at offset %llu\n",
445-
i);
446+
t);
446447
ksft_print_msg("Expected: %#x\t Got: %#x\n", c & 0xff,
447-
((char *) dest_addr)[i] & 0xff);
448+
((char *) dest_addr)[t] & 0xff);
448449
ret = -1;
449450
goto clean_up_dest;
450451
}
@@ -453,14 +454,14 @@ static long long remap_region(struct config c, unsigned int threshold_mb,
453454
/* Verify the dest preamble byte pattern after remapping */
454455
if (c.dest_preamble_size) {
455456
srand(pattern_seed);
456-
for (i = 0; i < c.dest_preamble_size; i++) {
457+
for (d = 0; d < c.dest_preamble_size; d++) {
457458
char c = (char) rand();
458459

459-
if (((char *) dest_preamble_addr)[i] != c) {
460+
if (((char *) dest_preamble_addr)[d] != c) {
460461
ksft_print_msg("Preamble data after remap doesn't match at offset %d\n",
461-
i);
462+
d);
462463
ksft_print_msg("Expected: %#x\t Got: %#x\n", c & 0xff,
463-
((char *) dest_preamble_addr)[i] & 0xff);
464+
((char *) dest_preamble_addr)[d] & 0xff);
464465
ret = -1;
465466
goto clean_up_dest;
466467
}

0 commit comments

Comments
 (0)