public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Jones <davej@redhat.com>
To: Joe Perches <joe@perches.com>
Cc: apw@canonical.com, Linux Kernel <linux-kernel@vger.kernel.org>
Subject: Re: add memset checks to checkpatch.pl
Date: Wed, 18 Aug 2010 17:48:18 -0400	[thread overview]
Message-ID: <20100818214818.GA31094@redhat.com> (raw)
In-Reply-To: <1282167133.6724.165.camel@Joe-Laptop>

On Wed, Aug 18, 2010 at 02:32:13PM -0700, Joe Perches wrote:
 > On Wed, 2010-08-18 at 16:40 -0400, Dave Jones wrote:
 > > 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.
 > 
 > Maybe something like allows more flexible checking?
 > 
 > 	if ($line =~ /\bmemset\s*\(\s*($Lval)\s*,\s*($Lval)\s*,\s*($Lval)\s*\)/) {
 > 		my $memset_addr = $1;
 > 		my $memset_val = $2;
 > 		my $memset_size = $3;
 > 		if ($memset_size =~ /(0x|)0$/i) {
 > 			ERROR("memset uses second argument as constant byte value, not third.\n" . $herecurr);
 > 		elsif ($memset_size =~ /(0x|)1/i) {
 > 			WARN("single byte memset is suspicious. Swapped 2nd/3rd argument?\n" . $herecurr);
 > 		}
 > 	}

I'm all for improving my shoddy perl where possible, but this doesn't seem to actually
catch any of the test cases I wrote.  (it's also missing a } )

	Dave


  reply	other threads:[~2010-08-18 21:48 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-18 20:40 add memset checks to checkpatch.pl Dave Jones
2010-08-18 21:32 ` Joe Perches
2010-08-18 21:48   ` Dave Jones [this message]
2010-08-18 21:57     ` Joe Perches
2010-08-18 22:17       ` Dave Jones
2010-08-18 23:38         ` Joe Perches
2010-09-02 10:52           ` Andy Whitcroft
2010-09-02 13:17             ` Ævar Arnfjörð Bjarmason

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=20100818214818.GA31094@redhat.com \
    --to=davej@redhat.com \
    --cc=apw@canonical.com \
    --cc=joe@perches.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