Messages in this thread | | | Subject | Re: [patch] checkpatch: complain about GW-BASIC style label names | From | Joe Perches <> | Date | Thu, 07 May 2015 06:47:51 -0700 |
| |
On Thu, 2015-05-07 at 14:21 +0300, Dan Carpenter wrote: > GW-BASIC style label names are quite common. This generates a warning > like: > > WARNING: bad label name > #795: FILE: drivers/ata/pata_mpc52xx.c:795: > + err2:
Hey Dan.
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl [] > @@ -4023,6 +4023,16 @@ sub process { > } > } > > +#avoid GW-BASIC style label names > + if ($line=~/^\+\s*(err|error|fail|out)[0-9]+:/) {
Labels aren't always only lower case.
This may have false positives with ?: uses like a = foo ? err1:err2;
> + if (WARN("LABEL_NAME", > + "bad label name\n" . $herecurr) && > + $fix) { > + $fixed[$fixlinenr] =~ > + s/^(.)\s+/$1/; > + } > + }
There already is a $fix option in the INDENTED_LABEL test above this one and isn't needed or wanted here.
It may be better to use a message like: "Prefer functionally descriptive label naming (ie: label<why>:)\n"
| |