Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751211Ab1CQEwS (ORCPT ); Thu, 17 Mar 2011 00:52:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41909 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750779Ab1CQEwQ (ORCPT ); Thu, 17 Mar 2011 00:52:16 -0400 Date: Thu, 17 Mar 2011 00:52:09 -0400 From: Dave Jones To: Linux Kernel Cc: Andrew Morton Subject: make checkpatch warn about memset with swapped arguments. Message-ID: <20110317045209.GA18656@redhat.com> Mail-Followup-To: Dave Jones , Linux Kernel , Andrew Morton MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1117 Lines: 29 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 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|)\);/) { + 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/