diff options
| author | Joe Perches <joe@perches.com> | 2017-07-10 18:52:27 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-07-10 19:32:35 -0400 |
| commit | 7fe528a27dee5fcab3bc093ee6f311080f799e29 (patch) | |
| tree | 3b9edffbe9302f08e78392e251f3babfa6998801 /scripts/checkpatch.pl | |
| parent | 737c0767758bbd65cf95c44ccc09bca970e2ef8e (diff) | |
checkpatch: improve macro reuse test
checkpatch reports a false positive when using token pasting argument
multiple times in a macro.
Fix it.
Miscellanea:
o Make the $tmp variable name used in the macro argument tests
a bit more descriptive
Link: http://lkml.kernel.org/r/cf434ae7602838388c7cb49d42bca93ab88527e7.1498483044.git.joe@perches.com
Signed-off-by: Joe Perches <joe@perches.com>
Reported-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts/checkpatch.pl')
| -rwxr-xr-x | scripts/checkpatch.pl | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 63409dbd0de5..43171ed88115 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
| @@ -4940,17 +4940,17 @@ sub process { | |||
| 4940 | foreach my $arg (@def_args) { | 4940 | foreach my $arg (@def_args) { |
| 4941 | next if ($arg =~ /\.\.\./); | 4941 | next if ($arg =~ /\.\.\./); |
| 4942 | next if ($arg =~ /^type$/i); | 4942 | next if ($arg =~ /^type$/i); |
| 4943 | my $tmp = $define_stmt; | 4943 | my $tmp_stmt = $define_stmt; |
| 4944 | $tmp =~ s/\b(typeof|__typeof__|__builtin\w+|typecheck\s*\(\s*$Type\s*,|\#+)\s*\(*\s*$arg\s*\)*\b//g; | 4944 | $tmp_stmt =~ s/\b(typeof|__typeof__|__builtin\w+|typecheck\s*\(\s*$Type\s*,|\#+)\s*\(*\s*$arg\s*\)*\b//g; |
| 4945 | $tmp =~ s/\#+\s*$arg\b//g; | 4945 | $tmp_stmt =~ s/\#+\s*$arg\b//g; |
| 4946 | $tmp =~ s/\b$arg\s*\#\#//g; | 4946 | $tmp_stmt =~ s/\b$arg\s*\#\#//g; |
| 4947 | my $use_cnt = $tmp =~ s/\b$arg\b//g; | 4947 | my $use_cnt = $tmp_stmt =~ s/\b$arg\b//g; |
| 4948 | if ($use_cnt > 1) { | 4948 | if ($use_cnt > 1) { |
| 4949 | CHK("MACRO_ARG_REUSE", | 4949 | CHK("MACRO_ARG_REUSE", |
| 4950 | "Macro argument reuse '$arg' - possible side-effects?\n" . "$herectx"); | 4950 | "Macro argument reuse '$arg' - possible side-effects?\n" . "$herectx"); |
| 4951 | } | 4951 | } |
| 4952 | # check if any macro arguments may have other precedence issues | 4952 | # check if any macro arguments may have other precedence issues |
| 4953 | if ($define_stmt =~ m/($Operators)?\s*\b$arg\b\s*($Operators)?/m && | 4953 | if ($tmp_stmt =~ m/($Operators)?\s*\b$arg\b\s*($Operators)?/m && |
| 4954 | ((defined($1) && $1 ne ',') || | 4954 | ((defined($1) && $1 ne ',') || |
| 4955 | (defined($2) && $2 ne ','))) { | 4955 | (defined($2) && $2 ne ','))) { |
| 4956 | CHK("MACRO_ARG_PRECEDENCE", | 4956 | CHK("MACRO_ARG_PRECEDENCE", |
