public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Dave Jones <davej@redhat.com>,
	Linux Kernel <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: make checkpatch warn about memset with swapped arguments.
Date: Thu, 17 Mar 2011 15:36:45 -0400	[thread overview]
Message-ID: <20110317193645.GD14675@home.goodmis.org> (raw)
In-Reply-To: <20110317045209.GA18656@redhat.com>

On Thu, Mar 17, 2011 at 12:52:09AM -0400, Dave Jones wrote:
> 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|)\);/) {

Wouldn't this be a better regex:

	if ($line =~ /memset.*\,\s*(0x)?0\s*\)\s*;/)

-- Steve

> +			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
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

  reply	other threads:[~2011-03-17 19:36 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-17  4:52 make checkpatch warn about memset with swapped arguments Dave Jones
2011-03-17 19:36 ` Steven Rostedt [this message]
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=20110317193645.GD14675@home.goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=davej@redhat.com \
    --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