mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Quentin Monnet <quentin@isovalent.com>
To: Andy Whitcroft <apw@canonical.com>, Joe Perches <joe@perches.com>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, Quentin Monnet <quentin@isovalent.com>
Subject: [PATCH] checkpatch: prevent reporting C99_COMMENTS error for SPDX tag in .c file
Date: Tue, 30 Jun 2020 15:35:25 +0100	[thread overview]
Message-ID: <20200630143525.13869-1-quentin@isovalent.com> (raw)

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>
---
 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) {
-- 
2.20.1


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

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-30 14:35 Quentin Monnet [this message]
2020-06-30 14:46 ` Joe Perches
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=20200630143525.13869-1-quentin@isovalent.com \
    --to=quentin@isovalent.com \
    --cc=akpm@linux-foundation.org \
    --cc=apw@canonical.com \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.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®