scripts: checkpatch: Check block comments start with /* empty line outside net
PATCH 1/1 scripts: checkpatch: Check block comments start with /* empty line outside net
This patch ensures that apart from net code, block comments start with an empty /* line.
--- scripts/checkpatch.pl | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
scripts/checkpatch.pl +15 -6
@@ -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
Signature · 1 line
2.20.1
Joe Perches
maintainerQuoted 2 lines · Alexandre Ghiti
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(+)
scripts/checkpatch.pl +11 -0
@@ -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 /*
Le 3/6/19 à 12:08 AM, Joe Perches a écrit :
Quoted 6 lines · Alexandre Ghiti
Quoted 2 lines
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
Quoted 6 lines
$ 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.
Quoted 20 lines
Also, perhaps the code would be simpler using something like:
--- scripts/checkpatch.pl | 11 +++++++++++ 1 file changed, 11 insertions(+)scripts/checkpatch.pl +4
-0@@ -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/)@ &&
scripts/checkpatch.pl sub process { · line 3278
Quoted 10 lines
scripts/checkpatch.pl +7
-0+ $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
Quoted 52 lines · Alexandre Ghiti
Le 3/6/19 à 12:08 AM, Joe Perches a écrit :
Quoted 6 lines · Alexandre Ghiti
Quoted 2 lines
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
Quoted 6 lines
$ git grep -P "^\/\*\s*\S" | \ grep -v "\*/\s*$" | \ grep -vP "^(drivers/net|net/)" | \ grep -vP "\/\*\**$" | \ wc -l 19437This 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.
Quoted 22 lines
Also, perhaps the code would be simpler using something like:
---
scripts/checkpatch.pl| 11 +++++++++++1 file changed, 11 insertions(+)scripts/checkpatch.pl +0
-0@@ -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
scripts/checkpatch.pl +8
-0+# 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 otherwiseQuoted 8 lines
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.
Quoted 5 lines
Thanks for your comments,
Alex
Hi Joe,
Can I do something more regarding this patch ?
Thanks,
Alex
Quoted 59 lines · Alex Ghiti
Quoted 52 lines · Alexandre Ghiti
Le 3/6/19 à 12:08 AM, Joe Perches a écrit :
Quoted 6 lines · Alexandre Ghiti
Quoted 2 lines
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
Quoted 6 lines
$ git grep -P "^\/\*\s*\S" | \ grep -v "\*/\s*$" | \ grep -vP "^(drivers/net|net/)" | \ grep -vP "\/\*\**$" | \ wc -l 19437This 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.
Quoted 22 lines
Also, perhaps the code would be simpler using something like:
---
scripts/checkpatch.pl| 11 +++++++++++1 file changed, 11 insertions(+)scripts/checkpatch.pl +0
-0@@ -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
scripts/checkpatch.pl +8
-0+# 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 otherwiseQuoted 8 lines
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.
Quoted 5 lines
Thanks for your comments,
Alex
Quoted 8 lines
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