Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759424AbcDMGxv (ORCPT ); Wed, 13 Apr 2016 02:53:51 -0400 Received: from mail-wm0-f47.google.com ([74.125.82.47]:38774 "EHLO mail-wm0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759227AbcDMGxq (ORCPT ); Wed, 13 Apr 2016 02:53:46 -0400 Date: Wed, 13 Apr 2016 07:53:36 +0100 From: Andy Whitcroft To: Joe Perches Cc: Daniel Walker , open list , Daniel Walker , "xe-kernel@external.cisco.com" Subject: Re: checkpatch false positon on EXPORT_SYMBOL Message-ID: <20160413065336.GA4354@brain> References: <56FD3BAE.1070209@cisco.com> <1459452096.1744.12.camel@perches.com> <570C1C62.1060008@cisco.com> <1460412582.1800.96.camel@perches.com> <20160412125904.GB5107@brain> <1460483357.2507.24.camel@perches.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1460483357.2507.24.camel@perches.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2489 Lines: 76 On Tue, Apr 12, 2016 at 10:49:17AM -0700, Joe Perches wrote: > > On Tue, 2016-04-12 at 13:59 +0100, Andy Whitcroft wrote: > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl > [] > > @@ -3000,7 +3000,7 @@ sub process { > > > > ? $realline_next = $line_nr_next; > > ? if (defined $realline_next && > > ? ????(!defined $lines[$realline_next - 1] || > > - ?????substr($lines[$realline_next - 1], $off_next) =~ /^\s*$/)) { > > + ?????substr($lines[$realline_next - 1], $off_next) =~ /^($;|\s)*$/)) { > > ? $realline_next++; > > ?? } > > This doesn't work with c99 comments like: > > int foo; // comment > EXPORT_SYMBOL(foo); // comment > > but then again, there aren't any uses like that in the > kernel tree so it almost certainly doesn't matter. > > Thanks Andy. Ok, that makes sense. Lets try the below. -apw >From 4fd261803ca26cc4ff5b5efb04c0bf8b7bb713e9 Mon Sep 17 00:00:00 2001 From: Andy Whitcroft Date: Tue, 12 Apr 2016 13:43:46 +0100 Subject: [PATCH] checkpatch: comments are whitespace for the purposes of finding the next line While parsing statements we are recording the nominal next line for the purposes of checking that EXPORT* follows exactly on below an appropriate statement. Where there is whitespace after a statement end marker (such as ;) we will move to the next line. This also needs to apply to inline comments at the end of a line. Allows us to more correctly parse: +int test_export; +EXPORT_SYMBOL(test_export); /* No Error ! */ + +int test_export2; /* No Error below */ +EXPORT_SYMBOL(test_export2); + +int test_export3; /* Error below */ +EXPORT_SYMBOL(test_export3); /* Error ! */ + +int test_export4; // Error below +EXPORT_SYMBOL(test_export4); // Error ! + Reported-by: Daniel Walker Signed-off-by: Andy Whitcroft --- scripts/checkpatch.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index d574d13..c58bc4d 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -3000,7 +3000,7 @@ sub process { $realline_next = $line_nr_next; if (defined $realline_next && (!defined $lines[$realline_next - 1] || - substr($lines[$realline_next - 1], $off_next) =~ /^\s*$/)) { + substr($lines[$realline_next - 1], $off_next) =~ /^($;|\s|\/\/.*)*$/)) { $realline_next++; } -- 2.7.4