From: Joe Perches <joe@perches.com>
To: Julia Lawall <julia.lawall@inria.fr>
Cc: Dan Carpenter <dan.carpenter@oracle.com>,
Andy Whitcroft <apw@canonical.com>, cocci <cocci@systeme.lip6.fr>,
Dwaipayan Ray <dwaipayanray1@gmail.com>,
Lukas Bulwahn <lukas.bulwahn@gmail.com>,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] checkpatch: prefer = {} initializations to = {0}
Date: Thu, 05 Aug 2021 11:28:14 -0700 [thread overview]
Message-ID: <83ffab14de1c2af00d38d532ffecdda1f9e936ab.camel@perches.com> (raw)
In-Reply-To: <alpine.DEB.2.22.394.2108052016220.16100@hadrien>
On Thu, 2021-08-05 at 20:17 +0200, Julia Lawall wrote:
> On Thu, 5 Aug 2021, Joe Perches wrote:
> > On Thu, 2021-08-05 at 05:27 -0700, Joe Perches wrote:
> > > On Thu, 2021-08-05 at 13:43 +0300, Dan Carpenter wrote:
> > > > The "= {};" style empty struct initializer is preferred over = {0}.
> > > > It avoids the situation where the first struct member is a pointer and
> > > > that generates a Sparse warning about assigning using zero instead of
> > > > NULL. Also it's just nicer to look at.
> >
> > Perhaps a cocci script like the below could help too:
> >
> > $ cat zero_init_struct.cocci
> > @@
> > identifier name;
> > identifier t;
> > @@
> >
> > struct name t = {
> > - 0
> > };
> >
> > @@
> > identifier name;
> > identifier t;
> > identifier member;
> > @@
> >
> > struct name t = {
> > ...,
> > .member = {
> > - 0
> > },
> > ...,
> > };
>
> My test turns up over 1900 occurrences. There is the question of whether
> {} or { } is preferred. The above semantic patch replaces {0} by {} and
> ( 0 } by { }.
I saw that and I don't recall how to force one style or another
to be output.
next prev parent reply other threads:[~2021-08-05 18:28 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-05 10:43 [PATCH] checkpatch: prefer = {} initializations to = {0} Dan Carpenter
2021-08-05 12:27 ` Joe Perches
2021-08-05 18:04 ` Joe Perches
2021-08-05 18:17 ` Julia Lawall
2021-08-05 18:28 ` Joe Perches [this message]
2021-08-05 18:44 ` Julia Lawall
2021-08-14 13:59 ` Christophe JAILLET
2021-08-14 14:05 ` Marion & Christophe JAILLET
2021-08-14 14:38 ` Leon Romanovsky
2021-08-14 14:57 ` Al Viro
2021-08-14 15:52 ` Leon Romanovsky
2021-08-14 16:45 ` Al Viro
2021-08-14 14:44 ` Russell King (Oracle)
2021-08-14 14:52 ` Al Viro
2021-08-14 20:20 ` Christophe JAILLET
2021-08-16 6:55 ` Dan Carpenter
2021-08-16 7:23 ` Russell King (Oracle)
2021-08-16 19:05 ` Dan Carpenter
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=83ffab14de1c2af00d38d532ffecdda1f9e936ab.camel@perches.com \
--to=joe@perches.com \
--cc=apw@canonical.com \
--cc=cocci@systeme.lip6.fr \
--cc=dan.carpenter@oracle.com \
--cc=dwaipayanray1@gmail.com \
--cc=julia.lawall@inria.fr \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lukas.bulwahn@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox