Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

selftest/mm: fix pointer comparison in mremap_test

Pointer arthemitic with 'void * addr' and 'ulong 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) {
| ^

this warning is raised from clang version 20.1.8 (Fedora 20.1.8-4.fc42).

use 'void *tmp_addr' to do the pointer arthemitic.

Link: https://lkml.kernel.org/r/20251108161829.25105-1-ankitkhushwaha.linux@gmail.com
Signed-off-by: Ankit Khushwaha <ankitkhushwaha.linux@gmail.com>
Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Ankit Khushwaha and committed by
Andrew Morton
3b12a53b 4f8961b2

+3 -2
+3 -2
tools/testing/selftests/mm/mremap_test.c
··· 994 994 static long long remap_region(struct config c, unsigned int threshold_mb, 995 995 char *rand_addr) 996 996 { 997 - void *addr, *src_addr, *dest_addr, *dest_preamble_addr = NULL; 997 + void *addr, *tmp_addr, *src_addr, *dest_addr, *dest_preamble_addr = NULL; 998 998 unsigned long long t, d; 999 999 struct timespec t_start = {0, 0}, t_end = {0, 0}; 1000 1000 long long start_ns, end_ns, align_mask, ret, offset; ··· 1032 1032 /* Don't destroy existing mappings unless expected to overlap */ 1033 1033 while (!is_remap_region_valid(addr, c.region_size) && !c.overlapping) { 1034 1034 /* Check for unsigned overflow */ 1035 - if (addr + c.dest_alignment < addr) { 1035 + tmp_addr = addr + c.dest_alignment; 1036 + if (tmp_addr < addr) { 1036 1037 ksft_print_msg("Couldn't find a valid region to remap to\n"); 1037 1038 ret = -1; 1038 1039 goto clean_up_src;