Path: csiph.com!news.redatomik.org!weretis.net!feeder4.news.weretis.net!news.unit0.net!news.panservice.it!bofh.it!news.nic.it!robomod From: Joe Perches Newsgroups: linux.kernel Subject: [PATCH] checkpatch: Improve the embedded function name test for patch contexts Date: Sat, 29 Apr 2017 19:20:01 +0200 Message-ID: X-Original-To: Andrew Morton , Andy Whitcroft X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 64,4,0,,d41d8cd98f00b204,joe@perches.com,:::::,RULES_HIT:41:355:379:541:800:960:973:982:988:989:1260:1345:1437:1534:1541:1711:1730:1747:1777:1792:2197:2199:2332:2393:2559:2562:3138:3139:3140:3141:3142:3353:3653:3865:3866:3870:3871:3872:3874:4321:5007:6261:9592:10004:10848:11026:11658:11914:12438:12555:12895:13069:13073:13161:13229:13311:13357:14181:14384:14394:14721:21080:21221:21324:21433:21451:30029:30034:30054:30070,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:2,LUA_SUMMARY:none X-He-Tag: cable68_13483ab9dd425 X-Filterd-Recvd-Size: 2597 X-Mailer: git-send-email 2.10.0.rc2.1.g053435c Sender: robomod@news.nic.it List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Approved: robomod@news.nic.it Lines: 63 Organization: linux.* mail to news gateway X-Original-Cc: linux-kernel@vger.kernel.org X-Original-Date: Sat, 29 Apr 2017 10:15:30 -0700 X-Original-Message-ID: <6c675a31c74fbfad4fc45b9f462303d60ca2a283.1493486091.git.joe@perches.com> X-Original-Sender: linux-kernel-owner@vger.kernel.org Xref: csiph.com linux.kernel:1633312 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. Signed-off-by: Joe Perches --- scripts/checkpatch.pl | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 5270f7948493..c8573aece06c 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -2195,8 +2195,7 @@ sub process { } #next; } - if ($rawline=~/^\@\@ -\d+(?:,\d+)? \+(\d+)(,(\d+))? \@\@(.*)/) { - my $context = $4; + if ($rawline =~ /^\@\@ -\d+(?:,\d+)? \+(\d+)(,(\d+))? \@\@/) { $realline=$1-1; if (defined $2) { $realcnt=$3+1; @@ -2205,12 +2204,6 @@ sub process { } $in_comment = 0; - if ($context =~ /\b(\w+)\s*\(/) { - $context_function = $1; - } else { - undef $context_function; - } - # Guestimate if this is a continuing comment. Run # the context looking for a comment "edge". If this # edge is a close comment then we must be in a comment @@ -2281,7 +2274,8 @@ sub process { #extract the line range in the file after the patch is applied if (!$in_commit_log && - $line =~ /^\@\@ -\d+(?:,\d+)? \+(\d+)(,(\d+))? \@\@/) { + $line =~ /^\@\@ -\d+(?:,\d+)? \+(\d+)(,(\d+))? \@\@(.*)/) { + my $context = $4; $is_patch = 1; $first_line = $linenr + 1; $realline=$1-1; @@ -2297,6 +2291,11 @@ sub process { %suppress_whiletrailers = (); %suppress_export = (); $suppress_statement = 0; + if ($context =~ /\b(\w+)\s*\(/) { + $context_function = $1; + } else { + undef $context_function; + } next; # track the line number as we move through the hunk, note that -- 2.10.0.rc2.1.g053435c