LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH linux-next] x86:uaccess: fix boolreturn.cocci warnings
@ 2021-08-24  7:18 CGEL
  2021-08-25 19:30 ` Nick Desaulniers
  0 siblings, 1 reply; 2+ messages in thread
From: CGEL @ 2021-08-24  7:18 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Ingo Molnar, Borislav Petkov, x86, Michael Ellerman,
	Nick Desaulniers, Dan Williams, Uros Bizjak, linux-kernel,
	Jing Yangyang, Zeal Robot

From: Jing Yangyang <jing.yangyang@zte.com.cn>

./arch/x86/include/asm/uaccess.h:477:9-10:WARNING:return of 0/1 in
function 'user_access_begin' with return type bool

Return statements in functions returning bool should use true/false
instead of 1/0.

Generated by: scripts/coccinelle/misc/boolreturn.cocci

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Jing Yangyang <jing.yangyang@zte.com.cn>
---
 arch/x86/include/asm/uaccess.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
index c9fa7be..e3b6f4f 100644
--- a/arch/x86/include/asm/uaccess.h
+++ b/arch/x86/include/asm/uaccess.h
@@ -474,9 +474,9 @@ static inline bool __chk_range_not_ok(unsigned long addr, unsigned long size, un
 static __must_check __always_inline bool user_access_begin(const void __user *ptr, size_t len)
 {
 	if (unlikely(!access_ok(ptr,len)))
-		return 0;
+		return false;
 	__uaccess_begin_nospec();
-	return 1;
+	return true;
 }
 #define user_access_begin(a,b)	user_access_begin(a,b)
 #define user_access_end()	__uaccess_end()
-- 
1.8.3.1



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

* Re: [PATCH linux-next] x86:uaccess: fix boolreturn.cocci warnings
  2021-08-24  7:18 [PATCH linux-next] x86:uaccess: fix boolreturn.cocci warnings CGEL
@ 2021-08-25 19:30 ` Nick Desaulniers
  0 siblings, 0 replies; 2+ messages in thread
From: Nick Desaulniers @ 2021-08-25 19:30 UTC (permalink / raw)
  To: CGEL
  Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, x86,
	Michael Ellerman, Dan Williams, Uros Bizjak, linux-kernel,
	Jing Yangyang, Zeal Robot

On Tue, Aug 24, 2021 at 12:18 AM CGEL <cgel.zte@gmail.com> wrote:
>
> From: Jing Yangyang <jing.yangyang@zte.com.cn>
>
> ./arch/x86/include/asm/uaccess.h:477:9-10:WARNING:return of 0/1 in
> function 'user_access_begin' with return type bool
>
> Return statements in functions returning bool should use true/false
> instead of 1/0.
>
> Generated by: scripts/coccinelle/misc/boolreturn.cocci
>
> Reported-by: Zeal Robot <zealci@zte.com.cn>
> Signed-off-by: Jing Yangyang <jing.yangyang@zte.com.cn>

Fixes: 594cc251fdd0 ("make 'user_access_begin()' do 'access_ok()'")
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

> ---
>  arch/x86/include/asm/uaccess.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
> index c9fa7be..e3b6f4f 100644
> --- a/arch/x86/include/asm/uaccess.h
> +++ b/arch/x86/include/asm/uaccess.h
> @@ -474,9 +474,9 @@ static inline bool __chk_range_not_ok(unsigned long addr, unsigned long size, un
>  static __must_check __always_inline bool user_access_begin(const void __user *ptr, size_t len)
>  {
>         if (unlikely(!access_ok(ptr,len)))
> -               return 0;
> +               return false;
>         __uaccess_begin_nospec();
> -       return 1;
> +       return true;
>  }
>  #define user_access_begin(a,b) user_access_begin(a,b)
>  #define user_access_end()      __uaccess_end()
> --
> 1.8.3.1
>
>


-- 
Thanks,
~Nick Desaulniers

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

end of thread, other threads:[~2021-08-25 19:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-24  7:18 [PATCH linux-next] x86:uaccess: fix boolreturn.cocci warnings CGEL
2021-08-25 19:30 ` Nick Desaulniers

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