Re: [PATCH] scripts: checkpatch: Check block comments start with /* empty line outside net

From: Joe Perches
Date: Tue Mar 05 2019 - 18:08:47 EST


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 /*