checkpatch: improve the block comment * alignment test
An "uninitialized value" is emitted when a block comment starts on the same line as a statement. Fix this and make the test use a little fewer cpu cycles too. Link: http://lkml.kernel.org/r/3c9993320c2182d37f53ac540878cfef59c3f62d.1473365956.git.joe@perches.com Signed-off-by: Joe Perches <joe@perches.com> Reported-by: Charlemagne Lasse <charlemagnelasse@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
0616efa45a
commit
af207524a4
|
@ -3005,18 +3005,23 @@ sub process {
|
||||||
|
|
||||||
# Block comment * alignment
|
# Block comment * alignment
|
||||||
if ($prevline =~ /$;[ \t]*$/ && #ends in comment
|
if ($prevline =~ /$;[ \t]*$/ && #ends in comment
|
||||||
(($prevrawline =~ /^\+.*?\/\*/ && #starting /*
|
$line =~ /^\+[ \t]*$;/ && #leading comment
|
||||||
|
$rawline =~ /^\+[ \t]*\*/ && #leading *
|
||||||
|
(($prevrawline =~ /^\+.*?\/\*/ && #leading /*
|
||||||
$prevrawline !~ /\*\/[ \t]*$/) || #no trailing */
|
$prevrawline !~ /\*\/[ \t]*$/) || #no trailing */
|
||||||
$prevrawline =~ /^\+[ \t]*\*/) && #starting *
|
$prevrawline =~ /^\+[ \t]*\*/)) { #leading *
|
||||||
$rawline =~ /^\+[ \t]*\*/) { #rawline *
|
my $oldindent;
|
||||||
$prevrawline =~ m@^\+([ \t]*/?)\*@;
|
$prevrawline =~ m@^\+([ \t]*/?)\*@;
|
||||||
my $oldindent = expand_tabs($1);
|
if (defined($1)) {
|
||||||
|
$oldindent = expand_tabs($1);
|
||||||
|
} else {
|
||||||
|
$prevrawline =~ m@^\+(.*/?)\*@;
|
||||||
|
$oldindent = expand_tabs($1);
|
||||||
|
}
|
||||||
$rawline =~ m@^\+([ \t]*)\*@;
|
$rawline =~ m@^\+([ \t]*)\*@;
|
||||||
my $newindent = $1;
|
my $newindent = $1;
|
||||||
my $test_comment = '^\\+' . "$;" x (length($newindent) + 1);
|
|
||||||
$newindent = expand_tabs($newindent);
|
$newindent = expand_tabs($newindent);
|
||||||
if ($line =~ /$test_comment/ &&
|
if (length($oldindent) ne length($newindent)) {
|
||||||
length($oldindent) ne length($newindent)) {
|
|
||||||
WARN("BLOCK_COMMENT_STYLE",
|
WARN("BLOCK_COMMENT_STYLE",
|
||||||
"Block comments should align the * on each line\n" . $hereprev);
|
"Block comments should align the * on each line\n" . $hereprev);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue