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

From: Alex Ghiti
Date: Mon Mar 25 2019 - 03:08:15 EST



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