[PATCH] checkpatch: Allow comments in macros tested for single statements

Joe Perches joe at perches.com
Thu Jan 8 16:31:33 EST 2015

Convert all the comments to spaces before testing for
single statement macros.

Reported-by: Valdis Kletnieks <Valdis.Kletnieks at vt.edu>
Signed-off-by: Joe Perches <joe at perches.com>
> It's interesting that the warning only popped on the one case where the
> "/* looping version */" is on a separate line, not on the #else line.
> Am cc'ing Joe Perches for that question. Joe - to get you up to speed,
> checkpatch was run against drivers/staging/skein/skein_block.c, and it
> flagged one definition of the macro R256, but not the other one, or the
> two definitions each for R512 and R1024.  Any idea why?

Yup, that was it...

 scripts/checkpatch.pl | 1 +
 1 file changed, 1 insertion(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 6afc24b..6ac355e 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -4260,6 +4260,7 @@ sub process {
 			$ctx = $dstat;
 			$dstat =~ s/\\\n.//g;
+			$dstat =~ s/$;/ /g;
 			if ($dstat =~ /^\+\s*#\s*define\s+$Ident\s*${balanced_parens}\s*do\s*{(.*)\s*}\s*while\s*\(\s*0\s*\)\s*([;\s]*)\s*$/) {
 				my $stmts = $2;

More information about the Kernelnewbies mailing list