提交 7fe528a2 编写于 作者: J Joe Perches 提交者: Linus Torvalds

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.comSigned-off-by: NJoe Perches <joe@perches.com>
Reported-by: NJohannes Berg <johannes@sipsolutions.net>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 737c0767
...@@ -4940,17 +4940,17 @@ sub process { ...@@ -4940,17 +4940,17 @@ sub process {
foreach my $arg (@def_args) { foreach my $arg (@def_args) {
next if ($arg =~ /\.\.\./); next if ($arg =~ /\.\.\./);
next if ($arg =~ /^type$/i); next if ($arg =~ /^type$/i);
my $tmp = $define_stmt; my $tmp_stmt = $define_stmt;
$tmp =~ s/\b(typeof|__typeof__|__builtin\w+|typecheck\s*\(\s*$Type\s*,|\#+)\s*\(*\s*$arg\s*\)*\b//g; $tmp_stmt =~ s/\b(typeof|__typeof__|__builtin\w+|typecheck\s*\(\s*$Type\s*,|\#+)\s*\(*\s*$arg\s*\)*\b//g;
$tmp =~ s/\#+\s*$arg\b//g; $tmp_stmt =~ s/\#+\s*$arg\b//g;
$tmp =~ s/\b$arg\s*\#\#//g; $tmp_stmt =~ s/\b$arg\s*\#\#//g;
my $use_cnt = $tmp =~ s/\b$arg\b//g; my $use_cnt = $tmp_stmt =~ s/\b$arg\b//g;
if ($use_cnt > 1) { if ($use_cnt > 1) {
CHK("MACRO_ARG_REUSE", CHK("MACRO_ARG_REUSE",
"Macro argument reuse '$arg' - possible side-effects?\n" . "$herectx"); "Macro argument reuse '$arg' - possible side-effects?\n" . "$herectx");
} }
# check if any macro arguments may have other precedence issues # check if any macro arguments may have other precedence issues
if ($define_stmt =~ m/($Operators)?\s*\b$arg\b\s*($Operators)?/m && if ($tmp_stmt =~ m/($Operators)?\s*\b$arg\b\s*($Operators)?/m &&
((defined($1) && $1 ne ',') || ((defined($1) && $1 ne ',') ||
(defined($2) && $2 ne ','))) { (defined($2) && $2 ne ','))) {
CHK("MACRO_ARG_PRECEDENCE", CHK("MACRO_ARG_PRECEDENCE",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册