public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: Arnd Bergmann <arnd@kernel.org>
Cc: Doug Ledford <dledford@redhat.com>,
	Shamir Rabinovitch <shamir.rabinovitch@oracle.com>,
	Arnd Bergmann <arnd@arndb.de>, Leon Romanovsky <leon@kernel.org>,
	Yishai Hadas <yishaih@mellanox.com>,
	Michael Guralnik <michaelgur@mellanox.com>,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>,
	<linux-rdma@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] IB/verbs: avoid nested container_of()
Date: Wed, 28 Oct 2020 10:30:48 -0300	[thread overview]
Message-ID: <20201028133048.GA2406668@nvidia.com> (raw)
In-Reply-To: <20201026161549.3709175-1-arnd@kernel.org>

On Mon, Oct 26, 2020 at 05:15:39PM +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> Nested container_of() calls work correctly but cause a warning when
> building with W=2. Invoking it from an inline function like in
> drivers/infiniband/hw/mlx5/mlx5_ib.h means we get hundreds of
> warnings like:
> 
> include/linux/kernel.h:852:8: warning: declaration of '__mptr' shadows a previous local [-Wshadow]
>   852 |  void *__mptr = (void *)(ptr);     \
>       |        ^~~~~~
> include/rdma/uverbs_ioctl.h:651:11: note: in expansion of macro 'container_of'
>   651 |  (udata ? container_of(container_of(udata, struct uverbs_attr_bundle,   \
>       |           ^~~~~~~~~~~~
> include/rdma/uverbs_ioctl.h:651:24: note: in expansion of macro 'container_of'
>   651 |  (udata ? container_of(container_of(udata, struct uverbs_attr_bundle,   \
>       |                        ^~~~~~~~~~~~
> drivers/infiniband/hw/mthca/mthca_qp.c:564:35: note: in expansion of macro 'rdma_udata_to_drv_context'
>   564 |  struct mthca_ucontext *context = rdma_udata_to_drv_context(
>       |                                   ^~~~~~~~~~~~~~~~~~~~~~~~~
> include/linux/kernel.h:852:8: note: shadowed declaration is here
>   852 |  void *__mptr = (void *)(ptr);     \
>       |        ^~~~~~
> include/rdma/uverbs_ioctl.h:651:11: note: in expansion of macro 'container_of'
>   651 |  (udata ? container_of(container_of(udata, struct uverbs_attr_bundle,   \
>       |           ^~~~~~~~~~~~
> drivers/infiniband/hw/mthca/mthca_qp.c:564:35: note: in expansion of macro 'rdma_udata_to_drv_context'
>   564 |  struct mthca_ucontext *context = rdma_udata_to_drv_context(
>       |                                   ^~~~~~~~~~~~~~~~~~~~~~~~~
> In file included from <command-line>:
> include/linux/kernel.h:852:8: warning: declaration of '__mptr' shadows a previous local [-Wshadow]
>   852 |  void *__mptr = (void *)(ptr);     \
>       |        ^~~~~~
> 
> Rewrite the macro to use an inline function internally, which makes
> it more readable and reduces the amount of useless output from
> make W=2.
> 
> Fixes: 730623f4a56f ("IB/verbs: Add helper function rdma_udata_to_drv_context")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  include/rdma/uverbs_ioctl.h | 15 +++++++++------
>  1 file changed, 9 insertions(+), 6 deletions(-)

Applied to rdma for-next, thanks

Jason

      reply	other threads:[~2020-10-28 22:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-26 16:15 [PATCH] IB/verbs: avoid nested container_of() Arnd Bergmann
2020-10-28 13:30 ` Jason Gunthorpe [this message]

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=20201028133048.GA2406668@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=arnd@arndb.de \
    --cc=arnd@kernel.org \
    --cc=dledford@redhat.com \
    --cc=gustavoars@kernel.org \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=michaelgur@mellanox.com \
    --cc=shamir.rabinovitch@oracle.com \
    --cc=yishaih@mellanox.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