@@ -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;
@@ -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,
@@ -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");
@@ -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);
@@ -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;
}
@@ -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__);
@@ -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);
@@ -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));
@@ -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)
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(-)