From: Joe Perches <joe@perches.com>
To: akpm@linux-foundation.org, LKML <linux-kernel@vger.kernel.org>
Cc: mm-commits@vger.kernel.org, apw@canonical.com,
David Rientjes <rientjes@google.com>,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: [PATCH V2] checkpatch: Add check for use of sizeof without parenthesis
Date: Wed, 11 Jul 2012 22:23:32 -0700 [thread overview]
Message-ID: <1342070612.1970.16.camel@joe2Laptop> (raw)
In-Reply-To: <20120709215256.9A4F71E0043@wpzn4.hot.corp.google.com>
Kernel style uses parenthesis around sizeof.
Signed-off-by: Joe Perches <joe@perches.com>
---
Add check that works for sizeof *foo as well as sizeof foo
scripts/checkpatch.pl | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 7190f95..72c1803 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+((?:\*\s*|)$Lval|$Type(?:\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",
prev parent reply other threads:[~2012-07-12 5:23 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20120709215256.9A4F71E0043@wpzn4.hot.corp.google.com>
2012-07-09 22:23 ` + checkpatch-add-check-for-use-of-sizeof-without-parenthesis.patch added to -mm tree David Rientjes
2012-07-09 22:36 ` Joe Perches
2012-07-09 22:55 ` David Rientjes
2012-07-09 23:21 ` Joe Perches
2012-07-09 23:47 ` David Rientjes
2012-07-10 0:55 ` Joe Perches
2012-07-10 1:50 ` David Rientjes
2012-07-10 2:03 ` Joe Perches
2012-07-10 2:21 ` David Rientjes
2012-07-10 5:12 ` Joe Perches
2012-07-10 2:28 ` Linus Torvalds
2012-07-10 2:49 ` David Rientjes
2012-07-12 5:23 ` Joe Perches [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1342070612.1970.16.camel@joe2Laptop \
--to=joe@perches.com \
--cc=akpm@linux-foundation.org \
--cc=apw@canonical.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mm-commits@vger.kernel.org \
--cc=rientjes@google.com \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®