LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] powerpc32: fix warning from include/asm-generic/termios-base.h
@ 2014-12-05 11:20 Christophe Leroy
  2015-03-21  0:01 ` Scott Wood
  0 siblings, 1 reply; 2+ messages in thread
From: Christophe Leroy @ 2014-12-05 11:20 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, scottwood
  Cc: linux-kernel, linuxppc-dev

When size is equal to 1, the test is always true so lets eliminate both 0 and 1
at first.

include/asm-generic/termios-base.h: In function 'user_termio_to_kernel_termios':
include/asm-generic/termios-base.h:35:2: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]
  if (get_user(termios->c_line, &termio->c_line) < 0)
  ^
include/asm-generic/termios-base.h: In function 'kernel_termios_to_user_termio':
include/asm-generic/termios-base.h:57:6: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]
      put_user(termios->c_line,  &termio->c_line) < 0 ||
      ^

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>

---
 arch/powerpc/include/asm/uaccess.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
index 9485b43..f3028d2 100644
--- a/arch/powerpc/include/asm/uaccess.h
+++ b/arch/powerpc/include/asm/uaccess.h
@@ -54,7 +54,7 @@
 
 #define __access_ok(addr, size, segment)	\
 	(((addr) <= (segment).seg) &&		\
-	 (((size) == 0) || (((size) - 1) <= ((segment).seg - (addr)))))
+	 (((size) <= 1) || (((size) - 1) <= ((segment).seg - (addr)))))
 
 #endif
 
-- 
2.1.0


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

* Re: powerpc32: fix warning from include/asm-generic/termios-base.h
  2014-12-05 11:20 [PATCH] powerpc32: fix warning from include/asm-generic/termios-base.h Christophe Leroy
@ 2015-03-21  0:01 ` Scott Wood
  0 siblings, 0 replies; 2+ messages in thread
From: Scott Wood @ 2015-03-21  0:01 UTC (permalink / raw)
  To: LEROY Christophe
  Cc: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	linuxppc-dev, linux-kernel

On Fri, Dec 05, 2014 at 12:20:25PM +0100, LEROY Christophe wrote:
> When size is equal to 1, the test is always true so lets eliminate both 0 and 1
> at first.
> 
> include/asm-generic/termios-base.h: In function 'user_termio_to_kernel_termios':
> include/asm-generic/termios-base.h:35:2: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]
>   if (get_user(termios->c_line, &termio->c_line) < 0)
>   ^
> include/asm-generic/termios-base.h: In function 'kernel_termios_to_user_termio':
> include/asm-generic/termios-base.h:57:6: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]
>       put_user(termios->c_line,  &termio->c_line) < 0 ||
>       ^
> 
> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
> ---
>  arch/powerpc/include/asm/uaccess.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
> index 9485b43..f3028d2 100644
> --- a/arch/powerpc/include/asm/uaccess.h
> +++ b/arch/powerpc/include/asm/uaccess.h
> @@ -54,7 +54,7 @@
>  
>  #define __access_ok(addr, size, segment)	\
>  	(((addr) <= (segment).seg) &&		\
> -	 (((size) == 0) || (((size) - 1) <= ((segment).seg - (addr)))))
> +	 (((size) <= 1) || (((size) - 1) <= ((segment).seg - (addr)))))

Again, I don't think Linux enables this warning.  What did you do to
produce this?  In any case, it's a bad warning that doesn't take macros
into account, and the answer is not to make the code less clear by hiding
the fact that zero is a special case.

-Scott

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

end of thread, other threads:[~2015-03-21  0:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-05 11:20 [PATCH] powerpc32: fix warning from include/asm-generic/termios-base.h Christophe Leroy
2015-03-21  0:01 ` Scott Wood

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