linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] scripts: checkpatch: Check block comments start with /* empty line outside net
@ 2019-03-05 18:02 Alexandre Ghiti
  2019-03-05 23:08 ` Joe Perches
  0 siblings, 1 reply; 5+ messages in thread
From: Alexandre Ghiti @ 2019-03-05 18:02 UTC (permalink / raw)
  To: Andy Whitcroft, Joe Perches, linux-kernel; +Cc: Alexandre Ghiti

This patch ensures that apart from net code, block comments start with an
empty /* line.

Signed-off-by: Alexandre Ghiti <alex@ghiti.fr>
---
 scripts/checkpatch.pl | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 7dc12c137009..bcaf5d317976 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3230,12 +3230,21 @@ sub process {
 
 # Block comment styles
 # Networking with an initial /*
-		if ($realfile =~ m@^(drivers/net/|net/)@ &&
-		    $prevrawline =~ /^\+[ \t]*\/\*[ \t]*$/ &&
-		    $rawline =~ /^\+[ \t]*\*/ &&
-		    $realline > 2) {
-			WARN("NETWORKING_BLOCK_COMMENT_STYLE",
-			     "networking block comments don't use an empty /* line, use /* Comment...\n" . $hereprev);
+		if ($realfile =~ m@^(drivers/net/|net/)@) {
+			if ($prevrawline =~ /^\+[ \t]*\/\*[ \t]*$/ &&
+			    $rawline =~ /^\+[ \t]*\*/ &&
+			    $realline > 2) {
+				WARN("NETWORKING_BLOCK_COMMENT_STYLE",
+				     "networking block comments don't use an empty /* line, use /* Comment...\n" . $hereprev);
+			}
+		} else {
+# 'Normal' with an initial empty /*
+			if ($prevrawline =~ /^\+[ \t]*\/\*[ \t]*\S/ &&
+			    $rawline =~ /^\+[ \t]*\*/ &&
+			    $realline > 2) {
+				WARN("BLOCK_COMMENT_STYLE",
+				     "block comments use an empty /* line, don't use /* Comment...\n" . $hereprev);
+			}
 		}
 
 # Block comments use * on subsequent lines
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] scripts: checkpatch: Check block comments start with /* empty line outside net
  2019-03-05 18:02 [PATCH] scripts: checkpatch: Check block comments start with /* empty line outside net Alexandre Ghiti
@ 2019-03-05 23:08 ` Joe Perches
  2019-03-06 12:12   ` Alexandre Ghiti
  0 siblings, 1 reply; 5+ messages in thread
From: Joe Perches @ 2019-03-05 23:08 UTC (permalink / raw)
  To: Alexandre Ghiti, Andy Whitcroft, linux-kernel

On Tue, 2019-03-05 at 13:02 -0500, Alexandre Ghiti wrote:
> This patch ensures that apart from net code, block comments start with an
> empty /* line.

I'm not sure it's useful to try to eliminate these types
of lines as there are ~20K of them in the kernel

$ git grep -P "^\/\*\s*\S" | \
  grep -v "\*/\s*$" | \
  grep -vP "^(drivers/net|net/)" | \
  grep -vP "\/\*\**$" | \
  wc -l
19437

Also, perhaps the code would be simpler using something like:
---
 scripts/checkpatch.pl | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index d0001fd1112d..c62dbd440c50 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3262,6 +3262,17 @@ sub process {
 			     "networking block comments don't use an empty /* line, use /* Comment...\n" . $hereprev);
 		}
 
+# Block comments use an initial blank /* unless self contained single line
+# or a continuous header line like /**********************
+# This also allows for introductory kernel-doc /** lines
+		if ($realfile !~ m@(?:drivers/net|net/)@ &&
+		    $rawline =~ m@^\+\s*/\*(?:\s*\*++)?\s*\S@ &&
+		    $rawline !~ m@\*/\s*$@ &&
+		    $realline > 2) {
+			WARN("BLOCK_COMMENT_STYLE",
+			     "Block comments start with only /* on an otherwise blank line\n" . $herecurr);
+		}
+
 # Block comments use * on subsequent lines
 		if ($prevline =~ /$;[ \t]*$/ &&			#ends in comment
 		    $prevrawline =~ /^\+.*?\/\*/ &&		#starting /*



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] scripts: checkpatch: Check block comments start with /* empty line outside net
  2019-03-05 23:08 ` Joe Perches
@ 2019-03-06 12:12   ` Alexandre Ghiti
  2019-03-17 15:48     ` Alex Ghiti
  0 siblings, 1 reply; 5+ messages in thread
From: Alexandre Ghiti @ 2019-03-06 12:12 UTC (permalink / raw)
  To: Joe Perches, Andy Whitcroft, linux-kernel

Le 3/6/19 à 12:08 AM, Joe Perches a écrit :
> On Tue, 2019-03-05 at 13:02 -0500, Alexandre Ghiti wrote:
>> This patch ensures that apart from net code, block comments start with an
>> empty /* line.
> I'm not sure it's useful to try to eliminate these types
> of lines as there are ~20K of them in the kernel
>
> $ git grep -P "^\/\*\s*\S" | \
>    grep -v "\*/\s*$" | \
>    grep -vP "^(drivers/net|net/)" | \
>    grep -vP "\/\*\**$" | \
>    wc -l
> 19437


This is part of the coding style, some people rely on checkpatch for 
this matter,
so I think we should at least warn user, that would avoid patch bouncing.


>
> Also, perhaps the code would be simpler using something like:
> ---
>   scripts/checkpatch.pl | 11 +++++++++++
>   1 file changed, 11 insertions(+)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index d0001fd1112d..c62dbd440c50 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -3262,6 +3262,17 @@ sub process {
>   			     "networking block comments don't use an empty /* line, use /* Comment...\n" . $hereprev);
>   		}
>   
> +# Block comments use an initial blank /* unless self contained single line
> +# or a continuous header line like /**********************
> +# This also allows for introductory kernel-doc /** lines
> +		if ($realfile !~ m@(?:drivers/net|net/)@ &&
> +		    $rawline =~ m@^\+\s*/\*(?:\s*\*++)?\s*\S@ &&
> +		    $rawline !~ m@\*/\s*$@ &&
> +		    $realline > 2) {
> +			WARN("BLOCK_COMMENT_STYLE",
> +			     "Block comments start with only /* on an otherwise blank line\n" . $herecurr);
> +		}
> +
>   # Block comments use * on subsequent lines
>   		if ($prevline =~ /$;[ \t]*$/ &&			#ends in comment
>   		    $prevrawline =~ /^\+.*?\/\*/ &&		#starting /*
>
>
Your version handles more cases, but why is it simpler ? Anyway, that's 
ok for me
if you prefer your version.

Thanks for your comments,

Alex



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] scripts: checkpatch: Check block comments start with /* empty line outside net
  2019-03-06 12:12   ` Alexandre Ghiti
@ 2019-03-17 15:48     ` Alex Ghiti
  2019-03-25  7:08       ` Alex Ghiti
  0 siblings, 1 reply; 5+ messages in thread
From: Alex Ghiti @ 2019-03-17 15:48 UTC (permalink / raw)
  To: Joe Perches, Andy Whitcroft, linux-kernel

On 3/6/19 7:12 AM, Alexandre Ghiti wrote:
> Le 3/6/19 à 12:08 AM, Joe Perches a écrit :
>> On Tue, 2019-03-05 at 13:02 -0500, Alexandre Ghiti wrote:
>>> This patch ensures that apart from net code, block comments start 
>>> with an
>>> empty /* line.
>> I'm not sure it's useful to try to eliminate these types
>> of lines as there are ~20K of them in the kernel
>>
>> $ git grep -P "^\/\*\s*\S" | \
>>    grep -v "\*/\s*$" | \
>>    grep -vP "^(drivers/net|net/)" | \
>>    grep -vP "\/\*\**$" | \
>>    wc -l
>> 19437
>
>
> This is part of the coding style, some people rely on checkpatch for 
> this matter,
> so I think we should at least warn user, that would avoid patch bouncing.
>
>
>>
>> Also, perhaps the code would be simpler using something like:
>> ---
>>   scripts/checkpatch.pl | 11 +++++++++++
>>   1 file changed, 11 insertions(+)
>>
>> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
>> index d0001fd1112d..c62dbd440c50 100755
>> --- a/scripts/checkpatch.pl
>> +++ b/scripts/checkpatch.pl
>> @@ -3262,6 +3262,17 @@ sub process {
>>                    "networking block comments don't use an empty /* 
>> line, use /* Comment...\n" . $hereprev);
>>           }
>>   +# Block comments use an initial blank /* unless self contained 
>> single line
>> +# or a continuous header line like /**********************
>> +# This also allows for introductory kernel-doc /** lines
>> +        if ($realfile !~ m@(?:drivers/net|net/)@ &&
>> +            $rawline =~ m@^\+\s*/\*(?:\s*\*++)?\s*\S@ &&
>> +            $rawline !~ m@\*/\s*$@ &&
>> +            $realline > 2) {
>> +            WARN("BLOCK_COMMENT_STYLE",
>> +                 "Block comments start with only /* on an otherwise 
>> blank line\n" . $herecurr);
>> +        }
>> +
>>   # Block comments use * on subsequent lines
>>           if ($prevline =~ /$;[ \t]*$/ && #ends in comment
>>               $prevrawline =~ /^\+.*?\/\*/ && #starting /*
>>
>>
> Your version handles more cases, but why is it simpler ? Anyway, 
> that's ok for me
> if you prefer your version.
>
> Thanks for your comments,
>
> Alex
>
>

Hi Joe,

Can I do something more regarding this patch ?

Thanks,

Alex


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] scripts: checkpatch: Check block comments start with /* empty line outside net
  2019-03-17 15:48     ` Alex Ghiti
@ 2019-03-25  7:08       ` Alex Ghiti
  0 siblings, 0 replies; 5+ messages in thread
From: Alex Ghiti @ 2019-03-25  7:08 UTC (permalink / raw)
  To: Joe Perches, Andy Whitcroft, linux-kernel


On 3/17/19 11:48 AM, Alex Ghiti wrote:
> On 3/6/19 7:12 AM, Alexandre Ghiti wrote:
>> Le 3/6/19 à 12:08 AM, Joe Perches a écrit :
>>> On Tue, 2019-03-05 at 13:02 -0500, Alexandre Ghiti wrote:
>>>> This patch ensures that apart from net code, block comments start 
>>>> with an
>>>> empty /* line.
>>> I'm not sure it's useful to try to eliminate these types
>>> of lines as there are ~20K of them in the kernel
>>>
>>> $ git grep -P "^\/\*\s*\S" | \
>>>    grep -v "\*/\s*$" | \
>>>    grep -vP "^(drivers/net|net/)" | \
>>>    grep -vP "\/\*\**$" | \
>>>    wc -l
>>> 19437
>>
>>
>> This is part of the coding style, some people rely on checkpatch for 
>> this matter,
>> so I think we should at least warn user, that would avoid patch 
>> bouncing.
>>
>>
>>>
>>> Also, perhaps the code would be simpler using something like:
>>> ---
>>>   scripts/checkpatch.pl | 11 +++++++++++
>>>   1 file changed, 11 insertions(+)
>>>
>>> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
>>> index d0001fd1112d..c62dbd440c50 100755
>>> --- a/scripts/checkpatch.pl
>>> +++ b/scripts/checkpatch.pl
>>> @@ -3262,6 +3262,17 @@ sub process {
>>>                    "networking block comments don't use an empty /* 
>>> line, use /* Comment...\n" . $hereprev);
>>>           }
>>>   +# Block comments use an initial blank /* unless self contained 
>>> single line
>>> +# or a continuous header line like /**********************
>>> +# This also allows for introductory kernel-doc /** lines
>>> +        if ($realfile !~ m@(?:drivers/net|net/)@ &&
>>> +            $rawline =~ m@^\+\s*/\*(?:\s*\*++)?\s*\S@ &&
>>> +            $rawline !~ m@\*/\s*$@ &&
>>> +            $realline > 2) {
>>> +            WARN("BLOCK_COMMENT_STYLE",
>>> +                 "Block comments start with only /* on an otherwise 
>>> blank line\n" . $herecurr);
>>> +        }
>>> +
>>>   # Block comments use * on subsequent lines
>>>           if ($prevline =~ /$;[ \t]*$/ && #ends in comment
>>>               $prevrawline =~ /^\+.*?\/\*/ && #starting /*
>>>
>>>
>> Your version handles more cases, but why is it simpler ? Anyway, 
>> that's ok for me
>> if you prefer your version.
>>
>> Thanks for your comments,
>>
>> Alex
>>
>>
>
> Hi Joe,
>
> Can I do something more regarding this patch ?
>
> Thanks,
>
> Alex
>
Hi,

Sorry for insisting, but do you consider this patch for inclusion ?

Thanks,

Alex

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-03-25  7:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-05 18:02 [PATCH] scripts: checkpatch: Check block comments start with /* empty line outside net Alexandre Ghiti
2019-03-05 23:08 ` Joe Perches
2019-03-06 12:12   ` Alexandre Ghiti
2019-03-17 15:48     ` Alex Ghiti
2019-03-25  7:08       ` Alex Ghiti

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).