Skip to contentSkip to conversation

checkpatch: allow reporting C99 style comments

PATCH In review Vadim Bendebury 2 participants 5 messages Jan 10, 2019 – Jan 11, 2019 1 message not in the archive Checkpatch

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 checkpatch: allow reporting C99 style comments

Presently C99 style comments are removed unconditionally before actual patch validity check happens. This is a problem for some third party projects which use checkpatch.pl but do not allow C99 style comments.

This patch adds yet another variable, named C99_COMMENT_TOLERANCE. If it is included in the --ignore command line or config file options list, C99 comments in the patch are reported as errors.

Tested by processing a patch with a C99 style comment, it passes the check just fine unless '--ignore C99_COMMENT_TOLERANCE' is present in .checkpatch.conf.

---
 scripts/checkpatch.pl | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
scripts/checkpatch.pl +2 -1
index b737ca9d7204..c5fe10934080 100755
@@ -61,7 +61,6 @@ my $codespellfile = "/usr/share/codespell/dictionary.txt";
 my $conststructsfile = "$D/const_structs.checkpatch";
 my $typedefsfile = "";
 my $color = "auto";
-my $allow_c99_comments = 1;
 
 sub help {
 	my ($exitcode) = @_;
@@ -1250,6 +1249,8 @@ sub sanitise_line {
 	my $off = 0;
 	my $c;
 
+	my $allow_c99_comments = !defined $ignore_type{"C99_COMMENT_TOLERANCE"};
+
 	# Always copy over the diff marker.
 	$res = substr($line, 0, 1);
 
Signature · 1 line
2.20.1.97.g81188d93c3-goog
maintainer
#1 lore raw
Quoted 11 lines · Vadim Bendebury

Presently C99 style comments are removed unconditionally before actual patch validity check happens. This is a problem for some third party projects which use checkpatch.pl but do not allow C99 style comments.

This patch adds yet another variable, named C99_COMMENT_TOLERANCE. If it is included in the --ignore command line or config file options list, C99 comments in the patch are reported as errors.

Tested by processing a patch with a C99 style comment, it passes the check just fine unless '--ignore C99_COMMENT_TOLERANCE' is present in .checkpatch.conf.

I'm not a big fan of the name but I can't think of anything much better.

And the location of the added test isn't good.

scripts/checkpatch.pl

Quoted 1 line
scripts/checkpatch.pl +0 -0

[]

scripts/checkpatch.pl my $codespellfile = "/usr/share/codespell/dictionary.txt"; · line 64

Quoted 5 lines
scripts/checkpatch.pl +0 -1
@@ -61,7 +61,6 @@ my $codespellfile = "/usr/share/codespell/dictionary.txt";
 my $conststructsfile = "$D/const_structs.checkpatch";
 my $typedefsfile = "";
 my $color = "auto";
-my $allow_c99_comments = 1;

Keep this here.

scripts/checkpatch.pl sub sanitise_line { · line 1253

Quoted 8 lines
scripts/checkpatch.pl +2 -0
 sub help {
 	my ($exitcode) = @_;
@@ -1250,6 +1249,8 @@ sub sanitise_line {
 	my $off = 0;
 	my $c;
 
+	my $allow_c99_comments = !defined $ignore_type{"C99_COMMENT_TOLERANCE"};
+

And add this test as a new line near line 1015 like

my $vname;
+$allow_c99_comments = !defined $ignore_type{"C99_COMMENT_TOLERANCE"};
for my $filename (@ARGV) {

#2 lore raw

PATCH 1/1 checkpatch: allow reporting C99 style comments

In reply to Vadim Bendebury

Presently C99 style comments are removed unconditionally before actual patch validity check happens. This is a problem for some third party projects which use checkpatch.pl but do not allow C99 style comments.

This patch adds yet another variable, named C99_COMMENT_TOLERANCE. If it is included in the --ignore command line or config file options list, C99 comments in the patch are reported as errors.

Tested by processing a patch with a C99 style comment, it passes the check just fine unless '--ignore C99_COMMENT_TOLERANCE' is present in .checkpatch.conf.

---
 scripts/checkpatch.pl | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
scripts/checkpatch.pl +2 -1
index b737ca9d7204..8a1aaeb8fa1b 100755
@@ -61,7 +61,7 @@ my $codespellfile = "/usr/share/codespell/dictionary.txt";
 my $conststructsfile = "$D/const_structs.checkpatch";
 my $typedefsfile = "";
 my $color = "auto";
-my $allow_c99_comments = 1;
+my $allow_c99_comments = 1; # Can be overridden by --ignore C99_COMMENT_TOLERANCE
 
 sub help {
 	my ($exitcode) = @_;
@@ -1011,6 +1011,7 @@ if ($git) {
 }
 
 my $vname;
+$allow_c99_comments = !defined $ignore_type{"C99_COMMENT_TOLERANCE"};
 for my $filename (@ARGV) {
 	my $FILE;
 	if ($git) {
Signature · 1 line
2.17.1
maintainer
#3 lore raw
Quoted 8 lines · Vadim Bendebury

Presently C99 style comments are removed unconditionally before actual patch validity check happens. This is a problem for some third party projects which use checkpatch.pl but do not allow C99 style comments.

This patch adds yet another variable, named C99_COMMENT_TOLERANCE. If it is included in the --ignore command line or config file options list, C99 comments in the patch are reported as errors.

Quoted 5 lines

Tested by processing a patch with a C99 style comment, it passes the check just fine unless '--ignore C99_COMMENT_TOLERANCE' is present in .checkpatch.conf.

Seems sensible enough.

Quoted 25 lines
---
 scripts/checkpatch.pl | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
scripts/checkpatch.pl +2 -1
index b737ca9d7204..8a1aaeb8fa1b 100755
@@ -61,7 +61,7 @@ my $codespellfile = "/usr/share/codespell/dictionary.txt";
 my $conststructsfile = "$D/const_structs.checkpatch";
 my $typedefsfile = "";
 my $color = "auto";
-my $allow_c99_comments = 1;
+my $allow_c99_comments = 1; # Can be overridden by --ignore C99_COMMENT_TOLERANCE
 
 sub help {
 	my ($exitcode) = @_;
@@ -1011,6 +1011,7 @@ if ($git) {
 }
 
 my $vname;
+$allow_c99_comments = !defined $ignore_type{"C99_COMMENT_TOLERANCE"};
 for my $filename (@ARGV) {
 	my $FILE;
 	if ($git) {

A message that is not in the archive (sent off-list or not yet received): CAC3GErFi6Hg-E81wpwDV6gpWD0pxM6Rcbj-J9Q6Rs1FOuZ3fNA@mail.gmail.com

maintainer
#5 lore raw
Quoted 3 lines · Vadim Bendebury

Joe,

what are next steps to get this merged

Generally, Andrew Morton will pick it up
and merge it in the next major release.

Quoted 1 line

- do I have to do anything,

Be patient.

Quoted 1 line

is anything still missing?

I think not.