linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] selftests/bpf: Fix warning comparing pointer to 0
@ 2022-03-24  2:08 Haowen Bai
  2022-03-24 20:28 ` Martin KaFai Lau
  2022-03-25 19:55 ` Shuah Khan
  0 siblings, 2 replies; 19+ messages in thread
From: Haowen Bai @ 2022-03-24  2:08 UTC (permalink / raw)
  To: shuah, ast, daniel, andrii, kafai, songliubraving, yhs,
	john.fastabend, kpsingh
  Cc: linux-kselftest, netdev, bpf, linux-kernel, Haowen Bai

Avoid pointer type value compared with 0 to make code clear.

Signed-off-by: Haowen Bai <baihaowen@meizu.com>
---
 tools/testing/selftests/bpf/progs/map_ptr_kern.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/bpf/progs/map_ptr_kern.c b/tools/testing/selftests/bpf/progs/map_ptr_kern.c
index b64df94..db388f5 100644
--- a/tools/testing/selftests/bpf/progs/map_ptr_kern.c
+++ b/tools/testing/selftests/bpf/progs/map_ptr_kern.c
@@ -367,7 +367,7 @@ static inline int check_array_of_maps(void)
 
 	VERIFY(check_default(&array_of_maps->map, map));
 	inner_map = bpf_map_lookup_elem(array_of_maps, &key);
-	VERIFY(inner_map != 0);
+	VERIFY(inner_map != NULL);
 	VERIFY(inner_map->map.max_entries == INNER_MAX_ENTRIES);
 
 	return 1;
@@ -394,7 +394,7 @@ static inline int check_hash_of_maps(void)
 
 	VERIFY(check_default(&hash_of_maps->map, map));
 	inner_map = bpf_map_lookup_elem(hash_of_maps, &key);
-	VERIFY(inner_map != 0);
+	VERIFY(inner_map != NULL);
 	VERIFY(inner_map->map.max_entries == INNER_MAX_ENTRIES);
 
 	return 1;
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 19+ messages in thread
* [PATCH] selftests/bpf: fix warning comparing pointer to 0
@ 2021-04-22 10:00 Jiapeng Chong
  2021-04-22 21:56 ` Daniel Borkmann
  0 siblings, 1 reply; 19+ messages in thread
From: Jiapeng Chong @ 2021-04-22 10:00 UTC (permalink / raw)
  To: shuah
  Cc: ast, daniel, andrii, kafai, songliubraving, yhs, john.fastabend,
	kpsingh, linux-kselftest, netdev, bpf, linux-kernel,
	Jiapeng Chong

Fix the following coccicheck warning:

./tools/testing/selftests/bpf/progs/fentry_test.c:76:15-16: WARNING
comparing pointer to 0.

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
---
 tools/testing/selftests/bpf/progs/fentry_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/bpf/progs/fentry_test.c b/tools/testing/selftests/bpf/progs/fentry_test.c
index 52a550d..d4247d6 100644
--- a/tools/testing/selftests/bpf/progs/fentry_test.c
+++ b/tools/testing/selftests/bpf/progs/fentry_test.c
@@ -73,7 +73,7 @@ int BPF_PROG(test7, struct bpf_fentry_test_t *arg)
 SEC("fentry/bpf_fentry_test8")
 int BPF_PROG(test8, struct bpf_fentry_test_t *arg)
 {
-	if (arg->a == 0)
+	if (!arg->a)
 		test8_result = 1;
 	return 0;
 }
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread
* [PATCH] selftests/bpf: fix warning comparing pointer to 0
@ 2021-03-18  1:55 Jiapeng Chong
  2021-03-18 16:23 ` Daniel Borkmann
  0 siblings, 1 reply; 19+ messages in thread
From: Jiapeng Chong @ 2021-03-18  1:55 UTC (permalink / raw)
  To: shuah
  Cc: ast, daniel, andrii, kafai, songliubraving, yhs, john.fastabend,
	kpsingh, linux-kselftest, netdev, bpf, linux-kernel,
	Jiapeng Chong

Fix the following coccicheck warning:

./tools/testing/selftests/bpf/progs/fentry_test.c:76:15-16: WARNING
comparing pointer to 0.

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
---
 tools/testing/selftests/bpf/progs/fentry_test.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/bpf/progs/fentry_test.c b/tools/testing/selftests/bpf/progs/fentry_test.c
index 5f645fd..d4247d6 100644
--- a/tools/testing/selftests/bpf/progs/fentry_test.c
+++ b/tools/testing/selftests/bpf/progs/fentry_test.c
@@ -64,7 +64,7 @@ struct bpf_fentry_test_t {
 SEC("fentry/bpf_fentry_test7")
 int BPF_PROG(test7, struct bpf_fentry_test_t *arg)
 {
-	if (arg == 0)
+	if (!arg)
 		test7_result = 1;
 	return 0;
 }
@@ -73,7 +73,7 @@ int BPF_PROG(test7, struct bpf_fentry_test_t *arg)
 SEC("fentry/bpf_fentry_test8")
 int BPF_PROG(test8, struct bpf_fentry_test_t *arg)
 {
-	if (arg->a == 0)
+	if (!arg->a)
 		test8_result = 1;
 	return 0;
 }
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread
* [PATCH] selftests/bpf: fix warning comparing pointer to 0
@ 2021-03-16  7:59 Jiapeng Chong
  2021-03-16 23:00 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 19+ messages in thread
From: Jiapeng Chong @ 2021-03-16  7:59 UTC (permalink / raw)
  To: shuah
  Cc: ast, daniel, andrii, kafai, songliubraving, yhs, john.fastabend,
	kpsingh, linux-kselftest, netdev, bpf, linux-kernel,
	Jiapeng Chong

Fix the following coccicheck warning:

./tools/testing/selftests/bpf/progs/fexit_test.c:77:15-16: WARNING
comparing pointer to 0.

./tools/testing/selftests/bpf/progs/fexit_test.c:68:12-13: WARNING
comparing pointer to 0.

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
---
 tools/testing/selftests/bpf/progs/fexit_test.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/bpf/progs/fexit_test.c b/tools/testing/selftests/bpf/progs/fexit_test.c
index 0952aff..8f1ccb7 100644
--- a/tools/testing/selftests/bpf/progs/fexit_test.c
+++ b/tools/testing/selftests/bpf/progs/fexit_test.c
@@ -65,7 +65,7 @@ struct bpf_fentry_test_t {
 SEC("fexit/bpf_fentry_test7")
 int BPF_PROG(test7, struct bpf_fentry_test_t *arg)
 {
-	if (arg == 0)
+	if (!arg)
 		test7_result = 1;
 	return 0;
 }
@@ -74,7 +74,7 @@ int BPF_PROG(test7, struct bpf_fentry_test_t *arg)
 SEC("fexit/bpf_fentry_test8")
 int BPF_PROG(test8, struct bpf_fentry_test_t *arg)
 {
-	if (arg->a == 0)
+	if (!arg->a)
 		test8_result = 1;
 	return 0;
 }
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread
* [PATCH] selftests/bpf: fix warning comparing pointer to 0
@ 2021-03-10  6:22 Jiapeng Chong
  2021-03-10  9:31 ` Yauheni Kaliuta
  2021-03-10 22:00 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 19+ messages in thread
From: Jiapeng Chong @ 2021-03-10  6:22 UTC (permalink / raw)
  To: shuah
  Cc: ast, daniel, andrii, kafai, songliubraving, yhs, john.fastabend,
	kpsingh, linux-kselftest, netdev, bpf, linux-kernel,
	Jiapeng Chong

Fix the following coccicheck warning:

./tools/testing/selftests/bpf/progs/test_global_func10.c:17:12-13:
WARNING comparing pointer to 0.

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
---
 tools/testing/selftests/bpf/progs/test_global_func10.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/bpf/progs/test_global_func10.c b/tools/testing/selftests/bpf/progs/test_global_func10.c
index 61c2ae9..97b7031 100644
--- a/tools/testing/selftests/bpf/progs/test_global_func10.c
+++ b/tools/testing/selftests/bpf/progs/test_global_func10.c
@@ -14,7 +14,7 @@ struct Big {
 
 __noinline int foo(const struct Big *big)
 {
-	if (big == 0)
+	if (!big)
 		return 0;
 
 	return bpf_get_prandom_u32() < big->y;
-- 
1.8.3.1


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

end of thread, other threads:[~2022-03-30 13:30 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-24  2:08 [PATCH] selftests/bpf: Fix warning comparing pointer to 0 Haowen Bai
2022-03-24 20:28 ` Martin KaFai Lau
2022-03-25  1:15   ` 答复: " 白浩文
2022-03-25 19:55 ` Shuah Khan
2022-03-30  1:59   ` [PATCH V2] " Haowen Bai
2022-03-30  3:16     ` Yonghong Song
2022-03-30 13:30     ` patchwork-bot+netdevbpf
  -- strict thread matches above, loose matches on Subject: below --
2021-04-22 10:00 [PATCH] selftests/bpf: fix " Jiapeng Chong
2021-04-22 21:56 ` Daniel Borkmann
2021-04-23 11:57   ` Abaci Robot
2021-04-23 16:47     ` Alexei Starovoitov
2021-03-18  1:55 Jiapeng Chong
2021-03-18 16:23 ` Daniel Borkmann
2021-04-22  8:09   ` Jiapeng Chong
2021-03-16  7:59 Jiapeng Chong
2021-03-16 23:00 ` patchwork-bot+netdevbpf
2021-03-10  6:22 Jiapeng Chong
2021-03-10  9:31 ` Yauheni Kaliuta
2021-03-10 22:00 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).