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.

selftests/mm: convert page_size to unsigned long

Cppcheck warning:
int result is assigned to long long variable. If the variable is long long
to avoid loss of information, then you have loss of information.

This patch changes the type of page_size from 'unsigned int' to
'unsigned long' instead of using ULL suffixes. Changing hpage_size to
'unsigned long' was considered, but since gethugepage() expects an int,
this change was avoided.

Link: https://lkml.kernel.org/r/20250403101345.29226-1-siddarthsgml@gmail.com
Signed-off-by: Siddarth G <siddarthsgml@gmail.com>
Reported-by: David Binderman <dcb314@hotmail.com>
Closes: https://lore.kernel.org/all/AS8PR02MB10217315060BBFDB21F19643E9CA62@AS8PR02MB10217.eurprd02.prod.outlook.com/
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Siddarth G and committed by
Andrew Morton
0bf19a35 26d4d18b

+6 -6
+6 -6
tools/testing/selftests/mm/pagemap_ioctl.c
··· 34 34 #define PAGEMAP "/proc/self/pagemap" 35 35 int pagemap_fd; 36 36 int uffd; 37 - unsigned int page_size; 37 + unsigned long page_size; 38 38 unsigned int hpage_size; 39 39 const char *progname; 40 40 ··· 184 184 185 185 int userfaultfd_tests(void) 186 186 { 187 - int mem_size, vec_size, written, num_pages = 16; 187 + long mem_size, vec_size, written, num_pages = 16; 188 188 char *mem, *vec; 189 189 190 190 mem_size = num_pages * page_size; ··· 213 213 written = pagemap_ioctl(mem, mem_size, vec, 1, PM_SCAN_WP_MATCHING | PM_SCAN_CHECK_WPASYNC, 214 214 vec_size - 2, PAGE_IS_WRITTEN, 0, 0, PAGE_IS_WRITTEN); 215 215 if (written < 0) 216 - ksft_exit_fail_msg("error %d %d %s\n", written, errno, strerror(errno)); 216 + ksft_exit_fail_msg("error %ld %d %s\n", written, errno, strerror(errno)); 217 217 218 218 ksft_test_result(written == 0, "%s all new pages must not be written (dirty)\n", __func__); 219 219 ··· 995 995 { 996 996 void *start = (void *)0x10000000; 997 997 int written, len = 0x00040000; 998 - int vec_size = len / page_size; 998 + long vec_size = len / page_size; 999 999 struct page_region *vec = malloc(sizeof(struct page_region) * vec_size); 1000 1000 1001 1001 /* 1. Get written pages */ ··· 1051 1051 int sanity_tests(void) 1052 1052 { 1053 1053 unsigned long long mem_size, vec_size; 1054 - int ret, fd, i, buf_size; 1054 + long ret, fd, i, buf_size; 1055 1055 struct page_region *vec; 1056 1056 char *mem, *fmem; 1057 1057 struct stat sbuf; ··· 1160 1160 1161 1161 ret = stat(progname, &sbuf); 1162 1162 if (ret < 0) 1163 - ksft_exit_fail_msg("error %d %d %s\n", ret, errno, strerror(errno)); 1163 + ksft_exit_fail_msg("error %ld %d %s\n", ret, errno, strerror(errno)); 1164 1164 1165 1165 fmem = mmap(NULL, sbuf.st_size, PROT_READ, MAP_PRIVATE, fd, 0); 1166 1166 if (fmem == MAP_FAILED)