From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751559AbdJ2R2f (ORCPT ); Sun, 29 Oct 2017 13:28:35 -0400 Received: from smtprelay0064.hostedemail.com ([216.40.44.64]:39802 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751405AbdJ2R2d (ORCPT ); Sun, 29 Oct 2017 13:28:33 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::,RULES_HIT:41:355:379:541:599: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:2199:2393:2559:2562:2693:2828:2898:3138:3139:3140:3141:3142:3354:3608:3622:3653:3865:3866:3867:3868:3870:3871:3872:3873:3874:4321:4823:5007:7875:7903:7904:10004:10400:10450:10455:10848:11026:11232:11658:11914:12043:12555:12740:12760:12895:12986:13439:13548:14093:14097:14181:14659:14721:14824:19904:19999:21080:21221:21324:21433:21451:21611:21627:30003:30006:30012:30054: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:0:0,LFtime:2,LUA_SUMMARY:none X-HE-Tag: stop47_fdb197eb743b X-Filterd-Recvd-Size: 3136 Message-ID: <1509298107.26592.26.camel@perches.com> Subject: Re: [PATCH] Fix line too long warning From: Joe Perches To: Yury Norov , Kien Ha Cc: linux-kernel@vger.kernel.org, devel@driverdev.osuosl.org, Andrew Morton , Linus Torvalds Date: Sun, 29 Oct 2017 10:28:27 -0700 In-Reply-To: <20171029155409.5pntisfklykssda4@yury-thinkpad> References: <1509245173.3669.5.camel@gmail.com> <20171029155409.5pntisfklykssda4@yury-thinkpad> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.26.1-1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 2017-10-29 at 18:54 +0300, Yury Norov wrote: > At second, and most important, refer Documentation/process/coding-style.rst: > Now, some people will claim that having 8-character indentations makes > the code move too far to the right, and makes it hard to read on a > 80-character terminal screen. The answer to that is that if you need > more than 3 levels of indentation, you're screwed anyway, and should fix > your program. > > The real problem here is not "line too long", but "indentation level too > big" - 5. And it worth to address real problem. Line length issues can be a combination of several factors: o identifier length o quantity of dereferences o indentation depth o code complexity 4 indentation depth levels are not a real issue. A significant percentage of lines in the kernel are 4 or more tab indent levels deep. checkpatch suggests that 6 or more is the depth level that should cause real concern. Here's a little breakdown of lines that start with a tab followed by a c90 keyword in the kernel $ git grep -P "^\t+(if|for|do|while|\}|else|switch|return|case|break|continue|goto)\b" -- "*.[ch]" | \ cut -f2- -d":" | perl -p -e 's/(^\t+).*/\1/' | \ sort | uniq -c | sort -rn | \ awk '{total += $1; count[i++] = $1} END { for (j = 0; j < i; j++) { printf "%d\t%d\t%.2f%%\n", j + 1, count[j], count[j] / total * 100 }}' 1 1325462 52.19% 2 863007 33.98% 3 271844 10.70% 4 64009 2.52% 5 12502 0.49% 6 2199 0.09% 7 501 0.02% 8 166 0.01% 9 51 0.00% 10 20 0.00% 11 10 0.00% 12 4 0.00% 13 1 0.00% I think it could reasonably be argued that the indentation depth warning (DEEP_INDENTATION) should start at 5 and not at 6. --- scripts/checkpatch.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 6bdd43d5dec5..923e4ff09d24 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -3353,7 +3353,7 @@ sub process { my ($level, @ctx) = ctx_statement_level($linenr, $realcnt, 0); - if ($line =~ /^\+\t{6,}/) { + if ($line =~ /^\+\t{5,}/) { WARN("DEEP_INDENTATION", "Too many leading tabs - consider code refactoring\n" . $herecurr); }