[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20110317193645.GD14675@home.goodmis.org>
Date: Thu, 17 Mar 2011 15:36:45 -0400
From: Steven Rostedt <rostedt@...dmis.org>
To: Dave Jones <davej@...hat.com>,
Linux Kernel <linux-kernel@...r.kernel.org>,
Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: make checkpatch warn about memset with swapped arguments.
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@...hat.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@...r.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists