* [PATCH -next] selftests/mm: mseal, self_elf: Fix warning comparing pointer to 0
@ 2024-07-18 3:10 Jiapeng Chong
2024-07-18 3:46 ` Andrew Morton
0 siblings, 1 reply; 2+ messages in thread
From: Jiapeng Chong @ 2024-07-18 3:10 UTC (permalink / raw)
To: akpm
Cc: shuah, linux-mm, linux-kselftest, linux-kernel, Jiapeng Chong,
Abaci Robot
Avoid pointer type value compared with 0 to make code clear.
./tools/testing/selftests/mm/mseal_test.c:486:27-28: WARNING comparing pointer to 0.
./tools/testing/selftests/mm/mseal_test.c:1399:29-30: WARNING comparing pointer to 0.
Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=9552
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
---
tools/testing/selftests/mm/mseal_test.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/tools/testing/selftests/mm/mseal_test.c b/tools/testing/selftests/mm/mseal_test.c
index a818f010de47..50a5b9b9399e 100644
--- a/tools/testing/selftests/mm/mseal_test.c
+++ b/tools/testing/selftests/mm/mseal_test.c
@@ -481,9 +481,8 @@ static void test_seal_zero_address(void)
int prot;
/* use mmap to change protection. */
- ptr = sys_mmap(0, size, PROT_NONE,
- MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0);
- FAIL_TEST_IF_FALSE(ptr == 0);
+ ptr = sys_mmap(0, size, PROT_NONE, MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0);
+ FAIL_TEST_IF_FALSE(!ptr);
size = get_vma_size(ptr, &prot);
FAIL_TEST_IF_FALSE(size == 4 * page_size);
@@ -1390,13 +1389,12 @@ static void test_seal_mremap_move_fixed_zero(bool seal)
/*
* MREMAP_FIXED can move the mapping to zero address
*/
- ret2 = mremap(ptr, size, 2 * page_size, MREMAP_MAYMOVE | MREMAP_FIXED,
- 0);
+ ret2 = mremap(ptr, size, 2 * page_size, MREMAP_MAYMOVE | MREMAP_FIXED, 0);
if (seal) {
FAIL_TEST_IF_FALSE(ret2 == MAP_FAILED);
FAIL_TEST_IF_FALSE(errno == EPERM);
} else {
- FAIL_TEST_IF_FALSE(ret2 == 0);
+ FAIL_TEST_IF_FALSE(!ret2);
}
--
2.32.0.3.g01195cf9f
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH -next] selftests/mm: mseal, self_elf: Fix warning comparing pointer to 0
2024-07-18 3:10 [PATCH -next] selftests/mm: mseal, self_elf: Fix warning comparing pointer to 0 Jiapeng Chong
@ 2024-07-18 3:46 ` Andrew Morton
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2024-07-18 3:46 UTC (permalink / raw)
To: Jiapeng Chong; +Cc: shuah, linux-mm, linux-kselftest, linux-kernel, Abaci Robot
On Thu, 18 Jul 2024 11:10:39 +0800 Jiapeng Chong <jiapeng.chong@linux.alibaba.com> wrote:
> Avoid pointer type value compared with 0 to make code clear.
>
> ./tools/testing/selftests/mm/mseal_test.c:486:27-28: WARNING comparing pointer to 0.
> ./tools/testing/selftests/mm/mseal_test.c:1399:29-30: WARNING comparing pointer to 0.
>
> ...
>
> --- a/tools/testing/selftests/mm/mseal_test.c
> +++ b/tools/testing/selftests/mm/mseal_test.c
> @@ -481,9 +481,8 @@ static void test_seal_zero_address(void)
> int prot;
>
> /* use mmap to change protection. */
> - ptr = sys_mmap(0, size, PROT_NONE,
> - MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0);
> - FAIL_TEST_IF_FALSE(ptr == 0);
> + ptr = sys_mmap(0, size, PROT_NONE, MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0);
> + FAIL_TEST_IF_FALSE(!ptr);
> @@ -1390,13 +1389,12 @@ static void test_seal_mremap_move_fixed_zero(bool seal)
> /*
> * MREMAP_FIXED can move the mapping to zero address
> */
> - ret2 = mremap(ptr, size, 2 * page_size, MREMAP_MAYMOVE | MREMAP_FIXED,
> - 0);
> + ret2 = mremap(ptr, size, 2 * page_size, MREMAP_MAYMOVE | MREMAP_FIXED, 0);
The author of this code chose to make it tractable in an 80-column
display. It's best not to change that, without explanation.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-07-18 3:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-18 3:10 [PATCH -next] selftests/mm: mseal, self_elf: Fix warning comparing pointer to 0 Jiapeng Chong
2024-07-18 3:46 ` Andrew Morton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox