From: Joe Perches <joe@perches.com>
To: Yury Norov <ynorov@caviumnetworks.com>, Kien Ha <kienha9922@gmail.com>
Cc: linux-kernel@vger.kernel.org, devel@driverdev.osuosl.org,
Andrew Morton <akpm@linux-foundation.org>,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [PATCH] Fix line too long warning
Date: Sun, 29 Oct 2017 10:28:27 -0700 [thread overview]
Message-ID: <1509298107.26592.26.camel@perches.com> (raw)
In-Reply-To: <20171029155409.5pntisfklykssda4@yury-thinkpad>
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);
}
next prev parent reply other threads:[~2017-10-29 17:28 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-29 2:46 Kien Ha
2017-10-29 15:19 ` Joe Perches
2017-10-29 15:54 ` Yury Norov
2017-10-29 16:29 ` Yury Norov
2017-10-29 17:22 ` Kien Ha
2017-10-29 17:28 ` Joe Perches [this message]
2017-10-29 18:34 ` Yury Norov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1509298107.26592.26.camel@perches.com \
--to=joe@perches.com \
--cc=akpm@linux-foundation.org \
--cc=devel@driverdev.osuosl.org \
--cc=kienha9922@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=ynorov@caviumnetworks.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®