Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 81ae542

Browse files
JoePerchessfrothwell
authored andcommitted
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 <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent c62dc22 commit 81ae542

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

scripts/checkpatch.pl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3491,6 +3491,14 @@ sub process {
34913491
}
34923492
}
34933493

3494+
# check unnecessary parentheses around addressof/dereference single $Lvals
3495+
# ie: &(foo->bar) should be &foo->bar and *(foo->bar) should be *foo->bar
3496+
3497+
while ($line =~ /(?:[^&]&\s*|\*)\(\s*($Ident\s*(?:$Member\s*)+)\s*\)/g) {
3498+
CHK("UNNECESSARY_PARENTHESES",
3499+
"Unnecessary parentheses around $1\n" . $herecurr);
3500+
}
3501+
34943502
#goto labels aren't indented, allow a single space however
34953503
if ($line=~/^.\s+[A-Za-z\d_]+:(?![0-9]+)/ and
34963504
!($line=~/^. [A-Za-z\d_]+:/) and !($line=~/^.\s+default:/)) {

0 commit comments

Comments
 (0)