public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Zhenwen Xu <helight.xu@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: sean.hefty@intel.com, hal.rosenstock@gmail.com,
	general@lists.openfabrics.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fix a warning on drivers/infiniband/hw/nes/nes_cm.c:862:
Date: Thu, 16 Apr 2009 09:11:02 +0800	[thread overview]
Message-ID: <20090416011102.GA3419@helight> (raw)
In-Reply-To: <20090415143228.d57a0201.akpm@linux-foundation.org>

On Wed, Apr 15, 2009 at 02:32:28PM -0700, Andrew Morton wrote:
> On Sun, 12 Apr 2009 20:23:17 +0800
> Zhenwen Xu <helight.xu@gmail.com> wrote:
> 
> > Fix this warning:
> > drivers/infiniband/hw/nes/nes_cm.c:862: warning: unused variable ___tmp_addr___
> > 
> > the 'tmp_addr' is defined for debug, so it should be defined in
> > CONFIG_INFINIBAND_NES_DEBUG
> > 
> > 
> > >From 5f67884bcda5450807dcd080378d829628e4db1c Mon Sep 17 00:00:00 2001
> > From: Zhenwen Xu <Helight.Xu@gmail.com>
> > Date: Sun, 12 Apr 2009 20:12:18 +0800
> > Subject: [PATCH] fix a warning on drivers/infiniband/hw/nes/nes_cm.c:862:
> > 
> > Signed-off-by: Zhenwen Xu <helight.xu@gmail.com>
> > ---
> >  drivers/infiniband/hw/nes/nes_cm.c |    3 ++-
> >  1 files changed, 2 insertions(+), 1 deletions(-)
> > 
> > diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
> > index dbd9a75..1bad93b 100644
> > --- a/drivers/infiniband/hw/nes/nes_cm.c
> > +++ b/drivers/infiniband/hw/nes/nes_cm.c
> > @@ -854,8 +854,9 @@ static struct nes_cm_listener *find_listener(struct nes_cm_core *cm_core,
> >  {
> >  	unsigned long flags;
> >  	struct nes_cm_listener *listen_node;
> > +#ifdef CONFIG_INFINIBAND_NES_DEBUG
> >  	__be32 tmp_addr = cpu_to_be32(dst_addr);
> > -
> > +#endif
> >  	/* walk list and find cm_node associated with this session ID */
> >  	spin_lock_irqsave(&cm_core->listen_list_lock, flags);
> >  	list_for_each_entry(listen_node, &cm_core->listen_list.list, list) {
> 
> eek, an ugly ifdef.  And we can't just remove tmp_addr because
> printk(%p) wants to be passed an address rather than a value.
> 
> It'd be nice if we had a handy macro to squish the warning, like
> uninitialized_var.
> 
> As it happens, uninitialized_var() _does_ suppress the unused-var warning:
> 
> --- a/drivers/infiniband/hw/nes/nes_cm.c~drivers-infiniband-hw-nes-nes_cmc-fix-unused-var-warning-cleanup
> +++ a/drivers/infiniband/hw/nes/nes_cm.c
> @@ -854,9 +854,8 @@ static struct nes_cm_listener *find_list
>  {
>  	unsigned long flags;
>  	struct nes_cm_listener *listen_node;
> -#ifdef CONFIG_INFINIBAND_NES_DEBUG
> -	__be32 tmp_addr = cpu_to_be32(dst_addr);
> -#endif
> +	__be32 uninitialized_var(tmp_addr) = cpu_to_be32(dst_addr);
> +
>  	/* walk list and find cm_node associated with this session ID */
>  	spin_lock_irqsave(&cm_core->listen_list_lock, flags);
>  	list_for_each_entry(listen_node, &cm_core->listen_list.list, list) {
> 
> 
> but that seems a bit abusive ;)
Thanks! I got.

-- 
---------------------------------
Zhenwen Xu - Open and Free
Home Page:	http://zhwen.org
My Studio:	http://dim4.cn

      reply	other threads:[~2009-04-16  1:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-12 12:23 [PATCH] fix a warning on drivers/infiniband/hw/nes/nes_cm.c:862: Zhenwen Xu
2009-04-15 21:32 ` Andrew Morton
2009-04-16  1:11   ` Zhenwen Xu [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=20090416011102.GA3419@helight \
    --to=helight.xu@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=general@lists.openfabrics.org \
    --cc=hal.rosenstock@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sean.hefty@intel.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