[PATCH 15/16] selftests/mm: uffd-*: Fix all type mismatch warnings

Muhammad Usama Anjum
2025-01-09T17:40:24Z

Fix all type mismatch warnings in all uffd-* files.

Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
---
tools/testing/selftests/mm/uffd-common.c | 6 +++---
tools/testing/selftests/mm/uffd-stress.c | 2 +-
tools/testing/selftests/mm/uffd-unit-tests.c | 6 +++---
3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/tools/testing/selftests/mm/uffd-common.c b/tools/testing/selftests/mm/uffd-common.c
index c15674a60f299..47bdcb47481ae 100644
--- a/tools/testing/selftests/mm/uffd-common.c
+++ b/tools/testing/selftests/mm/uffd-common.c
@@ -450,7 +450,7 @@ void uffd_handle_page_fault(struct uffd_msg *msg, struct uffd_args *args)
args->wp_faults++;
} else if (msg->arg.pagefault.flags & UFFD_PAGEFAULT_FLAG_MINOR) {
uint8_t *area;
- int b;
+ unsigned int b;

/*
* Minor page faults
@@ -621,7 +621,7 @@ int __copy_page(int ufd, unsigned long offset, bool retry, bool wp)
err("UFFDIO_COPY error: %"PRId64,
(int64_t)uffdio_copy.copy);
wake_range(ufd, uffdio_copy.dst, page_size);
- } else if (uffdio_copy.copy != page_size) {
+ } else if (uffdio_copy.copy != (signed long)page_size) {
err("UFFDIO_COPY error: %"PRId64, (int64_t)uffdio_copy.copy);
} else {
if (test_uffdio_copy_eexist && retry) {
@@ -655,7 +655,7 @@ int move_page(int ufd, unsigned long offset, unsigned long len)
err("UFFDIO_MOVE error: %"PRId64,
(int64_t)uffdio_move.move);
wake_range(ufd, uffdio_move.dst, len);
- } else if (uffdio_move.move != len) {
+ } else if (uffdio_move.move != (signed long)len) {
err("UFFDIO_MOVE error: %"PRId64, (int64_t)uffdio_move.move);
} else
return 1;
diff --git a/tools/testing/selftests/mm/uffd-stress.c b/tools/testing/selftests/mm/uffd-stress.c
index 1270ff3104cc6..5509ec32c3290 100644
--- a/tools/testing/selftests/mm/uffd-stress.c
+++ b/tools/testing/selftests/mm/uffd-stress.c
@@ -77,7 +77,7 @@ static void usage(void)

static void uffd_stats_reset(struct uffd_args *args, unsigned long n_cpus)
{
- int i;
+ unsigned int i;

for (i = 0; i < n_cpus; i++) {
args[i].cpu = i;
diff --git a/tools/testing/selftests/mm/uffd-unit-tests.c b/tools/testing/selftests/mm/uffd-unit-tests.c
index 81b315bedb744..c3d59ec754040 100644
--- a/tools/testing/selftests/mm/uffd-unit-tests.c
+++ b/tools/testing/selftests/mm/uffd-unit-tests.c
@@ -917,7 +917,7 @@ static bool do_uffdio_zeropage(int ufd, bool has_zeropage)
else if (res != -EINVAL)
err("UFFDIO_ZEROPAGE not -EINVAL");
} else if (has_zeropage) {
- if (res != page_size)
+ if (res != (signed long)page_size)
err("UFFDIO_ZEROPAGE unexpected size");
else
retry_uffdio_zeropage(ufd, &uffdio_zeropage);
@@ -949,7 +949,7 @@ uffd_register_detect_zeropage(int uffd, void *addr, uint64_t len)
static void uffd_zeropage_test(uffd_test_args_t __attribute__((unused)) *args)
{
bool has_zeropage;
- int i;
+ unsigned int i;

has_zeropage = uffd_register_detect_zeropage(uffd, area_dst, page_size);
if (area_dst_alias)
@@ -997,7 +997,7 @@ static void do_uffdio_poison(int uffd, unsigned long offset)

if (ret)
err("UFFDIO_POISON error: %"PRId64, (int64_t)res);
- else if (res != page_size)
+ else if (res != (signed long)page_size)
err("UFFDIO_POISON unexpected size: %"PRId64, (int64_t)res);
}

--
2.39.5