Re: [rfc patch] treewide: Convert "static const char <*> foo[] ="to "static const char <*> const foo[] ="

From: Joe Perches
Date: Thu Sep 09 2010 - 15:48:56 EST


On Thu, 2010-09-09 at 15:40 -0400, Mike Frysinger wrote:
> On Thu, Sep 9, 2010 at 15:33, Joe Perches wrote:
> > On Thu, 2010-09-09 at 15:16 -0400, Mike Frysinger wrote:
> >> On Thu, Sep 9, 2010 at 14:48, Joe Perches wrote:
> >> > could be warned by checkpatch
> >> i dont think you even need to check the contents. just match the base:
> >> char foo[]
> >> const char *foo[]
> >> we want to catch these even if it isnt static, and catching the
> >> forward decl would be useful too.
> > I think that's not so good.
> > There are times when a default is used but then modified.
> > For instance:
> > drivers/staging/comedi/drivers/comedi_bond.c: char file[] = "/dev/comediXXXXXX";
> how many hits of non-static (i.e. ones that are extern) that should be
> const but arent ?

Count them and see.

> >> how about making a coccinelle patch ?
> > Not necessary I think.
> > If Julia or anyone else wants to, no objection.
> but people splitting the decl wouldnt be caught by your checks ...
> coccinelle should catch it.
> static char *
> some_really_long_name[] = {
> ...
> };

That's not correct.

Perl (and grep -P) isn't sed and does multiline searching just fine.
A perl "\s*" spans lines, "[ \t]*" does not.

Look at the diffstat.
392 files changed, 844 insertions(+), 903 deletions(-)
I didn't delete those lines by hand.

The checkpatch tests don't catch those though as
it's mostly a single line oriented verifier.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/