Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755817Ab0BBMzu (ORCPT ); Tue, 2 Feb 2010 07:55:50 -0500 Received: from mail.perches.com ([173.55.12.10]:1804 "EHLO mail.perches.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753053Ab0BBMzq (ORCPT ); Tue, 2 Feb 2010 07:55:46 -0500 Subject: [RFC PATCH] checkpatch.pl: Add warning on non #define continuation lines From: Joe Perches To: Mark Brown , Andy Whitcroft , Andrew Morton Cc: Mike Frysinger , LKML In-Reply-To: <20100202110824.GF6566@rakim.wolfsonmicro.main> References: <20100201144745.GC26011@rakim.wolfsonmicro.main> <1265044080.25140.266.camel@Joe-Laptop.home> <8bd0f97a1002012013t5c4a3951ra559a8965d67a672@mail.gmail.com> <20100202110824.GF6566@rakim.wolfsonmicro.main> Content-Type: text/plain; charset="UTF-8" Date: Tue, 02 Feb 2010 04:55:44 -0800 Message-ID: <1265115344.25140.805.camel@Joe-Laptop.home> Mime-Version: 1.0 X-Mailer: Evolution 2.28.1 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1515 Lines: 46 On Tue, 2010-02-02 at 11:08 +0000, Mark Brown wrote: > it'd be good to also check for just regular use of > continuations in code other than macro definitions. These are just a > style nit but if there's a script that filters out false positives from > the macros that'd be handy... > Running "grep ' \\$' sound/soc/blackfin/*.[ch]" suggests that there's > still some of the continuations I mentioned above in there (plus a lot > of false positives from macros). diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 3257d3d..a174501 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -1234,6 +1234,7 @@ sub process { $realcnt = 0; $linenr = 0; + my $in_define = 0; foreach my $line (@lines) { $linenr++; @@ -1388,6 +1389,16 @@ sub process { WARN("adding a line without newline at end of file\n" . $herecurr); } + if ($rawline =~ /\\$/) { + if ($rawline =~ /\s*\#\s*define\s+/) { + $in_define = 1; + } elsif (!$in_define) { + WARN("Continuations outside of macros should be avoided\n" . $herecurr); + } + } else { + $in_define = 0; + } + # Blackfin: use hi/lo macros if ($realfile =~ m@arch/blackfin/.*\.S$@) { if ($line =~ /\.[lL][[:space:]]*=.*&[[:space:]]*0x[fF][fF][fF][fF]/) { -- 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/