Re: [patch] checkpatch: complain about GW-BASIC style label names

From: Joe Perches
Date: Thu May 07 2015 - 09:48:02 EST


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"


--
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/