All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH] checkpatch: Warn on unnecessary parentheses around references of foo->bar
@ 2014-06-25  3:46 Joe Perches
  0 siblings, 0 replies; only message in thread
From: Joe Perches @ 2014-06-25  3:46 UTC (permalink / raw)
  To: Andrew Morton; +Cc: LKML, Dan Carpenter

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>
---
lk sources by far use &foo->bar over &(foo->bar).
(a rough count shows about 25:1)

 scripts/checkpatch.pl | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 538105a..8feaee2 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3462,6 +3462,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:/)) {





^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2014-06-25  3:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-25  3:46 [RFC PATCH] checkpatch: Warn on unnecessary parentheses around references of foo->bar Joe Perches

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.