mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH -next] selftests/bpf: Fix warning comparing pointer to 0
@ 2025-08-07  1:54 Jiapeng Chong
  2025-08-07  1:57 ` Alexei Starovoitov
  0 siblings, 1 reply; 2+ messages in thread
From: Jiapeng Chong @ 2025-08-07  1:54 UTC (permalink / raw)
  To: ast
  Cc: daniel, andrii, martin.lau, eddyz87, song, yonghong.song,
	john.fastabend, kpsingh, sdf, haoluo, jolsa, mykolal, shuah, bpf,
	linux-kselftest, linux-kernel, Jiapeng Chong, Abaci Robot

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-08-07  1:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-08-07  1:54 [PATCH -next] selftests/bpf: Fix warning comparing pointer to 0 Jiapeng Chong
2025-08-07  1:57 ` Alexei Starovoitov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®