[PATCH] checkpatch: Add check for use of sizeof without parenthesis

From: Joe Perches
Date: Fri Jul 06 2012 - 17:58:29 EST


Kernel style uses parenthesis around sizeof.

Signed-off-by: Joe Perches <joe@xxxxxxxxxxx>
---
scripts/checkpatch.pl | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 7190f95..a743622 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3265,6 +3265,12 @@ sub process {
"sizeof(& should be avoided\n" . $herecurr);
}

+# check for sizeof without parenthesis
+ if ($line =~ /\bsizeof\s+($Lval)/) {
+ WARN("SIZEOF_PARENTHESIS",
+ "sizeof $1 should be sizeof($1)\n" . $herecurr);
+ }
+
# check for line continuations in quoted strings with odd counts of "
if ($rawline =~ /\\$/ && $rawline =~ tr/"/"/ % 2) {
WARN("LINE_CONTINUATIONS",
--
1.7.8.111.gad25c.dirty

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/