All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Dave Jones <davej@redhat.com>,
	Linux Kernel <linux-kernel@vger.kernel.org>
Subject: Re: make checkpatch warn about memset with swapped arguments.
Date: Thu, 17 Mar 2011 14:11:08 -0700	[thread overview]
Message-ID: <20110317141108.52697d81.akpm@linux-foundation.org> (raw)
In-Reply-To: <1300394224.16880.518.camel@gandalf.stny.rr.com>

On Thu, 17 Mar 2011 16:37:04 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:

> On Thu, 2011-03-17 at 16:02 -0400, Dave Jones wrote:
> > On Thu, Mar 17, 2011 at 03:36:45PM -0400, Steven Rostedt wrote:
> > 
> >  > > +		if ($line =~ /memset.*\,(\ |)(0x|)0(\ |0|)\);/) {
> >  > 
> >  > Wouldn't this be a better regex:
> >  > 
> >  > 	if ($line =~ /memset.*\,\s*(0x)?0\s*\)\s*;/)
> > 
> > I dunno, regexps are all gobble-de-gook to me.  Why is it better ?
> 
> :) I love regex :)
> 
> But the reason for better is more robust. This will catch other bad
> things users may do, like having tabs and such instead of spaces. Or
> they may have more than one space. Although this should be caught by
> other errors or warnings in checkpatch.
> 
> \s stands for any whitespace, 
> so ",\s*x" is ,[any-amount-of-white-space]x"
> 
> The (0x)? is common for (0x|) in perl, but either is fine. I'm just use
> to the '?' one.
> 

Dave's patch is tested (I assume), so it wins ;)

Maybe it's just me, but I think it would be better to use bzero() for
this operation - it's more readable and it can't be screwed up.  Then
checkpatch checks for memset(xxx, 0, xxx) and for memset(xxx, xxx, 0)
and says "hey, use bzero".  

  reply	other threads:[~2011-03-17 21:11 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
2011-03-17 20:02   ` Dave Jones
2011-03-17 20:37     ` Steven Rostedt
2011-03-17 21:11       ` Andrew Morton [this message]
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=20110317141108.52697d81.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=davej@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rostedt@goodmis.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 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.