From: Joe Perches <joe@perches.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Whitcroft <apw@canonical.com>, LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH] scripts/checkpatch.pl: Change long line warning to 105 chars
Date: Sat, 06 Mar 2010 14:11:39 -0800 [thread overview]
Message-ID: <1267913499.849.45.camel@Joe-Laptop.home> (raw)
Made the length test a variable for easier bike shedding.
Also add --strict tests for longer than 80 chars and more
than 6 leading tabs
Signed-off-by: Joe Perches <joe@perches.com>
---
scripts/checkpatch.pl | 24 ++++++++++++++++++------
1 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index a4d7434..2c5f30c 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -30,6 +30,10 @@ my $root;
my %debug;
my $help = 0;
+# Code style warnings
+my $style_long_line = 105;
+my $style_max_leading_tabs = 6;
+
sub help {
my ($exitcode) = @_;
@@ -1385,13 +1389,21 @@ sub process {
# check we are in a valid source file if not then ignore this hunk
next if ($realfile !~ /\.(h|c|s|S|pl|sh)$/);
-#80 column limit
- if ($line =~ /^\+/ && $prevrawline !~ /\/\*\*/ &&
+#Line too long
+ if ($line =~ /^\+/ &&
+ $prevrawline !~ /\/\*\*/ &&
$rawline !~ /^.\s*\*\s*\@$Ident\s/ &&
- $line !~ /^\+\s*$logFunctions\s*\(\s*(?:KERN_\S+\s*)?"[X\t]*"\s*(?:,|\)\s*;)\s*$/ &&
- $length > 80)
- {
- WARN("line over 80 characters\n" . $herecurr);
+ $line !~ /^\+\s*$logFunctions\s*\(\s*(?:KERN_\S+\s*)?"[X\t]*"\s*(?:,|\)\s*;)\s*$/) {
+ if ($length > $style_long_line) {
+ WARN("line over $style_long_line characters\n" . $herecurr);
+ } elsif ($length > 80) {
+ CHK("line over 80 characters\n" . $herecurr);
+ }
+ }
+
+#too many leading tabs - deep leading indent
+ if ($line =~ /^\+\t{$style_max_leading_tabs,}(?!(.*,$|.*\);$))/) {
+ CHK("Too many leading tabs. Consider restructuring code\n" . $herecurr);
}
# check for spaces before a quoted newline
next reply other threads:[~2010-03-06 22:11 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-06 22:11 Joe Perches [this message]
-- strict thread matches above, loose matches on Subject: below --
2010-03-10 21:18 Joe Perches
2009-12-15 21:57 [PATCH] Drop 80-character limit in checkpatch.pl Mikulas Patocka
2009-12-17 6:12 ` Paul Mundt
2009-12-17 8:34 ` Krzysztof Halasa
2009-12-17 23:29 ` Mikulas Patocka
2009-12-18 4:29 ` Valdis.Kletnieks
2009-12-18 5:12 ` [PATCH] scripts/checkpatch.pl: Change long line warning to 105 chars Joe Perches
2009-12-18 5:57 ` Paul Mundt
2009-12-18 17:43 ` Linus Torvalds
2009-12-18 17:54 ` Joe Perches
2009-12-18 18:41 ` Andi Kleen
2009-12-18 14:37 ` Krzysztof Halasa
2009-12-18 17:31 ` Joe Perches
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=1267913499.849.45.camel@Joe-Laptop.home \
--to=joe@perches.com \
--cc=akpm@linux-foundation.org \
--cc=apw@canonical.com \
--cc=linux-kernel@vger.kernel.org \
/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®