* [PATCH] checkpatch: Test multiple line block comment alignment
@ 2016-08-27 1:29 Joe Perches
0 siblings, 0 replies; only message in thread
From: Joe Perches @ 2016-08-27 1:29 UTC (permalink / raw)
To: Andrew Morton, Andy Whitcroft; +Cc: Sudip Mukherjee, linux-kernel
Warn when block comments are not aligned on the *
/*
* block comment, no warning
*/
/*
* block comment, emit warning
*/
Reported-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Signed-off-by: Joe Perches <joe@perches.com>
---
scripts/checkpatch.pl | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 4de3cc4..a16e0e2 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2939,6 +2939,25 @@ sub process {
"Block comments use a trailing */ on a separate line\n" . $herecurr);
}
+# Block comment * alignment
+ if ($prevline =~ /$;[ \t]*$/ && #ends in comment
+ (($prevrawline =~ /^\+.*?\/\*/ && #starting /*
+ $prevrawline !~ /\*\/[ \t]*$/) || #no trailing */
+ $prevrawline =~ /^\+[ \t]*\*/) && #starting *
+ $rawline =~ /^\+[ \t]*\*/) { #rawline *
+ $prevrawline =~ m@^\+([ \t]*/?)\*@;
+ my $oldindent = expand_tabs($1);
+ $rawline =~ m@^\+([ \t]*)\*@;
+ my $newindent = $1;
+ my $test_comment = '^\\+' . "$;" x (length($newindent) + 1);
+ $newindent = expand_tabs($newindent);
+ if ($line =~ /$test_comment/ &&
+ length($oldindent) ne length($newindent)) {
+ WARN("BLOCK_COMMENT_STYLE",
+ "Block comments should align the * on each line\n" . $hereprev);
+ }
+ }
+
# check for missing blank lines after struct/union declarations
# with exceptions for various attributes and macros
if ($prevline =~ /^[\+ ]};?\s*$/ &&
--
2.8.0.rc4.16.g56331f8
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2016-08-27 1:29 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-27 1:29 [PATCH] checkpatch: Test multiple line block comment alignment Joe Perches
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®