The patch titled Subject: asm-generic: fix -Wtype-limits compiler warnings has been added to the -mm tree. Its filename is asm-generic-fix-wtype-limits-compiler-warnings.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/asm-generic-fix-wtype-limits-compiler-warnings.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/asm-generic-fix-wtype-limits-compiler-warnings.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Qian Cai <cai@xxxxxx> Subject: asm-generic: fix -Wtype-limits compiler warnings The commit d66acc39c7ce ("bitops: Optimise get_order()") introduced a compilation warning because "rx_frag_size" is an "ushort" while PAGE_SHIFT here is 16. The commit changed the get_order() to be a multi-line macro where compilers insist to check all statements in the macro even when __builtin_constant_p(rx_frag_size) will return false as "rx_frag_size" is a module parameter. In file included from ./arch/powerpc/include/asm/page_64.h:107, from ./arch/powerpc/include/asm/page.h:242, from ./arch/powerpc/include/asm/mmu.h:132, from ./arch/powerpc/include/asm/lppaca.h:47, from ./arch/powerpc/include/asm/paca.h:17, from ./arch/powerpc/include/asm/current.h:13, from ./include/linux/thread_info.h:21, from ./arch/powerpc/include/asm/processor.h:39, from ./include/linux/prefetch.h:15, from drivers/net/ethernet/emulex/benet/be_main.c:14: drivers/net/ethernet/emulex/benet/be_main.c: In function 'be_rx_cqs_create': ./include/asm-generic/getorder.h:54:9: warning: comparison is always true due to limited range of data type [-Wtype-limits] (((n) < (1UL << PAGE_SHIFT)) ? 0 : \ ^ drivers/net/ethernet/emulex/benet/be_main.c:3138:33: note: in expansion of macro 'get_order' adapter->big_page_size = (1 << get_order(rx_frag_size)) * PAGE_SIZE; ^~~~~~~~~ Fix it by moving almost all of this multi-line macro into a proper function __get_order(), and leave get_order() as a single-line macro in order to avoid compilation errors. Link: http://lkml.kernel.org/r/1563914986-26502-1-git-send-email-cai@xxxxxx Fixes: d66acc39c7ce ("bitops: Optimise get_order()") Signed-off-by: Qian Cai <cai@xxxxxx> Cc: David S. Miller <davem@xxxxxxxxxxxxx> Cc: Arnd Bergmann <arnd@xxxxxxxx> Cc: David Howells <dhowells@xxxxxxxxxx> Cc: Jakub Jelinek <jakub@xxxxxxxxxx> Cc: Nick Desaulniers <ndesaulniers@xxxxxxxxxx> Cc: Bill Wendling <morbo@xxxxxxxxxx> Cc: James Y Knight <jyknight@xxxxxxxxxx> Cc: Nathan Chancellor <natechancellor@xxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- include/asm-generic/getorder.h | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) --- a/include/asm-generic/getorder.h~asm-generic-fix-wtype-limits-compiler-warnings +++ a/include/asm-generic/getorder.h @@ -15,6 +15,16 @@ int __get_order(unsigned long size) { int order; + if (__builtin_constant_p(size)) { + if (!size) + return BITS_PER_LONG - PAGE_SHIFT; + + if (size < (1UL << PAGE_SHIFT)) + return 0; + + return ilog2((size) - 1) - PAGE_SHIFT + 1; + } + size--; size >>= PAGE_SHIFT; #if BITS_PER_LONG == 32 @@ -49,11 +59,6 @@ int __get_order(unsigned long size) */ #define get_order(n) \ ( \ - __builtin_constant_p(n) ? ( \ - ((n) == 0UL) ? BITS_PER_LONG - PAGE_SHIFT : \ - (((n) < (1UL << PAGE_SHIFT)) ? 0 : \ - ilog2((n) - 1) - PAGE_SHIFT + 1) \ - ) : \ __get_order(n) \ ) _ Patches currently in -mm which might be from cai@xxxxxx are asm-generic-fix-wtype-limits-compiler-warnings.patch