All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <error27@gmail.com>
To: Zic Rim <zicrim@gmail.com>
Cc: Jiri Kosina <jkosina@suse.cz>,
	"open list:HID CORE LAYER" <linux-input@vger.kernel.org>,
	kernel-janitors@vger.kernel.org
Subject: Re: [patch 1/2 -next] hid-lg4ff: silence sparse complaint
Date: Thu, 18 Aug 2011 16:21:44 +0000	[thread overview]
Message-ID: <20110818162144.GD21927@shale.localdomain> (raw)
In-Reply-To: <CAMvewQJ=6-3LgDwAEgJ6TaQSBWiSC5ZTb-14V60ZN0Lh2TYbAQ@mail.gmail.com>

On Thu, Aug 18, 2011 at 07:50:45PM +0530, Zic Rim wrote:
> > device_attribute *attr, char *buf)
> >  {
> > -       struct lg4ff_device_entry *entry = 0;
> > +       struct lg4ff_device_entry *uninitialized_var(entry);
> >
> 
> I think this is better      struct lg4ff_device_entry *entry = NULL ;
> 

We only have the initialization to silence a gcc warning.  My way is
more explicit.  If we set entry = NULL then other static analysis
tools complain about a potential NULL dereference.

regards,
dan carpenter


WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <error27@gmail.com>
To: Zic Rim <zicrim@gmail.com>
Cc: Jiri Kosina <jkosina@suse.cz>,
	"open list:HID CORE LAYER" <linux-input@vger.kernel.org>,
	kernel-janitors@vger.kernel.org
Subject: Re: [patch 1/2 -next] hid-lg4ff: silence sparse complaint
Date: Thu, 18 Aug 2011 19:21:44 +0300	[thread overview]
Message-ID: <20110818162144.GD21927@shale.localdomain> (raw)
In-Reply-To: <CAMvewQJ=6-3LgDwAEgJ6TaQSBWiSC5ZTb-14V60ZN0Lh2TYbAQ@mail.gmail.com>

On Thu, Aug 18, 2011 at 07:50:45PM +0530, Zic Rim wrote:
> > device_attribute *attr, char *buf)
> >  {
> > -       struct lg4ff_device_entry *entry = 0;
> > +       struct lg4ff_device_entry *uninitialized_var(entry);
> >
> 
> I think this is better      struct lg4ff_device_entry *entry = NULL ;
> 

We only have the initialization to silence a gcc warning.  My way is
more explicit.  If we set entry = NULL then other static analysis
tools complain about a potential NULL dereference.

regards,
dan carpenter


  parent reply	other threads:[~2011-08-18 16:21 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-18 13:42 [patch 1/2 -next] hid-lg4ff: silence sparse complaint Dan Carpenter
2011-08-18 13:42 ` Dan Carpenter
     [not found] ` <CAMvewQJ=6-3LgDwAEgJ6TaQSBWiSC5ZTb-14V60ZN0Lh2TYbAQ@mail.gmail.com>
2011-08-18 16:21   ` Dan Carpenter [this message]
2011-08-18 16:21     ` Dan Carpenter
2011-08-23  8:43 ` Jiri Kosina
2011-08-23  8:43   ` Jiri Kosina

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=20110818162144.GD21927@shale.localdomain \
    --to=error27@gmail.com \
    --cc=jkosina@suse.cz \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=zicrim@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.