lkml.org 
[lkml]   [2020]   [Jun]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] checkpatch: prevent reporting C99_COMMENTS error for SPDX tag in .c file
Date
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
\
 
 \ /
  Last update: 2020-06-30 16:36    [W:0.089 / U:5.764 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site