Re: [PATCH v2] checkpatch: warn about multi-line comments without an empty /* line

From: Joe Perches
Date: Tue Sep 26 2023 - 15:56:45 EST


On Tue, 2023-09-26 at 21:24 +0200, Petr Tesarik wrote:
> According to Documentation/process/coding-style.rst, the preferred style
> for multi-line comments outside net/ and drivers/net/ is:
>
> .. code-block:: c
>
> /*
> * This is the preferred style for multi-line
> * comments in the Linux kernel source code.
> * Please use it consistently.
> *
> * Description: A column of asterisks on the left side,
> * with beginning and ending almost-blank lines.
> */
>
> Signed-off-by: Petr Tesarik <petr@xxxxxxxxxxx>
[]
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> @@ -4006,6 +4006,14 @@ sub process {
> "networking block comments don't use an empty /* line, use /* Comment...\n" . $hereprev);
> }
>
> +# Non-networking without an initial /*
> + if ($realfile !~ m@^(drivers/net/|net/)@ &&
> + $prevrawline =~ /^\+[ \t]*\/\*.*[^ \t]$/ &&
> + $rawline =~ /^\+[ \t]*\*/) {
> + WARN("BLOCK_COMMENT_STYLE",
> + "multi-line block comments should start with an empty /* line\n" . $hereprev);
> + }
> +
> # Block comments use * on subsequent lines
> if ($prevline =~ /$;[ \t]*$/ && #ends in comment
> $prevrawline =~ /^\+.*?\/\*/ && #starting /*

Still nack. Too many existing instances.

$ git grep '/\*.*' -- '*.[ch]' | \
grep -v '/\*.*\*/' | \
grep -v -P "/\*\s*$" | \
grep -v '/\*\*' | \
grep -v "SPDX-License" | \
grep -v -P '^drivers/net|^net/' | \
wc -l
51834