Re: [v2, 06/21] powerpc: Avoid comparison of unsigned long >= 0 in __access_ok
From: Michael Ellerman
Date: Wed Mar 14 2018 - 05:28:55 EST
On Fri, 2018-03-02 at 19:50:51 UTC, Mathieu Malaterre wrote:
> Rewrite function-like macro into regular static inline function to avoid a
> warning during macro expansion.
> Fix warning (treated as error in W=1):
>
> CC arch/powerpc/kernel/signal_32.o
> In file included from ./include/linux/uaccess.h:14:0,
> from ./include/asm-generic/termios-base.h:8,
> from ./arch/powerpc/include/asm/termios.h:20,
> from ./include/uapi/linux/termios.h:6,
> from ./include/linux/tty.h:7,
> from arch/powerpc/kernel/signal_32.c:36:
> ./include/asm-generic/termios-base.h: In function â??user_termio_to_kernel_termiosâ??:
> ./arch/powerpc/include/asm/uaccess.h:52:35: error: comparison of unsigned expression >= 0 is always true [-Werror=type-limits]
> (((size) == 0) || (((size) - 1) <= ((segment).seg - (addr)))))
> ^
> ./arch/powerpc/include/asm/uaccess.h:58:3: note: in expansion of macro â??__access_okâ??
> __access_ok((__force unsigned long)(addr), (size), get_fs()))
> ^~~~~~~~~~~
> ./arch/powerpc/include/asm/uaccess.h:262:6: note: in expansion of macro â??access_okâ??
> if (access_ok(VERIFY_READ, __gu_addr, (size))) \
> ^~~~~~~~~
> ./arch/powerpc/include/asm/uaccess.h:80:2: note: in expansion of macro â??__get_user_checkâ??
> __get_user_check((x), (ptr), sizeof(*(ptr)))
> ^~~~~~~~~~~~~~~~
> ./include/asm-generic/termios-base.h:36:6: note: in expansion of macro â??get_userâ??
> if (get_user(termios->c_line, &termio->c_line) < 0)
> ^~~~~~~~
> [...]
> cc1: all warnings being treated as errors
>
> Suggested-by: Segher Boessenkool <segher@xxxxxxxxxxxxxxxxxxx>
> Signed-off-by: Mathieu Malaterre <malat@xxxxxxxxxx>
> Reviewed-by: Christophe Leroy <christophe.leroy@xxxxxx>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/ef85dffd4251ff6c23056651f6f83b
cheers