Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756767AbdLPPNz (ORCPT ); Sat, 16 Dec 2017 10:13:55 -0500 Received: from smtprelay0223.hostedemail.com ([216.40.44.223]:45976 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753035AbdLPPNy (ORCPT ); Sat, 16 Dec 2017 10:13:54 -0500 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 57,3.5,0,,d41d8cd98f00b204,joe@perches.com,:::::::::,RULES_HIT:41:355:379:541:599:800:960:968:973:982:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1542:1593:1594:1711:1730:1747:1777:1792:2197:2198:2199:2200:2393:2553:2559:2562:2693:2828:3138:3139:3140:3141:3142:3354:3622:3865:3866:3867:3868:3870:3871:3872:3874:4250:4321:4823:5007:7903:7904:10013:10400:10848:11026:11232:11473:11658:11914:12050:12294:12555:12663:12740:12895:12986:13153:13228:13439:13894:14181:14659:14721:21080:21221:21627:30012:30054:30064:30090:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:2:0,LFtime:2,LUA_SUMMARY:none X-HE-Tag: mine77_21c0269d1be39 X-Filterd-Recvd-Size: 3356 Message-ID: <1513437230.4647.25.camel@perches.com> Subject: Re: [PATCH v2 3/5] checkpatch: Improve --fix-inplace for TABSTOP From: Joe Perches To: Knut Omang , linux-kernel@vger.kernel.org Cc: Andy Whitcroft , Andrew Morton , Dan Carpenter Date: Sat, 16 Dec 2017 07:13:50 -0800 In-Reply-To: <054ce1000f13fb321b84ac474957a759633e5a9d.1513430008.git-series.knut.omang@oracle.com> References: <054ce1000f13fb321b84ac474957a759633e5a9d.1513430008.git-series.knut.omang@oracle.com> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.26.1-1 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2286 Lines: 59 On Sat, 2017-12-16 at 15:42 +0100, Knut Omang wrote: > If the --fix-inplace option for TABSTOP encounters a sitation with several > spaces (but less than 8) at the end of an indentation, it will assume that there > are extra indentation and align back to the nearest tabstop instead of the next. > > This might go undetected in a "full" checkpatch --fix-inplace run, as this > potential new error will be handled by SUSPECT_CODE_INDENT further down in the > script. The code for TABSTOP have limited "knowledge" of the previous line. > Adding complexity when it is taken care of later anyway is maybe unnecessary/undesired. > As a simple heuristics just use a "natural" rounding algorithm and round > up for 4 spaces or more. > > There's an example in line 108 in net/rds/ib_recv.c with indentation TAB + 7 > spaces where the correct would have been an additional TAB. With only TABSTOP > enabled, checkpatch will fix this to a single TAB, which is visually worse IMO. > > Reported-by: H?kon Bugge > Signed-off-by: Knut Omang > Reviewed-by: H?kon Bugge Well written commit log description, thanks but I'm not sure that's actually better overall. It's not possible to know if the appropriate thing to do is to add a tab or remove spaces. This may get it wrong about as often as the current code gets it right. Last I checked 6 months or so ago, there were ~8000 TABSTOP warnings in the kernel tree. Most of those still seem valid and moving additional places to the right is sometimes incorrect too. It seems most common when there are 3 or 4 spaces used as indent level indentation instead of tabs. Dunno. Anyone else have an opinion? > --- > scripts/checkpatch.pl | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl > index 040aa79..febe010 100755 > --- a/scripts/checkpatch.pl > +++ b/scripts/checkpatch.pl > @@ -2989,7 +2989,7 @@ sub process { > if (WARN("TABSTOP", > "Statements should start on a tabstop\n" . $herecurr) && > $fix) { > - $fixed[$fixlinenr] =~ s@(^\+\t+) +@$1 . "\t" x ($indent/8)@e; > + $fixed[$fixlinenr] =~ s@(^\+\t+) +@$1 . "\t" x (($indent+4)/8)@e; > } > } > }