From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754705AbcH0B3r (ORCPT ); Fri, 26 Aug 2016 21:29:47 -0400 Received: from smtprelay0127.hostedemail.com ([216.40.44.127]:47107 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753133AbcH0B3r (ORCPT ); Fri, 26 Aug 2016 21:29:47 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::,RULES_HIT:41:355:379:541:800:960:973:982:988:989:1260:1345:1437:1534:1541:1711:1730:1747:1777:1792:2197:2199:2393:2559:2562:3138:3139:3140:3141:3142:3352:3653:3865:3868:3870:4321:4605:5007:6261:7514:7904:10004:10848:11026:11473:11657:11658:11914:12555:13069:13221:13229:13311:13357:14181:14384:14394:14721:21080:21221:21451:30054:30070,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:2,LUA_SUMMARY:none X-HE-Tag: unit96_37fd4621e000e X-Filterd-Recvd-Size: 2222 From: Joe Perches To: Andrew Morton , Andy Whitcroft Cc: Sudip Mukherjee , linux-kernel@vger.kernel.org Subject: [PATCH] checkpatch: Test multiple line block comment alignment Date: Fri, 26 Aug 2016 18:29:43 -0700 Message-Id: X-Mailer: git-send-email 2.8.0.rc4.16.g56331f8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Warn when block comments are not aligned on the * /* * block comment, no warning */ /* * block comment, emit warning */ Reported-by: Sudip Mukherjee Signed-off-by: Joe Perches --- 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