public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* make checkpatch warn about memset with swapped arguments.
@ 2011-03-17  4:52 Dave Jones
  2011-03-17 19:36 ` Steven Rostedt
  2011-03-17 22:56 ` Andi Kleen
  0 siblings, 2 replies; 11+ messages in thread
From: Dave Jones @ 2011-03-17  4:52 UTC (permalink / raw)
  To: Linux Kernel; +Cc: Andrew Morton

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

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2011-03-17 22:57 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-17  4:52 make checkpatch warn about memset with swapped arguments Dave Jones
2011-03-17 19:36 ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox