summaryrefslogtreecommitdiffstats
path: root/scripts/checkpatch.pl
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2016-10-11 13:51:50 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2016-10-11 15:06:30 -0700
commit08eb9b8016b18f53fa8900f3d1c9359f9edeb724 (patch)
tree1b616ce4b11712c7d3838c1888ee8ec5b5f8bd51 /scripts/checkpatch.pl
parentf90774e1fd2700de4a6e0d62866d34a26c544bd0 (diff)
downloadlinux-08eb9b8016b18f53fa8900f3d1c9359f9edeb724.tar.bz2
checkpatch: test multiple line block comment alignment
Warn when block comments are not aligned on the * /* * block comment, no warning */ /* * block comment, emit warning */ Link: http://lkml.kernel.org/r/edb57bd330adfe024b95ec2a807d4aa7f0c8b112.1472261299.git.joe@perches.com Signed-off-by: Joe Perches <joe@perches.com> Reported-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts/checkpatch.pl')
-rwxr-xr-xscripts/checkpatch.pl19
1 files changed, 19 insertions, 0 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 1c82b01d581a..894f8c616573 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2979,6 +2979,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*$/ &&