bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [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; 15+ 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	[flat|nested] 15+ messages in thread

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

On 4/22/21 12:00 PM, Jiapeng Chong wrote:
> 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>

How many more of those 'comparing pointer to 0' patches do you have?
Right now we already merged the following with similar trivial pattern:

  - ebda107e5f222a086c83ddf6d1ab1da97dd15810
  - a9c80b03e586fd3819089fbd33c38fb65ad5e00c
  - 04ea63e34a2ee85cfd38578b3fc97b2d4c9dd573

Given they don't really 'fix' anything, I would like to reduce such
patch cleanup churn on the bpf tree. Please _consolidate_ all other
such occurrences into a _single_ patch for BPF selftests, and resubmit.

Thanks!

> ---
>   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;
>   }
> 


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

* Re: [PATCH] selftests/bpf: fix warning comparing pointer to 0
  2021-04-22 21:56 ` Daniel Borkmann
@ 2021-04-23 11:57   ` Abaci Robot
  2021-04-23 16:47     ` Alexei Starovoitov
  0 siblings, 1 reply; 15+ messages in thread
From: Abaci Robot @ 2021-04-23 11:57 UTC (permalink / raw)
  To: Daniel Borkmann, Jiapeng Chong; +Cc: linux-kselftest, netdev, bpf, linux-kernel

在 2021/4/23 上午5:56, Daniel Borkmann 写道:
> On 4/22/21 12:00 PM, Jiapeng Chong wrote:
>> 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>
> 
> How many more of those 'comparing pointer to 0' patches do you have?
> Right now we already merged the following with similar trivial pattern:
> 
> - ebda107e5f222a086c83ddf6d1ab1da97dd15810
> - a9c80b03e586fd3819089fbd33c38fb65ad5e00c
> - 04ea63e34a2ee85cfd38578b3fc97b2d4c9dd573
> 
> Given they don't really 'fix' anything, I would like to reduce such
> patch cleanup churn on the bpf tree. Please _consolidate_ all other
> such occurrences into a _single_ patch for BPF selftests, and resubmit.
> 
> Thanks!
> 
>> ---
>>   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;
>>   }
>>

Hi,

Thanks for your reply.

TLDR:
1. Now all this kind of warning in tools/testing/selftests/bpf/progs/ 
were reported and discussed except this one.
2. We might not do scanning and check reports on 
tools/testing/selftests/bpf/progs/ in the future, because some 
contributors want the progs to stay as close as possible to the way they 
were written. 
(https://patchwork.kernel.org/project/linux-kselftest/patch/1618307549-78149-1-git-send-email-yang.lee@linux.alibaba.com/)


Details:

We have checked the recent linux master (commit: 
16fc44d6387e260f4932e9248b985837324705d8), and the related reports and 
their current status is shown as follows:

./tools/testing/selftests/bpf/progs/fentry_test.c:67:12-13: WARNING 
comparing pointer to 0
(not appear in the bpf-next branch)


./tools/testing/selftests/bpf/progs/fentry_test.c:76:15-16: WARNING 
comparing pointer to 0
(the above patch try to eliminate it)


./tools/testing/selftests/bpf/progs/fexit_test.c:68:12-13: WARNING 
comparing pointer to 0
./tools/testing/selftests/bpf/progs/fexit_test.c:77:15-16: WARNING 
comparing pointer to 0
(eliminated in 
https://kernel.source.codeaurora.cn/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=ebda107e5f222a086c83ddf6d1ab1da97dd15810)

./tools/testing/selftests/bpf/progs/profiler.inc.h:364:18-22: WARNING 
comparing pointer to 0
./tools/testing/selftests/bpf/progs/profiler.inc.h:364:18-22: WARNING 
comparing pointer to 0, suggest !E
./tools/testing/selftests/bpf/progs/profiler.inc.h:537:23-27: WARNING 
comparing pointer to 0
./tools/testing/selftests/bpf/progs/profiler.inc.h:537:23-27: WARNING 
comparing pointer to 0, suggest !E
./tools/testing/selftests/bpf/progs/profiler.inc.h:544:21-25: WARNING 
comparing pointer to 0
./tools/testing/selftests/bpf/progs/profiler.inc.h:544:21-25: WARNING 
comparing pointer to 0, suggest !E
./tools/testing/selftests/bpf/progs/profiler.inc.h:692:29-33: WARNING 
comparing pointer to 0
./tools/testing/selftests/bpf/progs/profiler.inc.h:770:13-17: WARNING 
comparing pointer to 0
(Discussed in 
https://patchwork.kernel.org/project/linux-kselftest/patch/1618307549-78149-1-git-send-email-yang.lee@linux.alibaba.com/)

./tools/testing/selftests/bpf/progs/test_global_func10.c:17:12-13: 
WARNING comparing pointer to 0
(cleanup in 
https://kernel.source.codeaurora.cn/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=04ea63e34a2ee85cfd38578b3fc97b2d4c9dd573)

Thanks.

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

* Re: [PATCH] selftests/bpf: fix warning comparing pointer to 0
  2021-04-23 11:57   ` Abaci Robot
@ 2021-04-23 16:47     ` Alexei Starovoitov
  0 siblings, 0 replies; 15+ messages in thread
From: Alexei Starovoitov @ 2021-04-23 16:47 UTC (permalink / raw)
  To: Abaci Robot
  Cc: Daniel Borkmann, Jiapeng Chong,
	open list:KERNEL SELFTEST FRAMEWORK, Network Development, bpf,
	LKML

On Fri, Apr 23, 2021 at 4:57 AM Abaci Robot <abaci@linux.alibaba.com> wrote:
>
> 在 2021/4/23 上午5:56, Daniel Borkmann 写道:
> > On 4/22/21 12:00 PM, Jiapeng Chong wrote:
> >> 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>
> >
> > How many more of those 'comparing pointer to 0' patches do you have?
> > Right now we already merged the following with similar trivial pattern:
> >
> > - ebda107e5f222a086c83ddf6d1ab1da97dd15810
> > - a9c80b03e586fd3819089fbd33c38fb65ad5e00c
> > - 04ea63e34a2ee85cfd38578b3fc97b2d4c9dd573
> >
> > Given they don't really 'fix' anything, I would like to reduce such
> > patch cleanup churn on the bpf tree. Please _consolidate_ all other
> > such occurrences into a _single_ patch for BPF selftests, and resubmit.
> >
> > Thanks!
> >
> >> ---
> >>   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;
> >>   }
> >>
>
> Hi,
>
> Thanks for your reply.
>
> TLDR:
> 1. Now all this kind of warning in tools/testing/selftests/bpf/progs/
> were reported and discussed except this one.
> 2. We might not do scanning and check reports on
> tools/testing/selftests/bpf/progs/ in the future,

please stop such scans in selftests/bpf.
I don't see any value in such patches.

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

* Re: [PATCH] selftests/bpf: Fix warning comparing pointer to 0
  2022-03-24  2:08 [PATCH] selftests/bpf: Fix " Haowen Bai
  2022-03-24 20:28 ` Martin KaFai Lau
@ 2022-03-25 19:55 ` Shuah Khan
  1 sibling, 0 replies; 15+ 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] 15+ messages in thread

* Re: [PATCH] selftests/bpf: Fix warning comparing pointer to 0
  2022-03-24  2:08 [PATCH] selftests/bpf: Fix " Haowen Bai
@ 2022-03-24 20:28 ` Martin KaFai Lau
  2022-03-25 19:55 ` Shuah Khan
  1 sibling, 0 replies; 15+ 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] 15+ messages in thread

* [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; 15+ 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	[flat|nested] 15+ messages in thread

* Re: [PATCH] selftests/bpf: fix warning comparing pointer to 0
  2021-03-18 16:23 ` Daniel Borkmann
@ 2021-04-22  8:09   ` Jiapeng Chong
  0 siblings, 0 replies; 15+ messages in thread
From: Jiapeng Chong @ 2021-04-22  8:09 UTC (permalink / raw)
  To: Daniel Borkmann; +Cc: linux-kselftest, netdev, bpf, linux-kernel

On 2021/3/19 0:23, Daniel Borkmann wrote:
> On 3/18/21 2:55 AM, Jiapeng Chong wrote:
>> 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;
>>   }
>>
> 
> This doesn't apply. Please rebase against bpf-next tree, and also make 
> sure to
> squash any other such patches into a single one.

OK, I'll submit it to the latest branch bpf-next tree later.

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

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

On 3/18/21 2:55 AM, Jiapeng Chong wrote:
> 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;
>   }
> 

This doesn't apply. Please rebase against bpf-next tree, and also make sure to
squash any other such patches into a single one.

^ permalink raw reply	[flat|nested] 15+ 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; 15+ 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	[flat|nested] 15+ messages in thread

* Re: [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, 0 replies; 15+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-03-16 23:00 UTC (permalink / raw)
  To: Jiapeng Chong
  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-next.git (refs/heads/master):

On Tue, 16 Mar 2021 15:59:37 +0800 you wrote:
> 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.
> 
> [...]

Here is the summary with links:
  - selftests/bpf: fix warning comparing pointer to 0
    https://git.kernel.org/bpf/bpf-next/c/ebda107e5f22

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] 15+ 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; 15+ 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	[flat|nested] 15+ messages in thread

* Re: [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
  1 sibling, 0 replies; 15+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-03-10 22:00 UTC (permalink / raw)
  To: Jiapeng Chong
  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-next.git (refs/heads/master):

On Wed, 10 Mar 2021 14:22:46 +0800 you wrote:
> 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>
> 
> [...]

Here is the summary with links:
  - selftests/bpf: fix warning comparing pointer to 0
    https://git.kernel.org/bpf/bpf-next/c/04ea63e34a2e

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] 15+ messages in thread

* Re: [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
  1 sibling, 0 replies; 15+ messages in thread
From: Yauheni Kaliuta @ 2021-03-10  9:31 UTC (permalink / raw)
  To: Jiapeng Chong
  Cc: shuah, Alexei Starovoitov, Daniel Borkmann, andrii,
	Martin KaFai Lau, Song Liu, Yonghong Song, john.fastabend,
	kpsingh, open list:KERNEL SELFTEST FRAMEWORK, netdev, bpf, LKML

On Wed, Mar 10, 2021 at 8:23 AM Jiapeng Chong
<jiapeng.chong@linux.alibaba.com> wrote:
>
> Fix the following coccicheck warning:
>
> ./tools/testing/selftests/bpf/progs/test_global_func10.c:17:12-13:
> WARNING comparing pointer to 0.

but it's ok from the C standard point of view

>
> 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
>


-- 
WBR, Yauheni


^ permalink raw reply	[flat|nested] 15+ 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; 15+ 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	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2022-03-25 20:02 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-22 10:00 [PATCH] selftests/bpf: fix warning comparing pointer to 0 Jiapeng Chong
2021-04-22 21:56 ` Daniel Borkmann
2021-04-23 11:57   ` Abaci Robot
2021-04-23 16:47     ` Alexei Starovoitov
  -- strict thread matches above, loose matches on Subject: below --
2022-03-24  2:08 [PATCH] selftests/bpf: Fix " Haowen Bai
2022-03-24 20:28 ` Martin KaFai Lau
2022-03-25 19:55 ` Shuah Khan
2021-03-18  1:55 [PATCH] selftests/bpf: fix " 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).