mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Quentin Monnet <quentin@isovalent.com>,
	Andy Whitcroft <apw@canonical.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Vadim Bendebury <vbendeb@chromium.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] checkpatch: prevent reporting C99_COMMENTS error for SPDX tag in .c file
Date: Tue, 30 Jun 2020 07:46:57 -0700	[thread overview]
Message-ID: <39ba164ba44be848feac831f2f21effca92bfc96.camel@perches.com> (raw)
In-Reply-To: <20200630143525.13869-1-quentin@isovalent.com>

(adding Vadem Bendebury who added the tolerance test)

On Tue, 2020-06-30 at 15:35 +0100, Quentin Monnet wrote:
> When checkpatch.pl is invoked with "--ignore C99_COMMENT_TOLERANCE", it
> reports C99-style comments found in the code, by matching on the
> double-slash pattern "//". This includes the leading slashes before the
> SPDX tags that are now used in a majority of C files.
> 
> Such tags are commented with the double-slash on purpose, and should not
> trigger errors from checkpatch. Let's ignore them when searching for
> C99-style comments to report.
> 
> Signed-off-by: Quentin Monnet <quentin@isovalent.com>

I think this unnecessary as perhaps those that want no
c99 comments likely _really_ want no c99 comments.

> ---
>  scripts/checkpatch.pl | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 3cacc122c528..67f350c580ea 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -3983,7 +3983,10 @@ sub process {
>  		}
>  
>  # no C99 // comments
> -		if ($line =~ m{//}) {
> +		if ($line =~ m{//} &&
> +		    !($rawline =~ m{// SPDX-License-Identifier:} &&
> +		      $realfile =~ /\.c$/ &&
> +		      $realline == $checklicenseline)) {
>  			if (ERROR("C99_COMMENTS",
>  				  "do not use C99 // comments\n" . $herecurr) &&
>  			    $fix) {


  reply	other threads:[~2020-06-30 14:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-30 14:35 Quentin Monnet
2020-06-30 14:46 ` Joe Perches [this message]
2020-06-30 17:20   ` Vadim Bendebury
2020-06-30 21:30     ` Quentin Monnet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=39ba164ba44be848feac831f2f21effca92bfc96.camel@perches.com \
    --to=joe@perches.com \
    --cc=akpm@linux-foundation.org \
    --cc=apw@canonical.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=quentin@isovalent.com \
    --cc=vbendeb@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®