Skip to contentSkip to conversation

checkpatch: allow c99 style // comments

PATCH New [email protected] 1 participant 1 message Aug 2, 2016 Checkpatch

lore
Share & tools
lore
#0 lore raw

PATCH 51/111 checkpatch: allow c99 style // comments

From: Joe Perches <[email protected]>
Subject: checkpatch: allow c99 style // comments

Sanitise the lines that contain c99 comments so that the error doesn't get emitted.

---

 scripts/checkpatch.pl |    6 ++++++
 1 file changed, 6 insertions(+)
scripts/checkpatch.pl renamed from scripts/checkpatch.pl~checkpatch-allow-c99-style-comments +6 -0
diff -puN scripts/checkpatch.pl~checkpatch-allow-c99-style-comments scripts/checkpatch.pl
@@ -55,6 +55,7 @@ my $spelling_file = "$D/spelling.txt";
 my $codespell = 0;
 my $codespellfile = "/usr/share/codespell/dictionary.txt";
 my $color = 1;
+my $allow_c99_comments = 1;
 
 sub help {
 	my ($exitcode) = @_;
@@ -1144,6 +1145,11 @@ sub sanitise_line {
 		$res =~ s@(\#\s*(?:error|warning)\s+).*@$1$clean@;
 	}
 
+	if ($allow_c99_comments && $res =~ m@(//.*$)@) {
+		my $match = $1;
+		$res =~ s/\Q$match\E/"$;" x length($match)/e;
+	}
+
 	return $res;
 }
 

_