From: Muhammad Usama Anjum <usama.anjum@collabora.com>
To: "Kees Cook" <kees@kernel.org>,
"Andy Lutomirski" <luto@amacapital.net>,
"Will Drewry" <wad@chromium.org>, "Shuah Khan" <shuah@kernel.org>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Jérôme Glisse" <jglisse@redhat.com>,
linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-mm@kvack.org
Cc: Muhammad Usama Anjum <usama.anjum@collabora.com>, kernel@collabora.com
Subject: [PATCH 04/16] selftests/mm: Fix type mismatch warnings
Date: Thu, 9 Jan 2025 22:38:30 +0500 [thread overview]
Message-ID: <20250109173842.1142376-5-usama.anjum@collabora.com> (raw)
In-Reply-To: <20250109173842.1142376-1-usama.anjum@collabora.com>
Fix type mismatch warnings in different tests.
Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
---
tools/testing/selftests/mm/compaction_test.c | 2 +-
tools/testing/selftests/mm/gup_longterm.c | 3 ++-
tools/testing/selftests/mm/hugetlb_dio.c | 2 +-
tools/testing/selftests/mm/hugetlb_fault_after_madv.c | 2 +-
tools/testing/selftests/mm/hugetlb_madv_vs_map.c | 2 +-
tools/testing/selftests/mm/ksm_functional_tests.c | 6 +++---
tools/testing/selftests/mm/mlock-random-test.c | 4 ++--
tools/testing/selftests/mm/pkey_sighandler_tests.c | 2 +-
tools/testing/selftests/mm/soft-dirty.c | 2 +-
9 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/tools/testing/selftests/mm/compaction_test.c b/tools/testing/selftests/mm/compaction_test.c
index 8d23b698ce9db..f6f32a5732e9e 100644
--- a/tools/testing/selftests/mm/compaction_test.c
+++ b/tools/testing/selftests/mm/compaction_test.c
@@ -134,7 +134,7 @@ int check_compaction(unsigned long mem_free, unsigned long hugepage_size,
lseek(fd, 0, SEEK_SET);
if (write(fd, init_nr_hugepages, strlen(init_nr_hugepages))
- != strlen(init_nr_hugepages)) {
+ != (signed long int)strlen(init_nr_hugepages)) {
ksft_print_msg("Failed to write value to /proc/sys/vm/nr_hugepages: %s\n",
strerror(errno));
goto close_fd;
diff --git a/tools/testing/selftests/mm/gup_longterm.c b/tools/testing/selftests/mm/gup_longterm.c
index 03a31dcb57577..7f1b4ad7fcaec 100644
--- a/tools/testing/selftests/mm/gup_longterm.c
+++ b/tools/testing/selftests/mm/gup_longterm.c
@@ -446,7 +446,8 @@ static int tests_per_test_case(void)
int main(void)
{
- int i, err;
+ unsigned int i;
+ int err;
pagesize = getpagesize();
nr_hugetlbsizes = detect_hugetlb_page_sizes(hugetlbsizes,
diff --git a/tools/testing/selftests/mm/hugetlb_dio.c b/tools/testing/selftests/mm/hugetlb_dio.c
index db63abe5ee5e8..62f368d4c8c16 100644
--- a/tools/testing/selftests/mm/hugetlb_dio.c
+++ b/tools/testing/selftests/mm/hugetlb_dio.c
@@ -63,7 +63,7 @@ void run_dio_using_hugetlb(unsigned int start_off, unsigned int end_off)
memset(buffer, 'A', writesize);
/* Write the buffer to the file */
- if (write(fd, buffer, writesize) != (writesize)) {
+ if (write(fd, buffer, writesize) != (signed int)writesize) {
munmap(orig_buffer, h_pagesize);
close(fd);
ksft_exit_fail_perror("Error writing to file\n");
diff --git a/tools/testing/selftests/mm/hugetlb_fault_after_madv.c b/tools/testing/selftests/mm/hugetlb_fault_after_madv.c
index e62f4e1388f26..2b5acb13ee0be 100644
--- a/tools/testing/selftests/mm/hugetlb_fault_after_madv.c
+++ b/tools/testing/selftests/mm/hugetlb_fault_after_madv.c
@@ -88,7 +88,7 @@ int main(void)
MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB,
-1, 0);
- if ((unsigned long)huge_ptr == -1)
+ if (huge_ptr == MAP_FAILED)
ksft_exit_skip("Failed to allocated huge page\n");
pthread_create(&thread1, NULL, madv, NULL);
diff --git a/tools/testing/selftests/mm/hugetlb_madv_vs_map.c b/tools/testing/selftests/mm/hugetlb_madv_vs_map.c
index 6c326cf3dcf6b..eda38b63e9e8d 100644
--- a/tools/testing/selftests/mm/hugetlb_madv_vs_map.c
+++ b/tools/testing/selftests/mm/hugetlb_madv_vs_map.c
@@ -100,7 +100,7 @@ int main(void)
MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB,
-1, 0);
- if ((unsigned long)huge_ptr == -1) {
+ if (huge_ptr == MAP_FAILED) {
ksft_test_result_fail("Failed to allocate huge page\n");
return KSFT_FAIL;
}
diff --git a/tools/testing/selftests/mm/ksm_functional_tests.c b/tools/testing/selftests/mm/ksm_functional_tests.c
index 66b4e111b5a27..4f96126e4e1f9 100644
--- a/tools/testing/selftests/mm/ksm_functional_tests.c
+++ b/tools/testing/selftests/mm/ksm_functional_tests.c
@@ -306,7 +306,7 @@ static void test_unmerge_zero_pages(void)
/* Check if ksm_zero_pages is updated correctly after KSM merging */
pages_expected = size / pagesize;
- if (pages_expected != get_my_ksm_zero_pages()) {
+ if ((signed long)pages_expected != get_my_ksm_zero_pages()) {
ksft_test_result_fail("'ksm_zero_pages' updated after merging\n");
goto unmap;
}
@@ -319,7 +319,7 @@ static void test_unmerge_zero_pages(void)
/* Check if ksm_zero_pages is updated correctly after unmerging */
pages_expected /= 2;
- if (pages_expected != get_my_ksm_zero_pages()) {
+ if ((signed long)pages_expected != get_my_ksm_zero_pages()) {
ksft_test_result_fail("'ksm_zero_pages' updated after unmerging\n");
goto unmap;
}
@@ -625,7 +625,7 @@ static void test_prot_none(void)
{
const unsigned int size = 2 * MiB;
char *map;
- int i;
+ unsigned int i;
ksft_print_msg("[RUN] %s\n", __func__);
diff --git a/tools/testing/selftests/mm/mlock-random-test.c b/tools/testing/selftests/mm/mlock-random-test.c
index 0d95d630d0450..f410699458f2a 100644
--- a/tools/testing/selftests/mm/mlock-random-test.c
+++ b/tools/testing/selftests/mm/mlock-random-test.c
@@ -138,7 +138,7 @@ static void test_mlock_within_limit(char *p, int alloc_size)
int page_size = 0;
getrlimit(RLIMIT_MEMLOCK, &cur);
- if (cur.rlim_cur < alloc_size)
+ if (cur.rlim_cur < (unsigned int)alloc_size)
ksft_exit_fail_msg("alloc_size[%d] < %u rlimit,lead to mlock failure\n",
alloc_size, (unsigned int)cur.rlim_cur);
@@ -204,7 +204,7 @@ static void test_mlock_outof_limit(char *p, int alloc_size)
struct rlimit cur;
getrlimit(RLIMIT_MEMLOCK, &cur);
- if (cur.rlim_cur >= alloc_size)
+ if (cur.rlim_cur >= (unsigned int)alloc_size)
ksft_exit_fail_msg("alloc_size[%d] >%u rlimit, violates test condition\n",
alloc_size, (unsigned int)cur.rlim_cur);
diff --git a/tools/testing/selftests/mm/pkey_sighandler_tests.c b/tools/testing/selftests/mm/pkey_sighandler_tests.c
index cd46528d6c215..89c0f4e090374 100644
--- a/tools/testing/selftests/mm/pkey_sighandler_tests.c
+++ b/tools/testing/selftests/mm/pkey_sighandler_tests.c
@@ -535,7 +535,7 @@ static void (*pkey_tests[])(void) = {
int main(void)
{
- int i;
+ unsigned int i;
ksft_print_header();
ksft_set_plan(ARRAY_SIZE(pkey_tests));
diff --git a/tools/testing/selftests/mm/soft-dirty.c b/tools/testing/selftests/mm/soft-dirty.c
index b6eb5c4642ce5..68edb2475ccd4 100644
--- a/tools/testing/selftests/mm/soft-dirty.c
+++ b/tools/testing/selftests/mm/soft-dirty.c
@@ -77,7 +77,7 @@ static void test_vma_reuse(int pagemap_fd, int pagesize)
static void test_hugepage(int pagemap_fd)
{
char *map;
- int i, ret;
+ unsigned int i, ret;
size_t hpage_len = read_pmd_pagesize();
if (!hpage_len)
--
2.39.5
next prev parent reply other threads:[~2025-01-09 17:39 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-09 17:38 [PATCH 00/16] selftest/mm: Remove warnings found by adding compiler flags Muhammad Usama Anjum
2025-01-09 17:38 ` [PATCH 01/16] selftests/mm: remove argc and argv unused parameters Muhammad Usama Anjum
2025-01-09 17:42 ` Kees Cook
2025-01-09 17:48 ` Muhammad Usama Anjum
2025-01-09 17:50 ` Kees Cook
2025-01-10 0:12 ` Andrew Morton
2025-02-01 7:43 ` Muhammad Usama Anjum
2025-01-10 19:00 ` David Laight
2025-02-01 7:32 ` Muhammad Usama Anjum
2025-01-09 17:38 ` [PATCH 02/16] selftests/mm: Fix unused parameter warnings Muhammad Usama Anjum
2025-01-09 17:38 ` [PATCH 03/16] " Muhammad Usama Anjum
2025-01-09 17:38 ` Muhammad Usama Anjum [this message]
2025-01-09 17:38 ` [PATCH 05/16] selftests/mm: kselftest_harness: Fix warnings Muhammad Usama Anjum
2025-01-15 22:19 ` Mark Brown
2025-01-09 17:38 ` [PATCH 06/16] selftests/mm: cow: remove unused variables and fix type mismatch errors Muhammad Usama Anjum
2025-01-09 17:38 ` [PATCH 07/16] selftests/mm: hmm-tests: Remove always false expressions Muhammad Usama Anjum
2025-01-09 17:38 ` [PATCH 08/16] selftests/mm: guard-pages: Fix type mismatch warnings Muhammad Usama Anjum
2025-01-09 17:38 ` [PATCH 09/16] selftests/mm: hugetlb-madvise: fix type mismatch issues Muhammad Usama Anjum
2025-01-09 17:38 ` [PATCH 10/16] selftests/mm: hugepage-vmemmap: fix type mismatch warnings Muhammad Usama Anjum
2025-01-09 17:38 ` [PATCH 11/16] selftests/mm: hugetlb-read-hwpoison: Fix " Muhammad Usama Anjum
2025-01-09 17:38 ` [PATCH 12/16] selftests/mm: khugepaged: " Muhammad Usama Anjum
2025-01-09 17:38 ` [PATCH 13/16] selftests/mm: protection_keys: Fix variables types " Muhammad Usama Anjum
2025-01-09 17:38 ` [PATCH 14/16] selftests/mm: thuge-gen: Fix type " Muhammad Usama Anjum
2025-01-09 17:38 ` [PATCH 15/16] selftests/mm: uffd-*: Fix all " Muhammad Usama Anjum
2025-01-09 17:38 ` [PATCH 16/16] selftests/mm: Makefile: Add the compiler flags Muhammad Usama Anjum
2025-01-16 5:32 ` [PATCH 00/16] selftest/mm: Remove warnings found by adding " Andrew Morton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250109173842.1142376-5-usama.anjum@collabora.com \
--to=usama.anjum@collabora.com \
--cc=akpm@linux-foundation.org \
--cc=jglisse@redhat.com \
--cc=kees@kernel.org \
--cc=kernel@collabora.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=luto@amacapital.net \
--cc=shuah@kernel.org \
--cc=wad@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox