[PATCH -next] selftests/bpf: Fix warning comparing pointer to 0

Jiapeng Chong posted 1 patch 1 month, 4 weeks ago
There is a newer version of this series
tools/testing/selftests/bpf/progs/mem_rdonly_untrusted.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH -next] selftests/bpf: Fix warning comparing pointer to 0
Posted by Jiapeng Chong 1 month, 4 weeks ago
Avoid pointer type value compared with 0 to make code clear.

./tools/testing/selftests/bpf/progs/mem_rdonly_untrusted.c:221:10-11: WARNING comparing pointer to 0.

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=23403
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
---
 tools/testing/selftests/bpf/progs/mem_rdonly_untrusted.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/bpf/progs/mem_rdonly_untrusted.c b/tools/testing/selftests/bpf/progs/mem_rdonly_untrusted.c
index 4f94c971ae86..6b725725b2bf 100644
--- a/tools/testing/selftests/bpf/progs/mem_rdonly_untrusted.c
+++ b/tools/testing/selftests/bpf/progs/mem_rdonly_untrusted.c
@@ -218,7 +218,7 @@ int null_check(void *ctx)
 	int *p;
 
 	p = bpf_rdonly_cast(0, 0);
-	if (p == 0)
+	if (!p)
 		/* make this a function call to avoid compiler
 		 * moving r0 assignment before check.
 		 */
-- 
2.43.5
Re: [PATCH -next] selftests/bpf: Fix warning comparing pointer to 0
Posted by Alexei Starovoitov 1 month, 4 weeks ago
On Wed, Aug 6, 2025 at 6:54 PM Jiapeng Chong
<jiapeng.chong@linux.alibaba.com> wrote:
>
> Avoid pointer type value compared with 0 to make code clear.
>
> ./tools/testing/selftests/bpf/progs/mem_rdonly_untrusted.c:221:10-11: WARNING comparing pointer to 0.
>
> Reported-by: Abaci Robot <abaci@linux.alibaba.com>

Hey Abaci folks,

stop sending this kind of patches.
Use your time for actual useful work instead of noise like this.

--
pw-bot: cr