linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
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 06/16] selftests/mm: cow: remove unused variables and fix type mismatch errors
Date: Thu,  9 Jan 2025 22:38:32 +0500	[thread overview]
Message-ID: <20250109173842.1142376-7-usama.anjum@collabora.com> (raw)
In-Reply-To: <20250109173842.1142376-1-usama.anjum@collabora.com>

Fix following warnings:
- Remove unused variables
- Use __attribute__(unused) with unused variables which aren't being
  used and cannot be removed because of function pointer declaration
- Fix type mismatches

Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
---
 tools/testing/selftests/mm/cow.c | 46 +++++++++++++++++++-------------
 1 file changed, 27 insertions(+), 19 deletions(-)

diff --git a/tools/testing/selftests/mm/cow.c b/tools/testing/selftests/mm/cow.c
index ea00c85c76caa..e37eb863e66cd 100644
--- a/tools/testing/selftests/mm/cow.c
+++ b/tools/testing/selftests/mm/cow.c
@@ -84,7 +84,7 @@ static void detect_huge_zeropage(void)
 		return;
 
 	ret = pread(fd, buf, sizeof(buf), 0);
-	if (ret > 0 && ret < sizeof(buf)) {
+	if (ret > 0 && (unsigned int)ret < sizeof(buf)) {
 		buf[ret] = 0;
 
 		enabled = strtoul(buf, NULL, 10);
@@ -263,12 +263,14 @@ static void do_test_cow_in_parent(char *mem, size_t size, bool do_mprotect,
 	close_comm_pipes(&comm_pipes);
 }
 
-static void test_cow_in_parent(char *mem, size_t size, bool is_hugetlb)
+static void test_cow_in_parent(char *mem, size_t size,
+			       bool __attribute__((unused)) is_hugetlb)
 {
 	do_test_cow_in_parent(mem, size, false, child_memcmp_fn, false);
 }
 
-static void test_cow_in_parent_mprotect(char *mem, size_t size, bool is_hugetlb)
+static void test_cow_in_parent_mprotect(char *mem, size_t size,
+					bool __attribute__((unused)) is_hugetlb)
 {
 	do_test_cow_in_parent(mem, size, true, child_memcmp_fn, false);
 }
@@ -408,10 +410,11 @@ static void do_test_iouring(char *mem, size_t size, bool use_fork)
 	struct io_uring_cqe *cqe;
 	struct io_uring_sqe *sqe;
 	struct io_uring ring;
-	ssize_t cur, total;
 	struct iovec iov;
 	char *buf, *tmp;
+	size_t total;
 	int ret, fd;
+	ssize_t cur;
 	FILE *file;
 
 	ret = setup_comm_pipes(&comm_pipes);
@@ -515,7 +518,7 @@ static void do_test_iouring(char *mem, size_t size, bool use_fork)
 		goto quit_child;
 	}
 
-	if (cqe->res != size) {
+	if ((unsigned int) cqe->res != size) {
 		ksft_test_result_fail("write_fixed failed\n");
 		goto quit_child;
 	}
@@ -529,7 +532,7 @@ static void do_test_iouring(char *mem, size_t size, bool use_fork)
 			ksft_test_result_fail("pread() failed\n");
 			goto quit_child;
 		}
-		total += cur;
+		total += (size_t)cur;
 	}
 
 	/* Finally, check if we read what we expected. */
@@ -553,12 +556,14 @@ static void do_test_iouring(char *mem, size_t size, bool use_fork)
 	close_comm_pipes(&comm_pipes);
 }
 
-static void test_iouring_ro(char *mem, size_t size, bool is_hugetlb)
+static void test_iouring_ro(char *mem, size_t size,
+			    bool __attribute__((unused)) is_hugetlb)
 {
 	do_test_iouring(mem, size, false);
 }
 
-static void test_iouring_fork(char *mem, size_t size, bool is_hugetlb)
+static void test_iouring_fork(char *mem, size_t size,
+			      bool __attribute__((unused)) is_hugetlb)
 {
 	do_test_iouring(mem, size, true);
 }
@@ -702,36 +707,38 @@ static void do_test_ro_pin(char *mem, size_t size, enum ro_pin_test test,
 	free(tmp);
 }
 
-static void test_ro_pin_on_shared(char *mem, size_t size, bool is_hugetlb)
+static void test_ro_pin_on_shared(char *mem, size_t size,
+				  bool __attribute__((unused)) is_hugetlb)
 {
 	do_test_ro_pin(mem, size, RO_PIN_TEST_SHARED, false);
 }
 
-static void test_ro_fast_pin_on_shared(char *mem, size_t size, bool is_hugetlb)
+static void test_ro_fast_pin_on_shared(char *mem, size_t size,
+				       bool __attribute__((unused)) is_hugetlb)
 {
 	do_test_ro_pin(mem, size, RO_PIN_TEST_SHARED, true);
 }
 
 static void test_ro_pin_on_ro_previously_shared(char *mem, size_t size,
-		bool is_hugetlb)
+						bool __attribute__((unused)) is_hugetlb)
 {
 	do_test_ro_pin(mem, size, RO_PIN_TEST_PREVIOUSLY_SHARED, false);
 }
 
 static void test_ro_fast_pin_on_ro_previously_shared(char *mem, size_t size,
-		bool is_hugetlb)
+						     bool __attribute__((unused)) is_hugetlb)
 {
 	do_test_ro_pin(mem, size, RO_PIN_TEST_PREVIOUSLY_SHARED, true);
 }
 
 static void test_ro_pin_on_ro_exclusive(char *mem, size_t size,
-		bool is_hugetlb)
+					bool __attribute__((unused)) is_hugetlb)
 {
 	do_test_ro_pin(mem, size, RO_PIN_TEST_RO_EXCLUSIVE, false);
 }
 
 static void test_ro_fast_pin_on_ro_exclusive(char *mem, size_t size,
-		bool is_hugetlb)
+					     bool __attribute__((unused)) is_hugetlb)
 {
 	do_test_ro_pin(mem, size, RO_PIN_TEST_RO_EXCLUSIVE, true);
 }
@@ -1192,7 +1199,7 @@ static void run_anon_test_case(struct test_case const *test_case)
 
 static void run_anon_test_cases(void)
 {
-	int i;
+	unsigned int i;
 
 	ksft_print_msg("[INFO] Anonymous memory tests in private mappings\n");
 
@@ -1420,7 +1427,7 @@ static const struct test_case anon_thp_test_cases[] = {
 
 static void run_anon_thp_test_cases(void)
 {
-	int i;
+	unsigned int i;
 
 	if (!pmdsize)
 		return;
@@ -1457,13 +1464,14 @@ static void test_cow(char *mem, const char *smem, size_t size)
 			 "Other mapping not modified\n");
 	free(old);
 }
+//typedef void (*non_anon_test_fn)(char *mem, const char *smem, size_t size);
 
-static void test_ro_pin(char *mem, const char *smem, size_t size)
+static void test_ro_pin(char *mem, const char __attribute__((unused)) *smem, size_t size)
 {
 	do_test_ro_pin(mem, size, RO_PIN_TEST, false);
 }
 
-static void test_ro_fast_pin(char *mem, const char *smem, size_t size)
+static void test_ro_fast_pin(char *mem, const char __attribute__((unused)) *smem, size_t size)
 {
 	do_test_ro_pin(mem, size, RO_PIN_TEST, true);
 }
@@ -1752,7 +1760,7 @@ static void run_non_anon_test_case(struct non_anon_test_case const *test_case)
 
 static void run_non_anon_test_cases(void)
 {
-	int i;
+	unsigned int i;
 
 	ksft_print_msg("[RUN] Non-anonymous memory tests in private mappings\n");
 
-- 
2.39.5



  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 ` [PATCH 04/16] selftests/mm: Fix type mismatch warnings Muhammad Usama Anjum
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 ` Muhammad Usama Anjum [this message]
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-7-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