2020-04-15 08:31:18

by Zou Wei

[permalink] [raw]
Subject: [PATCH -next] mm/usercopy: fix warning Comparison to bool

fix below warnings reported by coccicheck

mm/usercopy.c:304:5-18: WARNING: Comparison to bool

Reported-by: Hulk Robot <[email protected]>
Signed-off-by: Zou Wei <[email protected]>
---
mm/usercopy.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/usercopy.c b/mm/usercopy.c
index 660717a..04346cf 100644
--- a/mm/usercopy.c
+++ b/mm/usercopy.c
@@ -301,7 +301,7 @@ __setup("hardened_usercopy=", parse_hardened_usercopy);

static int __init set_hardened_usercopy(void)
{
- if (enable_checks == false)
+ if (!enable_checks)
static_branch_enable(&bypass_usercopy_checks);
return 1;
}
--
2.6.2


2020-04-16 01:15:33

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH -next] mm/usercopy: fix warning Comparison to bool

On Tue, 14 Apr 2020 11:42:04 +0800 Zou Wei <[email protected]> wrote:

> fix below warnings reported by coccicheck
>
> mm/usercopy.c:304:5-18: WARNING: Comparison to bool
>
> ...
>
> --- a/mm/usercopy.c
> +++ b/mm/usercopy.c
> @@ -301,7 +301,7 @@ __setup("hardened_usercopy=", parse_hardened_usercopy);
>
> static int __init set_hardened_usercopy(void)
> {
> - if (enable_checks == false)
> + if (!enable_checks)
> static_branch_enable(&bypass_usercopy_checks);
> return 1;
> }

My initial reaction is "fix coccicheck". There's nothing wrong with
that code?

2020-04-16 11:08:23

by Zou Wei

[permalink] [raw]
Subject: 答复: [PATCH -next] mm/usercopy: fix warning Comparison to bool

Hi Andrew,

Thanks for your reply.
Perhaps this is a detection rule of Coccinelle (coccicheck) software for programming specifications,
and it's no wrong with the code, just a coding style.

Best Regards
Zou Wei
-----?ʼ?ԭ??-----
??????: Andrew Morton [mailto:[email protected]]
????ʱ??: 2020??4??16?? 7:05
?ռ???: Zouwei (Samuel) <[email protected]>
????: [email protected]; [email protected]
????: Re: [PATCH -next] mm/usercopy: fix warning Comparison to bool

On Tue, 14 Apr 2020 11:42:04 +0800 Zou Wei <[email protected]> wrote:

> fix below warnings reported by coccicheck
>
> mm/usercopy.c:304:5-18: WARNING: Comparison to bool
>
> ...
>
> --- a/mm/usercopy.c
> +++ b/mm/usercopy.c
> @@ -301,7 +301,7 @@ __setup("hardened_usercopy=",
> parse_hardened_usercopy);
>
> static int __init set_hardened_usercopy(void) {
> - if (enable_checks == false)
> + if (!enable_checks)
> static_branch_enable(&bypass_usercopy_checks);
> return 1;
> }

My initial reaction is "fix coccicheck". There's nothing wrong with that code?

2020-04-16 11:27:41

by David Hildenbrand

[permalink] [raw]
Subject: Re: 答复: [PATCH -next] mm/usercopy: fix warning Comparison to bool

On 16.04.20 12:45, Zouwei (Samuel) wrote:
> Hi Andrew,
>
> Thanks for your reply.
> Perhaps this is a detection rule of Coccinelle (coccicheck) software for programming specifications,
> and it's no wrong with the code, just a coding style.

Then it's not an actual fix and the subject is misleading.

--
Thanks,

David / dhildenb