All of lore.kernel.org
 help / color / mirror / Atom feed
* [merged] checkpatch-check-for-common-memset-parameter-issues-against-statments.patch removed from -mm tree
@ 2012-01-11 21:31 akpm
  0 siblings, 0 replies; only message in thread
From: akpm @ 2012-01-11 21:31 UTC (permalink / raw)
  To: apw, joe, mm-commits


The patch titled
     Subject: checkpatch: check for common memset parameter issues against statments
has been removed from the -mm tree.  Its filename was
     checkpatch-check-for-common-memset-parameter-issues-against-statments.patch

This patch was dropped because it was merged into mainline or a subsystem tree

The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/

------------------------------------------------------
From: Andy Whitcroft <apw@canonical.com>
Subject: checkpatch: check for common memset parameter issues against statments

Move the memset checks over to work against the statement.  Also add
checks for 0 and 1 used as lengths.  Generally these indicate badly
ordered parameters.

Signed-off-by: Andy Whitcroft <apw@canonical.com>
Cc: Joe Perches <joe@perches.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 scripts/checkpatch.pl |   28 ++++++++++++++++++++++------
 1 file changed, 22 insertions(+), 6 deletions(-)

diff -puN scripts/checkpatch.pl~checkpatch-check-for-common-memset-parameter-issues-against-statments scripts/checkpatch.pl
--- a/scripts/checkpatch.pl~checkpatch-check-for-common-memset-parameter-issues-against-statments
+++ a/scripts/checkpatch.pl
@@ -3120,6 +3120,28 @@ sub process {
 			     "Avoid line continuations in quoted strings\n" . $herecurr);
 		}
 
+# Check for misused memsets
+		if (defined $stat && $stat =~ /\bmemset\s*\((.*)\)/s) {
+			my $args = $1;
+
+			# Flatten any parentheses and braces
+			while ($args =~ s/\([^\(\)]*\)/10/s ||
+			       $args =~ s/\{[^\{\}]*\}/10/s ||
+			       $args =~ s/\[[^\[\]]*\]/10/s)
+			{
+			}
+			# Extract the simplified arguments.
+			my ($ms_addr, $ms_val, $ms_size) =
+						split(/\s*,\s*/, $args);
+			if ($ms_size =~ /^(0x|)0$/i) {
+				ERROR("MEMSET",
+				      "memset size is 3rd argument, not the second.\n" . $herecurr);
+			} elsif ($ms_size =~ /^(0x|)1$/i) {
+				WARN("MEMSET",
+				     "single byte memset is suspicious. Swapped 2nd/3rd argument?\n" . $herecurr);
+			}
+		}
+
 # check for new externs in .c files.
 		if ($realfile =~ /\.c$/ && defined $stat &&
 		    $stat =~ /^.\s*(?:extern\s+)?$Type\s+($Ident)(\s*)\(/s)
@@ -3291,12 +3313,6 @@ sub process {
 			WARN("EXPORTED_WORLD_WRITABLE",
 			     "Exporting world writable files is usually an error. Consider more restrictive permissions.\n" . $herecurr);
 		}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-01-11 21:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-11 21:31 [merged] checkpatch-check-for-common-memset-parameter-issues-against-statments.patch removed from -mm tree akpm

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.