linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] selftest/mm: fix pointer comparison in mremap_test
@ 2025-11-06 10:49 Ankit Khushwaha
  2025-11-06 11:18 ` David Hildenbrand (Red Hat)
  2025-11-06 14:40 ` Lorenzo Stoakes
  0 siblings, 2 replies; 11+ messages in thread
From: Ankit Khushwaha @ 2025-11-06 10:49 UTC (permalink / raw)
  To: Andrew Morton, David Hildenbrand, Lorenzo Stoakes,
	Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
	Suren Baghdasaryan, Michal Hocko, Shuah Khan, linux-mm,
	linux-kselftest
  Cc: linux-kernel, Ankit Khushwaha

Pointer arthemitic with 'void * addr' and 'unsigned long long dest_alignment'
triggers following warning:

mremap_test.c:1035:31: warning: pointer comparison always evaluates to
false [-Wtautological-compare]
 1035 |                 if (addr + c.dest_alignment < addr) {
      |                                             ^

typecasting 'addr' to 'unsigned long long' to fix pointer comparison.

Signed-off-by: Ankit Khushwaha <ankitkhushwaha.linux@gmail.com>
---
 tools/testing/selftests/mm/mremap_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/mm/mremap_test.c b/tools/testing/selftests/mm/mremap_test.c
index a95c0663a011..5ae0400176af 100644
--- a/tools/testing/selftests/mm/mremap_test.c
+++ b/tools/testing/selftests/mm/mremap_test.c
@@ -1032,7 +1032,7 @@ static long long remap_region(struct config c, unsigned int threshold_mb,
 	/* Don't destroy existing mappings unless expected to overlap */
 	while (!is_remap_region_valid(addr, c.region_size) && !c.overlapping) {
 		/* Check for unsigned overflow */
-		if (addr + c.dest_alignment < addr) {
+		if ((unsigned long long) addr + c.dest_alignment < (unsigned long long) addr) {
 			ksft_print_msg("Couldn't find a valid region to remap to\n");
 			ret = -1;
 			goto clean_up_src;
--
2.51.0



^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2025-11-10 21:43 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-06 10:49 [PATCH] selftest/mm: fix pointer comparison in mremap_test Ankit Khushwaha
2025-11-06 11:18 ` David Hildenbrand (Red Hat)
2025-11-06 12:02   ` Ankit Khushwaha
2025-11-06 14:26     ` Lorenzo Stoakes
2025-11-07  9:27     ` David Hildenbrand (Red Hat)
2025-11-08  0:08       ` Andrew Morton
2025-11-08 16:03         ` Ankit Khushwaha
2025-11-09  6:54         ` Mike Rapoport
2025-11-09 19:11           ` Vlastimil Babka
2025-11-10 21:43             ` Nathan Chancellor
2025-11-06 14:40 ` Lorenzo Stoakes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).