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

From: Joe Perches
Date: Thu May 07 2015 - 16:17:50 EST


On Thu, 2015-05-07 at 22:42 +0300, Dan Carpenter wrote:
> On Thu, May 07, 2015 at 06:47:51AM -0700, Joe Perches wrote:
> > > +#avoid GW-BASIC style label names
[]
> To be honest, I'm crap at Perl.

Me too.

> Give me something to cut and paste?

[maybe below...]

> > It may be better to use a message like:
> > "Prefer functionally descriptive label naming (ie: label<why>:)\n"
> >
>
> These things are always the trickiest bit. I think of why as the goto
> location and not the label location.
>
> WARNING: Prefer a more descriptive label. What does the label do?\n
> It's also a bit crap because labels don't do anything.

Maybe something like:

# check for label names likely used in a numeric sequence of labels
if ($line =~ /^.\s*((?:err|error|fail|out)[0-9+])\s*:/i ||
$line =~ /\bgoto\s+((?:err|error|fail|out)[0-9+])\s*[:;,]/) {
my $label = "This label";
if (defined $1) {
$label = $1;
} else {
$label = $2;
}
WARN("BAD_LABEL_NAME",
"$label isn't informative - prefer descriptive gotos and labels\n" . $herecurr);
}


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