Skip to contentSkip to conversation

powerpc32: fix warning from include/asm-generic/termios-base.h

PATCH In review Christophe Leroy 2 participants 2 messages Dec 5, 2014 – Mar 21, 2015 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc32: fix warning from include/asm-generic/termios-base.h

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 ||
      ^
---
 arch/powerpc/include/asm/uaccess.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/include/asm/uaccess.h +1 -1
index 9485b43..f3028d2 100644
@@ -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
 
Signature · 1 line
2.1.0
#1 lore raw
Quoted 22 lines · LEROY Christophe

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 ||
      ^
---
 arch/powerpc/include/asm/uaccess.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/include/asm/uaccess.h +0 -0
index 9485b43..f3028d2 100644

arch/powerpc/include/asm/uaccess.h line 57

Quoted 5 lines
arch/powerpc/include/asm/uaccess.h +1 -1
@@ -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