From: Joe Perches <joe@perches.com>
To: Ryan Mallon <rmallon@gmail.com>
Cc: Dan Carpenter <dan.carpenter@oracle.com>,
Jiri Kosina <trivial@kernel.org>,
kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH next V2] drivers: Use NULL not zero pointer assignments
Date: Fri, 27 Jan 2012 07:38:10 +0000 [thread overview]
Message-ID: <1327649890.12089.20.camel@joe2Laptop> (raw)
In-Reply-To: <4F22421A.5020501@gmail.com>
On Fri, 2012-01-27 at 17:20 +1100, Ryan Mallon wrote:
> On 27/01/12 16:33, Joe Perches wrote:
> > Using NULL pointer assignments is more kernel-style standard.
> > Uncompiled, untested.
> > Done via cocinelle script:
> > @@
> > type T;
> > T *pointer;
> > @@
> > -pointer = 0
> > +pointer = NULL
> Hi Joe,
Hi Ryan.
> I think you can drop a lot of the initialisations completely rather than
> convert them. I've pointed some out below. I'm just scanning through for
> likely candidates and I didn't bother looking at the staging drivers, so
> this list is not comprehensive.
I'll try a more generic solution.
Here's a possible cocci script that looks for declarations with
initializations that are later overwritten.
$ cat multi_set.cocci
@@
type T;
identifier x;
expression y;
expression z;
@@
-T x = y;
+T x;
...
x = z
$
This script has a defect because expression z may
use identifier x.
Anyway, if the script can be tweaked appropriately,
it might be useful to remove these unnecessary
initializations.
cheers, Joe
next prev parent reply other threads:[~2012-01-27 7:38 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-26 6:13 [patch] nfc: NULL vs zero in nci_activate_target() Dan Carpenter
2012-01-26 6:36 ` drivers: Use NULL not zero for pointer Joe Perches
2012-01-27 5:33 ` [PATCH next V2] drivers: Use NULL not zero pointer assignments Joe Perches
2012-01-27 6:20 ` Ryan Mallon
2012-01-27 7:38 ` Joe Perches [this message]
2012-01-27 22:27 ` Ryan Mallon
2012-01-27 22:46 ` Julia Lawall
2012-01-27 23:21 ` Ryan Mallon
2012-01-26 20:23 ` [patch] nfc: NULL vs zero in nci_activate_target() Samuel Ortiz
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=1327649890.12089.20.camel@joe2Laptop \
--to=joe@perches.com \
--cc=dan.carpenter@oracle.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rmallon@gmail.com \
--cc=trivial@kernel.org \
/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