Skip to content

Commit 7fe528a

Browse files
JoePerchestorvalds
authored andcommitted
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 <[email protected]> Reported-by: Johannes Berg <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 737c076 commit 7fe528a

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

scripts/checkpatch.pl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4940,17 +4940,17 @@ sub process {
49404940
foreach my $arg (@def_args) {
49414941
next if ($arg =~ /\.\.\./);
49424942
next if ($arg =~ /^type$/i);
4943-
my $tmp = $define_stmt;
4944-
$tmp =~ s/\b(typeof|__typeof__|__builtin\w+|typecheck\s*\(\s*$Type\s*,|\#+)\s*\(*\s*$arg\s*\)*\b//g;
4945-
$tmp =~ s/\#+\s*$arg\b//g;
4946-
$tmp =~ s/\b$arg\s*\#\#//g;
4947-
my $use_cnt = $tmp =~ s/\b$arg\b//g;
4943+
my $tmp_stmt = $define_stmt;
4944+
$tmp_stmt =~ s/\b(typeof|__typeof__|__builtin\w+|typecheck\s*\(\s*$Type\s*,|\#+)\s*\(*\s*$arg\s*\)*\b//g;
4945+
$tmp_stmt =~ s/\#+\s*$arg\b//g;
4946+
$tmp_stmt =~ s/\b$arg\s*\#\#//g;
4947+
my $use_cnt = $tmp_stmt =~ s/\b$arg\b//g;
49484948
if ($use_cnt > 1) {
49494949
CHK("MACRO_ARG_REUSE",
49504950
"Macro argument reuse '$arg' - possible side-effects?\n" . "$herectx");
49514951
}
49524952
# 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 &&
49544954
((defined($1) && $1 ne ',') ||
49554955
(defined($2) && $2 ne ','))) {
49564956
CHK("MACRO_ARG_PRECEDENCE",

0 commit comments

Comments
 (0)