2020-10-06 08:44:26

by Łukasz Stelmach

[permalink] [raw]
Subject: [PATCH v2] checkpatch: Fix false positive on empty block comment lines

To avoid false positives in presence of SPDX-License-Identifier in
networking files it is required to increase the leeway for empty block
comment lines by one line.

For example, checking drivers/net/loopback.c which starts with

// SPDX-License-Identifier: GPL-2.0-or-later
/*
* INET An implementation of the TCP/IP protocol suite for the LINUX

rsults in an unnecessary warning

WARNING: networking block comments don't use an empty /* line, use /* Comment...
+/*
+ * INET An implementation of the TCP/IP protocol suite for the LINUX

Signed-off-by: Łukasz Stelmach <[email protected]>
---
scripts/checkpatch.pl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

Changes in v2:
- added example warning in the commit description
- added a comment in the code

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index a213cdb82ab0..3555ac812c99 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3460,7 +3460,7 @@ sub process {
if ($realfile =~ m@^(drivers/net/|net/)@ &&
$prevrawline =~ /^\+[ \t]*\/\*[ \t]*$/ &&
$rawline =~ /^\+[ \t]*\*/ &&
- $realline > 2) {
+ $realline > 3) { # Do not warn about the initial copyright comment block after SPDX-License-Identifier
WARN("NETWORKING_BLOCK_COMMENT_STYLE",
"networking block comments don't use an empty /* line, use /* Comment...\n" . $hereprev);
}
--
2.26.2


2020-10-06 08:45:42

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH v2] checkpatch: Fix false positive on empty block comment lines

On Tue, 2020-10-06 at 10:35 +0200, Łukasz Stelmach wrote:
> To avoid false positives in presence of SPDX-License-Identifier in
> networking files it is required to increase the leeway for empty block
> comment lines by one line.
>
> For example, checking drivers/net/loopback.c which starts with
>
> // SPDX-License-Identifier: GPL-2.0-or-later
> /*
> * INET An implementation of the TCP/IP protocol suite for the LINUX
>
> rsults in an unnecessary warning
>
> WARNING: networking block comments don't use an empty /* line, use /* Comment...
> +/*
> + * INET An implementation of the TCP/IP protocol suite for the LINUX
>
> Signed-off-by: Łukasz Stelmach <[email protected]>

Thank Lukasz. Andrew, can you please pick this up?

> ---
> scripts/checkpatch.pl | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> Changes in v2:
> - added example warning in the commit description
> - added a comment in the code
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index a213cdb82ab0..3555ac812c99 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -3460,7 +3460,7 @@ sub process {
> if ($realfile =~ m@^(drivers/net/|net/)@ &&
> $prevrawline =~ /^\+[ \t]*\/\*[ \t]*$/ &&
> $rawline =~ /^\+[ \t]*\*/ &&
> - $realline > 2) {
> + $realline > 3) { # Do not warn about the initial copyright comment block after SPDX-License-Identifier
> WARN("NETWORKING_BLOCK_COMMENT_STYLE",
> "networking block comments don't use an empty /* line, use /* Comment...\n" . $hereprev);
> }