Commit e2826fd0 authored by Joe Perches's avatar Joe Perches Committed by Linus Torvalds

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: default avatarJoe Perches <joe@perches.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 8d73e0e7
...@@ -3491,6 +3491,14 @@ sub process { ...@@ -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 #goto labels aren't indented, allow a single space however
if ($line=~/^.\s+[A-Za-z\d_]+:(?![0-9]+)/ and if ($line=~/^.\s+[A-Za-z\d_]+:(?![0-9]+)/ and
!($line=~/^. [A-Za-z\d_]+:/) and !($line=~/^.\s+default:/)) { !($line=~/^. [A-Za-z\d_]+:/) and !($line=~/^.\s+default:/)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment