powerpc: Avoid comparison of unsigned long >= 0 in __access_ok()
authorMathieu Malaterre <malat@debian.org>
Fri, 2 Mar 2018 19:50:51 +0000 (20:50 +0100)
committerMichael Ellerman <mpe@ellerman.id.au>
Tue, 13 Mar 2018 04:50:41 +0000 (15:50 +1100)
Rewrite function-like macro into regular static inline function to
avoid a warning during macro expansion.

Fix warning (treated as error in W=1):
./arch/powerpc/include/asm/uaccess.h:52:35: error: comparison of unsigned expression >= 0 is always true
   (((size) == 0) || (((size) - 1) <= ((segment).seg - (addr)))))
                                   ^

Suggested-by: Segher Boessenkool <segher@kernel.crashing.org>
Signed-off-by: Mathieu Malaterre <malat@debian.org>
Reviewed-by: Christophe Leroy <christophe.leroy@c-s.fr>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/include/asm/uaccess.h

index 51bfeb8777f065d843c0b0c1eb1cf910d7bbaaf3..a62ee663b2c834b22519ec1f88b6e557e8ac4f76 100644 (file)
 
 #else
 
-#define __access_ok(addr, size, segment)       \
-       (((addr) <= (segment).seg) &&           \
-        (((size) == 0) || (((size) - 1) <= ((segment).seg - (addr)))))
+static inline int __access_ok(unsigned long addr, unsigned long size,
+                       mm_segment_t seg)
+{
+       if (addr > seg.seg)
+               return 0;
+       return (size == 0 || size - 1 <= seg.seg - addr);
+}
 
 #endif