Skip to contentSkip to conversation

checkpatch: always allow C99 SPDX License Identifer comments

PATCH In review Scott Branden 2 participants 6 messages Mar 11, 2020 – Mar 13, 2020 Checkpatch

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 checkpatch: always allow C99 SPDX License Identifer comments

Always allow C99 comment styles if SPDK-License-Identifier is in comment even if C99_COMMENT_TOLERANCE is specified in the --ignore options.

---
 scripts/checkpatch.pl | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/checkpatch.pl +2 -2
index a63380c6b0d2..c8b429dd6b51 100755
@@ -3852,8 +3852,8 @@ sub process {
 			}
 		}
 
-# no C99 // comments
-		if ($line =~ m{//}) {
+# no C99 // comments except for SPDX-License-Identifier
+		if ($line =~ m{//} && $rawline !~ /SPDX-License-Identifier:/) {
 			if (ERROR("C99_COMMENTS",
 				  "do not use C99 // comments\n" . $herecurr) &&
 			    $fix) {
Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 2 lines · Scott Branden

Always allow C99 comment styles if SPDK-License-Identifier is in comment even if C99_COMMENT_TOLERANCE is specified in the --ignore options.

Why is this useful?

Quoted 20 lines
---
 scripts/checkpatch.pl | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/checkpatch.pl +2 -2
index a63380c6b0d2..c8b429dd6b51 100755
@@ -3852,8 +3852,8 @@ sub process {
 			}
 		}
 
-# no C99 // comments
-		if ($line =~ m{//}) {
+# no C99 // comments except for SPDX-License-Identifier
+		if ($line =~ m{//} && $rawline !~ /SPDX-License-Identifier:/) {
 			if (ERROR("C99_COMMENTS",
 				  "do not use C99 // comments\n" . $herecurr) &&
 			    $fix) {
#2 lore raw

Hi Joe,

Quoted 4 lines · Joe Perches
Quoted 2 lines · Scott Branden

Always allow C99 comment styles if SPDK-License-Identifier is in comment even if C99_COMMENT_TOLERANCE is specified in the --ignore options.

Why is this useful?

This is useful because if you run checkpatch with --ignore=C99_COMMENT_TOLERANCE right now it will warn on almost every .c file in the linux kernel due to the decision to use // SPDX-License-Identifier: at the start of every c file

With this change checkpatch will stop complaining about this single outlier // in the file and allow you to enforce no other C99 // style comments in the patch.

It would have been a lot nicer if /* SPDX-License-Identifier: xxxx */ was used instead...

Quoted 21 lines
Quoted 21 lines
---
  scripts/checkpatch.pl | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
scripts/checkpatch.pl +2 -2
index a63380c6b0d2..c8b429dd6b51 100755
@@ -3852,8 +3852,8 @@ sub process {
  			}
  		}
 
-# no C99 // comments
-		if ($line =~ m{//}) {
+# no C99 // comments except for SPDX-License-Identifier
+		if ($line =~ m{//} && $rawline !~ /SPDX-License-Identifier:/) {
  			if (ERROR("C99_COMMENTS",
  				  "do not use C99 // comments\n" . $herecurr) &&
  			    $fix) {
maintainer
#3 lore raw
Quoted 4 lines · Scott Branden

Hi Joe,

Quoted 1 line · Joe Perches

On Wed, 2020-03-11 at 12:11 -0700, Scott Branden wrote:

Quoted 8 lines
Quoted 3 lines
Quoted 2 lines

Always allow C99 comment styles if SPDK-License-Identifier is in comment even if C99_COMMENT_TOLERANCE is specified in the --ignore options.

Why is this useful?

This is useful because if you run checkpatch with --ignore=C99_COMMENT_TOLERANCE
right now it will warn on almost every .c file in the linux kernel due to the decision to
use // SPDX-License-Identifier: at the start of every c file

Maybe this is better:

Just don't perform any other per-line checks on a valid or invalid SPDX line.

---
 scripts/checkpatch.pl | 1 +
 1 file changed, 1 insertion(+)
scripts/checkpatch.pl +1 -0
index 529c892..3f2ae7 100755
@@ -3171,6 +3171,7 @@ sub process {
 						WARN("SPDX_LICENSE_TAG",
 						     "'$spdx_license' is not supported in LICENSES/...\n" . $herecurr);
 					}
+					next;
 				}
 			}
 		}
#4 lore raw

Hi Joe,

Quoted 13 lines · Joe Perches
Quoted 4 lines · Scott Branden

Hi Joe,

Quoted 1 line · Joe Perches

On Wed, 2020-03-11 at 12:11 -0700, Scott Branden wrote:

Quoted 8 lines
Quoted 3 lines
Quoted 2 lines

Always allow C99 comment styles if SPDK-License-Identifier is in comment even if C99_COMMENT_TOLERANCE is specified in the --ignore options.

Why is this useful?

This is useful because if you run checkpatch with --ignore=C99_COMMENT_TOLERANCE
right now it will warn on almost every .c file in the linux kernel due to the decision to
use // SPDX-License-Identifier: at the start of every c file

Quoted 4 lines

Maybe this is better:

Just don't perform any other per-line checks on a valid or invalid SPDX line.

I tried your change and it works as well.
Probably better/simpler if no other processing is needed on lines with SPDX-License-Indentifier: on it.

Would you like to just submit your patch or do I need to construct something?

Quoted 18 lines
---
  scripts/checkpatch.pl | 1 +
  1 file changed, 1 insertion(+)
scripts/checkpatch.pl +1 -0
index 529c892..3f2ae7 100755
@@ -3171,6 +3171,7 @@ sub process {
  						WARN("SPDX_LICENSE_TAG",
  						     "'$spdx_license' is not supported in LICENSES/...\n" . $herecurr);
  					}
+					next;
  				}
  			}
  		}
maintainer
#5 lore raw

PATCH 1/1 checkpatch: No additional checking of SPDX License Identifier necessary

In reply to Scott Branden

If checkpatch is run with --ignore=C99_COMMENT_TOLERANCE it will warn on almost every .c file because linux kernel style requires use of a C99 comment // SPDX-License-Identifier:

checkpatch does not need to do any additional per-line checking after checking the SPDX-License-Identifier line.

This allows the C99 comment style for SPDK-License-Identifier even if C99_COMMENT_TOLERANCE is specified by an --ignore option.

---
 scripts/checkpatch.pl | 1 +
 1 file changed, 1 insertion(+)
scripts/checkpatch.pl +1 -0
index 529c892..3f2ae7 100755
@@ -3171,6 +3171,7 @@ sub process {
 						WARN("SPDX_LICENSE_TAG",
 						     "'$spdx_license' is not supported in LICENSES/...\n" . $herecurr);
 					}
+					next;
 				}
 			}
 		}