From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759537AbcING5y (ORCPT ); Wed, 14 Sep 2016 02:57:54 -0400 Received: from smtprelay0091.hostedemail.com ([216.40.44.91]:43637 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1758655AbcING5x (ORCPT ); Wed, 14 Sep 2016 02:57:53 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::,RULES_HIT:41:355:379:541:800:960:966:973:982:988:989:1260:1345:1437:1534:1541:1711:1730:1747:1777:1792:2196:2199:2393:2559:2562:3138:3139:3140:3141:3142:3353:3653:3865:3867:3868:3871:3872:3874:4321:4385:4605:5007:6119:6261:7903:10004:10848:11658:11914:12043:12114:12555:13069:13221:13229:13311:13357:14181:14384:14394:14721:21080:30054:30070,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:2,LUA_SUMMARY:none X-HE-Tag: dad91_2771cc94f5e4f X-Filterd-Recvd-Size: 2270 From: Joe Perches To: Andrew Morton , Andy Whitcroft Cc: linux-kernel@vger.kernel.org Subject: [PATCH] checkpatch: Improve MACRO_ARG_PRECEDENCE test Date: Tue, 13 Sep 2016 23:57:49 -0700 Message-Id: <60229d13399f9b6509db5a32e30d4c16951a60cd.1473836073.git.joe@perches.com> X-Mailer: git-send-email 2.10.0.rc2.1.g053435c Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It is possible for a multiple line macro definition to have a false positive report when an argument is used on a line after a continuation \. This line might have a leading '+' as the initial character that could be confused by checkpatch as an operator. Avoid the leading character on multiple line macro definitions. Signed-off-by: Joe Perches --- scripts/checkpatch.pl | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index ea1a7ad..0ef3d83 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -4833,13 +4833,31 @@ sub process { } } + + # Make $define_stmt single line, comment-free, etc + my @stmt_array = split('\n', $define_stmt); + my $first = 1; + $define_stmt = ""; + foreach my $l (@stmt_array) { + $l =~ s/\\$//; + if ($first) { + $define_stmt = $l; + $first = 0; + } elsif ($l =~ /^[\+ ]/) { + $define_stmt .= substr($l, 1); + } + } + $define_stmt =~ s/$;//g; + $define_stmt =~ s/\s+/ /g; + $define_stmt = trim($define_stmt); + # check if any macro arguments are reused (ignore '...' and 'type') foreach my $arg (@def_args) { next if ($arg =~ /\.\.\./); next if ($arg =~ /^type$/i); my $tmp = $define_stmt; $tmp =~ s/\b(typeof|__typeof__|__builtin\w+|typecheck\s*\(\s*$Type\s*,|\#+)\s*\(*\s*$arg\s*\)*\b//g; - $tmp =~ s/\#\s*$arg\b//g; + $tmp =~ s/\#+\s*$arg\b//g; $tmp =~ s/\b$arg\s*\#\#//g; my $use_cnt = $tmp =~ s/\b$arg\b//g; if ($use_cnt > 1) { -- 2.10.0.rc2.1.g053435c