* [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; 7+ 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] 7+ messages in thread
* Re: [PATCH] selftests/bpf: Fix warning comparing pointer to 0
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
1 sibling, 1 reply; 7+ messages in thread
From: Martin KaFai Lau @ 2022-03-24 20:28 UTC (permalink / raw)
To: Haowen Bai
Cc: shuah, ast, daniel, andrii, songliubraving, yhs, john.fastabend,
kpsingh, linux-kselftest, netdev, bpf, linux-kernel
On Thu, Mar 24, 2022 at 10:08:45AM +0800, Haowen Bai wrote:
> Avoid pointer type value compared with 0 to make code clear.
Which compiler version that warns ?
I don't see it with the latest llvm-project from github.
The patch lgtm.
Acked-by: Martin KaFai Lau <kafai@fb.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* 答复: [PATCH] selftests/bpf: Fix warning comparing pointer to 0
2022-03-24 20:28 ` Martin KaFai Lau
@ 2022-03-25 1:15 ` 白浩文
0 siblings, 0 replies; 7+ messages in thread
From: 白浩文 @ 2022-03-25 1:15 UTC (permalink / raw)
To: Martin KaFai Lau
Cc: shuah, ast, daniel, andrii, songliubraving, yhs, john.fastabend,
kpsingh, linux-kselftest, netdev, bpf, linux-kernel
hi, kafai
./scripts/coccicheck report this warning.
________________________________________
发件人: Martin KaFai Lau <kafai@fb.com>
发送时间: 2022年3月25日 4:28:48
收件人: 白浩文
抄送: shuah@kernel.org; ast@kernel.org; daniel@iogearbox.net; andrii@kernel.org; songliubraving@fb.com; yhs@fb.com; john.fastabend@gmail.com; kpsingh@kernel.org; linux-kselftest@vger.kernel.org; netdev@vger.kernel.org; bpf@vger.kernel.org; linux-kernel@vger.kernel.org
主题: Re: [PATCH] selftests/bpf: Fix warning comparing pointer to 0
On Thu, Mar 24, 2022 at 10:08:45AM +0800, Haowen Bai wrote:
> Avoid pointer type value compared with 0 to make code clear.
Which compiler version that warns ?
I don't see it with the latest llvm-project from github.
The patch lgtm.
Acked-by: Martin KaFai Lau <kafai@fb.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] selftests/bpf: Fix warning comparing pointer to 0
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 19:55 ` Shuah Khan
2022-03-30 1:59 ` [PATCH V2] " Haowen Bai
1 sibling, 1 reply; 7+ messages in thread
From: Shuah Khan @ 2022-03-25 19:55 UTC (permalink / raw)
To: Haowen Bai, shuah, ast, daniel, andrii, kafai, songliubraving,
yhs, john.fastabend, kpsingh
Cc: linux-kselftest, netdev, bpf, linux-kernel, Shuah Khan
On 3/23/22 8:08 PM, Haowen Bai wrote:
> Avoid pointer type value compared with 0 to make code clear.
>
Patch looks good to me. Please include the error/warn message
in the commit log. This gives reviewers information on how
this problem is found.
> 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;
>
With the change to commit log including the error/warn message and
details on how the problems is found:
Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>
thanks,
-- Shuah
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH V2] selftests/bpf: Fix warning comparing pointer to 0
2022-03-25 19:55 ` Shuah Khan
@ 2022-03-30 1:59 ` Haowen Bai
2022-03-30 3:16 ` Yonghong Song
2022-03-30 13:30 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 7+ messages in thread
From: Haowen Bai @ 2022-03-30 1:59 UTC (permalink / raw)
To: Shuah Khan, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
KP Singh
Cc: Haowen Bai, linux-kselftest, netdev, bpf, linux-kernel
Avoid pointer type value compared with 0 to make code clear.
reported by coccicheck:
tools/testing/selftests/bpf/progs/map_ptr_kern.c:370:21-22:
WARNING comparing pointer to 0
tools/testing/selftests/bpf/progs/map_ptr_kern.c:397:21-22:
WARNING comparing pointer to 0
Signed-off-by: Haowen Bai <baihaowen@meizu.com>
---
V1->V2: include the error/warn message.
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] 7+ messages in thread
* Re: [PATCH V2] selftests/bpf: Fix warning comparing pointer to 0
2022-03-30 1:59 ` [PATCH V2] " Haowen Bai
@ 2022-03-30 3:16 ` Yonghong Song
2022-03-30 13:30 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 7+ messages in thread
From: Yonghong Song @ 2022-03-30 3:16 UTC (permalink / raw)
To: Haowen Bai, Shuah Khan, Alexei Starovoitov, Daniel Borkmann,
Andrii Nakryiko, Martin KaFai Lau, Song Liu, John Fastabend,
KP Singh
Cc: linux-kselftest, netdev, bpf, linux-kernel
On 3/29/22 6:59 PM, Haowen Bai wrote:
> Avoid pointer type value compared with 0 to make code clear.
>
> reported by coccicheck:
> tools/testing/selftests/bpf/progs/map_ptr_kern.c:370:21-22:
> WARNING comparing pointer to 0
> tools/testing/selftests/bpf/progs/map_ptr_kern.c:397:21-22:
> WARNING comparing pointer to 0
>
> Signed-off-by: Haowen Bai <baihaowen@meizu.com>
Acked-by: Yonghong Song <yhs@fb.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH V2] selftests/bpf: Fix warning comparing pointer to 0
2022-03-30 1:59 ` [PATCH V2] " Haowen Bai
2022-03-30 3:16 ` Yonghong Song
@ 2022-03-30 13:30 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 7+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-03-30 13:30 UTC (permalink / raw)
To: Haowen Bai
Cc: shuah, ast, daniel, andrii, kafai, songliubraving, yhs,
john.fastabend, kpsingh, linux-kselftest, netdev, bpf,
linux-kernel
Hello:
This patch was applied to bpf/bpf.git (master)
by Daniel Borkmann <daniel@iogearbox.net>:
On Wed, 30 Mar 2022 09:59:48 +0800 you wrote:
> Avoid pointer type value compared with 0 to make code clear.
>
> reported by coccicheck:
> tools/testing/selftests/bpf/progs/map_ptr_kern.c:370:21-22:
> WARNING comparing pointer to 0
> tools/testing/selftests/bpf/progs/map_ptr_kern.c:397:21-22:
> WARNING comparing pointer to 0
>
> [...]
Here is the summary with links:
- [V2] selftests/bpf: Fix warning comparing pointer to 0
https://git.kernel.org/bpf/bpf/c/2609f635a20d
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-03-30 13:30 UTC | newest]
Thread overview: 7+ 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
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).