[patch] checkpatch: relax spacing and line length

From: Jan Engelhardt
Date: Sun Apr 06 2008 - 00:55:14 EST


===
total: 0 errors, 0 warnings, 36 lines checked

d27a9f5.diff has no obvious style problems and is ready for submission.
===
commit d27a9f5760fa231ab888f96e27355a001c88b239
Author: Jan Engelhardt <jengelh@xxxxxxxxxxxxxxx>
Date: Sun Apr 6 06:49:01 2008 +0200

checkpatch: relax spacing and line length

We all had the arguments about 80 columns, so here goes a relax.
Checking for 95 (or perhaps something better?), but of course we
print "80" in the output, because if you happened to get to 95, it's
"really time" to break it.

This also relaxes the tab doctrine, because spaces DO make sense --
especially when you view the code with a tab setting of not-8.

Signed-off-by: Jan Engelhardt <jengelh@xxxxxxxxxxxxxxx>
---
scripts/checkpatch.pl | 22 ++++++++++++++++------
1 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 58a9494..e5a96c1 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1094,8 +1094,8 @@ sub process {
my $herevet = "$here\n" . cat_vet($rawline) . "\n";
ERROR("trailing whitespace\n" . $herevet);
}
-#80 column limit
- if ($line =~ /^\+/ && !($prevrawline=~/\/\*\*/) && $length > 80) {
+#80 column limit (yes, testing for 95 is correct, we do not want to annoy)
+ if ($line =~ /^\+/ && !($prevrawline=~/\/\*\*/) && $length >= 95) {
WARN("line over 80 characters\n" . $herecurr);
}

@@ -1107,12 +1107,22 @@ sub process {
# check we are in a valid source file *.[hc] if not then ignore this hunk
next if ($realfile !~ /\.[hc]$/);

+ my $arg = qr/$Type(?: ?$Ident)?/;
+ if ($rawline =~ /^\+ +($arg, )*$arg(?:,|\);?)$/) {
+ # We are probably in a function parameter list.
+ # Spaces ok -- used for align.
+ } elsif ($rawline =~ /^\+\t+ *\S/) {
+ # We are probably in a function or an array/struct
+ # definition/initializer. Spaces ok -- used for align
+ # on multiline statements.
+ } else {
# at the beginning of a line any tabs must come first and anything
# more than 8 must use tabs.
- if ($rawline =~ /^\+\s* \t\s*\S/ ||
- $rawline =~ /^\+\s* \s*/) {
- my $herevet = "$here\n" . cat_vet($rawline) . "\n";
- ERROR("use tabs not spaces\n" . $herevet);
+ if ($rawline =~ /^\+\s* \t\s*\S/ ||
+ $rawline =~ /^\+\s* \s*/) {
+ my $herevet = "$here\n" . cat_vet($rawline) . "\n";
+ ERROR("use tabs not spaces\n" . $herevet);
+ }
}

# check for RCS/CVS revision markers

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/