Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755455AbdDGJ4q convert rfc822-to-8bit (ORCPT ); Fri, 7 Apr 2017 05:56:46 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:41578 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753199AbdDGJ4h (ORCPT ); Fri, 7 Apr 2017 05:56:37 -0400 From: Hugues FRUCHET To: Joe Perches , Andy Whitcroft CC: "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v1] checkpatch: test missing initial blank line in block comment Thread-Topic: [PATCH v1] checkpatch: test missing initial blank line in block comment Thread-Index: AQHSrK1seI0c+MrB6EOR0d8E/iXMYKG2UPMAgAADYwCAABL6gIAAAzKAgAA7KICAAunqgA== Date: Fri, 7 Apr 2017 09:56:31 +0000 Message-ID: References: <1491206895-24332-1-git-send-email-hugues.fruchet@st.com> <1491206895-24332-2-git-send-email-hugues.fruchet@st.com> <1491246400.27353.59.camel@perches.com> <5518d438-7c73-2ba0-de77-0650742895e6@st.com> <1491381342.27353.76.camel@perches.com> <6755c558-baeb-307d-5a3e-f58650457cd3@st.com> <1491386103.27353.78.camel@perches.com> <654b3487-23a1-4766-4f42-73fa41fd7c9a@st.com> In-Reply-To: <654b3487-23a1-4766-4f42-73fa41fd7c9a@st.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.75.127.49] Content-Type: text/plain; charset="Windows-1252" Content-ID: <8537C04BAEC1114A87C0B6788A605423@st.com> Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-04-07_09:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3706 Lines: 109 Hi Joe, here is the output with the last version of the script: https://paste.ubuntu.com/24333124/ Differences are on the macro cases and the //foo \ *bar, no more warned. BR, Hugues. On 04/05/2017 03:26 PM, Hugues Fruchet wrote: > > > On 04/05/2017 11:55 AM, Joe Perches wrote: >> On Wed, 2017-04-05 at 09:43 +0000, Hugues FRUCHET wrote: >>> >>> On 04/05/2017 10:35 AM, Joe Perches wrote: >>>> On Wed, 2017-04-05 at 08:23 +0000, Hugues FRUCHET wrote: >>>>> Hi Joe, thanks for reviewing, >>>> >>>> Hello Hugues >>>> >>>>> I have run the command you advice on the entire kernel code, modifying >>>>> the script to only match the newly introduced check case. >>>>> There was 14389 hits, quite huge, so I cannot 100% certify that there >>>>> are no false positives, but I have checked the output carefully and >>>>> found 2 limit cases: >>>>> >>>>> 1) space character placed just after "/*" >>>>> WARNING: Block comments starts with an empty /* >>>>> #330: FILE: arch/alpha/kernel/core_irongate.c:330: >>>>> + /* >>>>> + * Check for within the AGP aperture... >>>>> => 146 hits (grep -c -n -E "\/\* $" /tmp/check.txt) >>>>> >>>>> 2) // style comment followed by pointer dereference >>>>> WARNING: Block comments starts with an empty /* >>>>> #426: FILE: drivers/media/dvb-core/dvb_ca_en50221.c:426: >>>>> + // success >>>>> + *tupleType = _tupleType; >>>>> => 4 hits >>>>> >>>>> Anyway this reveal comment style related issues, so I would say >>>>> that we >>>>> can keep script as it is, what do you think about ? >>>> >>>> Glancing at the output, there is also the comment >>>> in a multiline macro case: >>>> >>>> WARNING: Block comments starts with an empty /* >>>> #354: FILE: arch/mips/include/asm/processor.h:354: >>>> + /* \ >>>> + * Other stuff associated with the process \ >>>> >>>> Dunno how common that is, but maybe the test >>>> should be changed to avoid those. >>>> >>> >>> Here is a proposal that remove this macro case:Per >>> >>> # Missing initial /* >>> if ($realfile !~ m@^(drivers/net/|net/)@ && #networking exception >>> $prevrawline =~ /^\+[ \t]\/\**.+[ \t]/ && #start with /*... >>> $prevrawline !~ /^\+.*\/\*.*\*\/[ \t]*/ && #no inline /*...*/ >>> + $prevrawline !~ /^\+[ \t]\/\*+[ \t]+\\$/ &&#no macro /*<\> >>> $rawline =~ /^\+[ \t]*\*/ && >>> $realline > 2) { >> >> Perhaps it's better to change this to >> >> $prevrawline !~ /^\+\s*\/\*.*\\$/ > > KO with this line, I suspect you meant "\s" instead of "." in above > expression, so I've changed to: > $prevrawline !~ /^\+\s*\/\*\s*\\$/ > this one is OK > >> >> Also perhaps the >> // foo >> *bar = baz; >> >> case could be avoided by adding tests for the >> comment character $; on $prevline and $line >> and not looking only at $prevrawline and $rawline. >> > > Sorry for my poor understanding of the script but I don't catch what you > meant regarding "raw" and non "raw" variables, so I've done the job > simply by excluding the lines starting with "//": > $prevrawline !~ /^\+.*\/\/.*[ \t]*/ && #no inline // > > Which gives finally: > > # Missing initial /* > if ($realfile !~ m@^(drivers/net/|net/)@ && #networking exception > $prevrawline =~ /^\+[ \t]\/\**.+[ \t]/ && #start with /*... > $prevrawline !~ /^\+.*\/\*.*\*\/[ \t]*/ && #no inline /*...*/ > + $prevrawline !~ /^\+.*\/\/.*[ \t]*/ && #no inline // > + $prevrawline !~ /^\+\s*\/\*\s*\\$/ && #no macro /*<\> > $rawline =~ /^\+[ \t]*\*/ && > $realline > 2) { > WARN("MISSING_INITIAL_BLOCK_COMMENT_STYLE", > "Block comments starts with an empty /*\n" . $hereprev); > } > > > BR, > Hugues.