LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] checkpatch: always allow C99 SPDX License Identifer comments
@ 2020-03-11 19:11 Scott Branden
  2020-03-12  2:26 ` Joe Perches
  0 siblings, 1 reply; 6+ messages in thread
From: Scott Branden @ 2020-03-11 19:11 UTC (permalink / raw)
  To: Andy Whitcroft, Joe Perches, Greg Kroah-Hartman
  Cc: linux-kernel, bcm-kernel-feedback-list, 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.

Signed-off-by: Scott Branden <scott.branden@broadcom.com>
---
 scripts/checkpatch.pl | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index a63380c6b0d2..c8b429dd6b51 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -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.17.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] checkpatch: always allow C99 SPDX License Identifer comments
  2020-03-11 19:11 [PATCH] checkpatch: always allow C99 SPDX License Identifer comments Scott Branden
@ 2020-03-12  2:26 ` Joe Perches
  2020-03-12  2:48   ` Scott Branden
  0 siblings, 1 reply; 6+ messages in thread
From: Joe Perches @ 2020-03-12  2:26 UTC (permalink / raw)
  To: Scott Branden, Andy Whitcroft, Greg Kroah-Hartman
  Cc: linux-kernel, bcm-kernel-feedback-list

On Wed, 2020-03-11 at 12:11 -0700, Scott Branden wrote:
> 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?

> Signed-off-by: Scott Branden <scott.branden@broadcom.com>
> ---
>  scripts/checkpatch.pl | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index a63380c6b0d2..c8b429dd6b51 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -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) {


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] checkpatch: always allow C99 SPDX License Identifer comments
  2020-03-12  2:26 ` Joe Perches
@ 2020-03-12  2:48   ` Scott Branden
  2020-03-12  4:42     ` Joe Perches
  2020-03-13  8:21     ` [PATCH] checkpatch: No additional checking of SPDX License Identifier necessary Joe Perches
  0 siblings, 2 replies; 6+ messages in thread
From: Scott Branden @ 2020-03-12  2:48 UTC (permalink / raw)
  To: Joe Perches, Andy Whitcroft, Greg Kroah-Hartman
  Cc: linux-kernel, bcm-kernel-feedback-list

Hi Joe,

On 2020-03-11 7:26 p.m., Joe Perches wrote:
> On Wed, 2020-03-11 at 12:11 -0700, Scott Branden wrote:
>> 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...
>
>> Signed-off-by: Scott Branden <scott.branden@broadcom.com>
>> ---
>>   scripts/checkpatch.pl | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
>> index a63380c6b0d2..c8b429dd6b51 100755
>> --- a/scripts/checkpatch.pl
>> +++ b/scripts/checkpatch.pl
>> @@ -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) {


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] checkpatch: always allow C99 SPDX License Identifer comments
  2020-03-12  2:48   ` Scott Branden
@ 2020-03-12  4:42     ` Joe Perches
  2020-03-13  2:47       ` Scott Branden
  2020-03-13  8:21     ` [PATCH] checkpatch: No additional checking of SPDX License Identifier necessary Joe Perches
  1 sibling, 1 reply; 6+ messages in thread
From: Joe Perches @ 2020-03-12  4:42 UTC (permalink / raw)
  To: Scott Branden, Andy Whitcroft, Greg Kroah-Hartman
  Cc: linux-kernel, bcm-kernel-feedback-list

On Wed, 2020-03-11 at 19:48 -0700, Scott Branden wrote:
> Hi Joe,
> 
> On 2020-03-11 7:26 p.m., Joe Perches wrote:
> > On Wed, 2020-03-11 at 12:11 -0700, Scott Branden wrote:
> > > 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(+)

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



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] checkpatch: always allow C99 SPDX License Identifer comments
  2020-03-12  4:42     ` Joe Perches
@ 2020-03-13  2:47       ` Scott Branden
  0 siblings, 0 replies; 6+ messages in thread
From: Scott Branden @ 2020-03-13  2:47 UTC (permalink / raw)
  To: Joe Perches, Andy Whitcroft, Greg Kroah-Hartman
  Cc: linux-kernel, bcm-kernel-feedback-list

Hi Joe,

On 2020-03-11 9:42 p.m., Joe Perches wrote:
> On Wed, 2020-03-11 at 19:48 -0700, Scott Branden wrote:
>> Hi Joe,
>>
>> On 2020-03-11 7:26 p.m., Joe Perches wrote:
>>> On Wed, 2020-03-11 at 12:11 -0700, Scott Branden wrote:
>>>> 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.
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?
> ---
>   scripts/checkpatch.pl | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 529c892..3f2ae7 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -3171,6 +3171,7 @@ sub process {
>   						WARN("SPDX_LICENSE_TAG",
>   						     "'$spdx_license' is not supported in LICENSES/...\n" . $herecurr);
>   					}
> +					next;
>   				}
>   			}
>   		}
>
>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] checkpatch: No additional checking of SPDX License Identifier necessary
  2020-03-12  2:48   ` Scott Branden
  2020-03-12  4:42     ` Joe Perches
@ 2020-03-13  8:21     ` Joe Perches
  1 sibling, 0 replies; 6+ messages in thread
From: Joe Perches @ 2020-03-13  8:21 UTC (permalink / raw)
  To: Scott Branden, Andy Whitcroft, Greg Kroah-Hartman, Andrew Morton
  Cc: linux-kernel, bcm-kernel-feedback-list

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.

Original-patch-by: Scott Branden <scott.branden@broadcom.com>
Signed-off-by: Joe Perches <joe@perches.com>
---
 scripts/checkpatch.pl | 1 +
 1 file changed, 1 insertion(+)

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




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-03-13  8:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-11 19:11 [PATCH] checkpatch: always allow C99 SPDX License Identifer comments Scott Branden
2020-03-12  2:26 ` Joe Perches
2020-03-12  2:48   ` Scott Branden
2020-03-12  4:42     ` Joe Perches
2020-03-13  2:47       ` Scott Branden
2020-03-13  8:21     ` [PATCH] checkpatch: No additional checking of SPDX License Identifier necessary Joe Perches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).