From: Dave Jones <davej@redhat.com>
To: Linux Kernel <linux-kernel@vger.kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Subject: make checkpatch warn about memset with swapped arguments.
Date: Thu, 17 Mar 2011 00:52:09 -0400 [thread overview]
Message-ID: <20110317045209.GA18656@redhat.com> (raw)
Because the second and third arguments of memset have the same type,
it turns out to be really easy to mix them up.
This bug comes up time after time, so checkpatch should really
be checking for it at patch submission time.
Signed-off-by: Dave Jones <davej@redhat.com>
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 58848e3..421b3e69 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2902,6 +2902,11 @@ sub process {
$line =~ /DEVICE_ATTR.*S_IWUGO/ ) {
WARN("Exporting world writable files is usually an error. Consider more restrictive permissions.\n" . $herecurr);
}
+
+ # Check for memset with swapped arguments
+ if ($line =~ /memset.*\,(\ |)(0x|)0(\ |0|)\);/) {
+ ERROR("memset size is 3rd argument, not the second.\n" . $herecurr);
+ }
}
# If we have no input at all, then there is nothing to report on
next reply other threads:[~2011-03-17 4:52 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-17 4:52 Dave Jones [this message]
2011-03-17 19:36 ` make checkpatch warn about memset with swapped arguments Steven Rostedt
2011-03-17 20:02 ` Dave Jones
2011-03-17 20:37 ` Steven Rostedt
2011-03-17 21:11 ` Andrew Morton
2011-03-17 21:32 ` Dave Jones
2011-03-17 21:57 ` Andrew Morton
2011-03-17 22:04 ` Steven Rostedt
2011-03-17 21:38 ` Steven Rostedt
2011-03-17 21:51 ` Dave Jones
2011-03-17 22:56 ` Andi Kleen
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=20110317045209.GA18656@redhat.com \
--to=davej@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.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