Skip to content

Commit 74fd4f3

Browse files
JoePerchestorvalds
authored andcommitted
checkpatch: improve the embedded function name test for patch contexts
The current test works only for a single patch context as it is done in the foreach ($rawlines) loop that precedes the loop where the actual $context_function variable is used. Move the set of $context_function into the foreach (@lines) loop where it is useful for each patch context. Link: http://lkml.kernel.org/r/6c675a31c74fbfad4fc45b9f462303d60ca2a283.1493486091.git.joe@perches.com Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 75ad8c5 commit 74fd4f3

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

scripts/checkpatch.pl

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2213,8 +2213,7 @@ sub process {
22132213
}
22142214
#next;
22152215
}
2216-
if ($rawline=~/^\@\@ -\d+(?:,\d+)? \+(\d+)(,(\d+))? \@\@(.*)/) {
2217-
my $context = $4;
2216+
if ($rawline =~ /^\@\@ -\d+(?:,\d+)? \+(\d+)(,(\d+))? \@\@/) {
22182217
$realline=$1-1;
22192218
if (defined $2) {
22202219
$realcnt=$3+1;
@@ -2223,12 +2222,6 @@ sub process {
22232222
}
22242223
$in_comment = 0;
22252224

2226-
if ($context =~ /\b(\w+)\s*\(/) {
2227-
$context_function = $1;
2228-
} else {
2229-
undef $context_function;
2230-
}
2231-
22322225
# Guestimate if this is a continuing comment. Run
22332226
# the context looking for a comment "edge". If this
22342227
# edge is a close comment then we must be in a comment
@@ -2299,7 +2292,8 @@ sub process {
22992292

23002293
#extract the line range in the file after the patch is applied
23012294
if (!$in_commit_log &&
2302-
$line =~ /^\@\@ -\d+(?:,\d+)? \+(\d+)(,(\d+))? \@\@/) {
2295+
$line =~ /^\@\@ -\d+(?:,\d+)? \+(\d+)(,(\d+))? \@\@(.*)/) {
2296+
my $context = $4;
23032297
$is_patch = 1;
23042298
$first_line = $linenr + 1;
23052299
$realline=$1-1;
@@ -2315,6 +2309,11 @@ sub process {
23152309
%suppress_whiletrailers = ();
23162310
%suppress_export = ();
23172311
$suppress_statement = 0;
2312+
if ($context =~ /\b(\w+)\s*\(/) {
2313+
$context_function = $1;
2314+
} else {
2315+
undef $context_function;
2316+
}
23182317
next;
23192318

23202319
# track the line number as we move through the hunk, note that

0 commit comments

Comments
 (0)