[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20100818204016.GA29640@redhat.com>
Date: Wed, 18 Aug 2010 16:40:17 -0400
From: Dave Jones <davej@...hat.com>
To: apw@...onical.com
Cc: Linux Kernel <linux-kernel@...r.kernel.org>
Subject: add memset checks to checkpatch.pl
Occasionally someone goofs the argument order to memset.
This patch makes checkpatch catch those.
I made memset with size of 0 an error, because it's never correct,
whereas memset with a size of 1 isn't technically an incorrect
thing to do so I left it as a warning. It may still be better to replace
it with a single variable assignment in the false positive cases.
Signed-off-by: Dave Jones <davej@...hat.com>
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 2039acd..3690173 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2794,6 +2794,14 @@ sub process {
}
}
+# check for memset with reversed 2nd/3rd arguments.
+ if ($line =~ /memset.*\,(\ |)(0x|)0(\ |0|)\);/) {
+ ERROR("memset takes size as third argument, not the second.\n" . $herecurr);
+ }
+ if ($line =~ /memset.*\,(\ |)(0x|)1\);/) {
+ WARN("single byte memset is suspicious. Swapped 2nd/3rd argument?\n" . $herecurr);
+ }
+
# check for lockdep_set_novalidate_class
if ($line =~ /^.\s*lockdep_set_novalidate_class\s*\(/ ||
$line =~ /__lockdep_no_validate__\s*\)/ ) {
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists