aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2016-10-11 16:52:14 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-10-11 18:06:31 -0400
commit5207649b7b1d2b1e1f8c97df91debfaa8de37669 (patch)
tree2c8d7797f4e5d5583536d9d3e05e1ae98a8bec83 /scripts
parent9192d41a3f0b98844860f1de5b82f729bbe07c61 (diff)
checkpatch: improve MACRO_ARG_PRECEDENCE test
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. Link: http://lkml.kernel.org/r/60229d13399f9b6509db5a32e30d4c16951a60cd.1473836073.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>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/checkpatch.pl20
1 files changed, 19 insertions, 1 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index ea1a7adce406..0ef3d837f2aa 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -4833,13 +4833,31 @@ sub process {
4833 } 4833 }
4834 4834
4835 } 4835 }
4836
4837 # Make $define_stmt single line, comment-free, etc
4838 my @stmt_array = split('\n', $define_stmt);
4839 my $first = 1;
4840 $define_stmt = "";
4841 foreach my $l (@stmt_array) {
4842 $l =~ s/\\$//;
4843 if ($first) {
4844 $define_stmt = $l;
4845 $first = 0;
4846 } elsif ($l =~ /^[\+ ]/) {
4847 $define_stmt .= substr($l, 1);
4848 }
4849 }
4850 $define_stmt =~ s/$;//g;
4851 $define_stmt =~ s/\s+/ /g;
4852 $define_stmt = trim($define_stmt);
4853
4836# check if any macro arguments are reused (ignore '...' and 'type') 4854# check if any macro arguments are reused (ignore '...' and 'type')
4837 foreach my $arg (@def_args) { 4855 foreach my $arg (@def_args) {
4838 next if ($arg =~ /\.\.\./); 4856 next if ($arg =~ /\.\.\./);
4839 next if ($arg =~ /^type$/i); 4857 next if ($arg =~ /^type$/i);
4840 my $tmp = $define_stmt; 4858 my $tmp = $define_stmt;
4841 $tmp =~ s/\b(typeof|__typeof__|__builtin\w+|typecheck\s*\(\s*$Type\s*,|\#+)\s*\(*\s*$arg\s*\)*\b//g; 4859 $tmp =~ s/\b(typeof|__typeof__|__builtin\w+|typecheck\s*\(\s*$Type\s*,|\#+)\s*\(*\s*$arg\s*\)*\b//g;
4842 $tmp =~ s/\#\s*$arg\b//g; 4860 $tmp =~ s/\#+\s*$arg\b//g;
4843 $tmp =~ s/\b$arg\s*\#\#//g; 4861 $tmp =~ s/\b$arg\s*\#\#//g;
4844 my $use_cnt = $tmp =~ s/\b$arg\b//g; 4862 my $use_cnt = $tmp =~ s/\b$arg\b//g;
4845 if ($use_cnt > 1) { 4863 if ($use_cnt > 1) {