From: Joe Perches Date: Wed, 6 Aug 2014 23:10:48 +0000 (-0700) Subject: checkpatch: warn on unnecessary parentheses around references of foo->bar X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=e2826fd07029e14285c178b41b18f6edc3b15a84;p=GitHub%2FLineageOS%2FG12%2Fandroid_kernel_amlogic_linux-4.9.git 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 Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- 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:/)) {