diff options
Diffstat (limited to 'scripts/checkpatch.pl')
| -rwxr-xr-x | scripts/checkpatch.pl | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 41e7db451cc0..893cbd517f89 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
| @@ -3844,9 +3844,27 @@ sub process { | |||
| 3844 | # ie: &(foo->bar) should be &foo->bar and *(foo->bar) should be *foo->bar | 3844 | # ie: &(foo->bar) should be &foo->bar and *(foo->bar) should be *foo->bar |
| 3845 | 3845 | ||
| 3846 | while ($line =~ /(?:[^&]&\s*|\*)\(\s*($Ident\s*(?:$Member\s*)+)\s*\)/g) { | 3846 | while ($line =~ /(?:[^&]&\s*|\*)\(\s*($Ident\s*(?:$Member\s*)+)\s*\)/g) { |
| 3847 | CHK("UNNECESSARY_PARENTHESES", | 3847 | my $var = $1; |
| 3848 | "Unnecessary parentheses around $1\n" . $herecurr); | 3848 | if (CHK("UNNECESSARY_PARENTHESES", |
| 3849 | } | 3849 | "Unnecessary parentheses around $var\n" . $herecurr) && |
| 3850 | $fix) { | ||
| 3851 | $fixed[$fixlinenr] =~ s/\(\s*\Q$var\E\s*\)/$var/; | ||
| 3852 | } | ||
| 3853 | } | ||
| 3854 | |||
| 3855 | # check for unnecessary parentheses around function pointer uses | ||
| 3856 | # ie: (foo->bar)(); should be foo->bar(); | ||
| 3857 | # but not "if (foo->bar) (" to avoid some false positives | ||
| 3858 | if ($line =~ /(\bif\s*|)(\(\s*$Ident\s*(?:$Member\s*)+\))[ \t]*\(/ && $1 !~ /^if/) { | ||
| 3859 | my $var = $2; | ||
| 3860 | if (CHK("UNNECESSARY_PARENTHESES", | ||
| 3861 | "Unnecessary parentheses around function pointer $var\n" . $herecurr) && | ||
| 3862 | $fix) { | ||
| 3863 | my $var2 = deparenthesize($var); | ||
| 3864 | $var2 =~ s/\s//g; | ||
| 3865 | $fixed[$fixlinenr] =~ s/\Q$var\E/$var2/; | ||
| 3866 | } | ||
| 3867 | } | ||
| 3850 | 3868 | ||
| 3851 | #goto labels aren't indented, allow a single space however | 3869 | #goto labels aren't indented, allow a single space however |
| 3852 | if ($line=~/^.\s+[A-Za-z\d_]+:(?![0-9]+)/ and | 3870 | if ($line=~/^.\s+[A-Za-z\d_]+:(?![0-9]+)/ and |
