linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nathan Chancellor <natechancellor@gmail.com>
To: Qian Cai <cai@lca.pw>
Cc: akpm@linux-foundation.org, davem@davemloft.net, arnd@arndb.de,
	dhowells@redhat.com, jakub@redhat.com, ndesaulniers@google.com,
	morbo@google.com, jyknight@google.com,
	linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] asm-generic: fix -Wtype-limits compiler warnings
Date: Tue, 23 Jul 2019 19:29:36 -0700	[thread overview]
Message-ID: <20190724022936.GA73305@archlinux-threadripper> (raw)
Message-ID: <20190724022936.ID1Ni90nBEkBsOTQ-r58X44F7V6nbzu5Oj1sEs72yx8@z> (raw)
In-Reply-To: <1563914986-26502-1-git-send-email-cai@lca.pw>

On Tue, Jul 23, 2019 at 04:49:46PM -0400, Qian Cai wrote:
> 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.

Wouldn't it just be better to rename __get_order to get_order?

> Fixes: d66acc39c7ce ("bitops: Optimise get_order()")
> Signed-off-by: Qian Cai <cai@lca.pw>

Other than that, LGTM.

Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>

  parent reply	other threads:[~2019-07-24  2:29 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-23 20:49 [PATCH] asm-generic: fix -Wtype-limits compiler warnings Qian Cai
2019-07-23 20:49 ` Qian Cai
2019-07-23 21:27 ` Andrew Morton
2019-07-23 21:27   ` Andrew Morton
2019-07-24  2:29 ` Nathan Chancellor [this message]
2019-07-24  2:29   ` Nathan Chancellor
2019-07-24  7:49 ` David Howells
2019-07-24  7:49   ` David Howells
2019-07-24 18:45   ` Qian Cai
2019-07-24 18:45     ` Qian Cai
2019-07-24 21:49   ` David Howells
2019-07-24 21:49     ` David Howells
2019-07-25  3:22     ` Qian Cai
2019-07-25  3:22       ` Qian Cai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190724022936.GA73305@archlinux-threadripper \
    --to=natechancellor@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=cai@lca.pw \
    --cc=davem@davemloft.net \
    --cc=dhowells@redhat.com \
    --cc=jakub@redhat.com \
    --cc=jyknight@google.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=morbo@google.com \
    --cc=ndesaulniers@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).