summaryrefslogtreecommitdiff
path: root/scripts/checkpatch.pl
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2014-08-06 16:10:48 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2014-08-06 18:01:28 -0700
commite2826fd07029e14285c178b41b18f6edc3b15a84 (patch)
tree498d3b5a5434aa0b4ae94cf0708d97650eb8327f /scripts/checkpatch.pl
parent8d73e0e7dc18a39b120cb85ec675d59516e0af1a (diff)
downloadlwn-e2826fd07029e14285c178b41b18f6edc3b15a84.tar.gz
lwn-e2826fd07029e14285c178b41b18f6edc3b15a84.zip
checkpatch: warn on unnecessary parentheses around references of foo->bar
Parentheses around &(foo->bar) and *(foo->bar) are unnecessary. Emit a --strict only message on these uses. 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/checkpatch.pl')
-rwxr-xr-xscripts/checkpatch.pl8
1 files changed, 8 insertions, 0 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index df4250a8ad51..9a89a0609bac 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3491,6 +3491,14 @@ sub process {
}
}
+# check unnecessary parentheses around addressof/dereference single $Lvals
+# ie: &(foo->bar) should be &foo->bar and *(foo->bar) should be *foo->bar
+
+ while ($line =~ /(?:[^&]&\s*|\*)\(\s*($Ident\s*(?:$Member\s*)+)\s*\)/g) {
+ CHK("UNNECESSARY_PARENTHESES",
+ "Unnecessary parentheses around $1\n" . $herecurr);
+ }
+
#goto labels aren't indented, allow a single space however
if ($line=~/^.\s+[A-Za-z\d_]+:(?![0-9]+)/ and
!($line=~/^. [A-Za-z\d_]+:/) and !($line=~/^.\s+default:/)) {