lkml.org 
[lkml]   [2015]   [May]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [patch] checkpatch: complain about GW-BASIC style label names
From
Date
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);
}




\
 
 \ /
  Last update: 2015-05-07 22:41    [W:0.090 / U:0.316 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site