Re: make checkpatch warn about memset with swapped arguments.

From: Steven Rostedt
Date: Thu Mar 17 2011 - 16:37:12 EST

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.

-- Steve

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at