aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/checkpatch.pl
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2012-12-17 19:01:54 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-12-17 20:15:19 -0500
commit6cd7f3869c925622bbf420e1107a026d91dbd7f2 (patch)
tree23c356d279579726f68ddfdebe54d4e469e25572 /scripts/checkpatch.pl
parent03df4b51f33e1fdd35fe7bc19f1f450726395207 (diff)
checkpatch: allow control over line length warning, default remains 80
Some projects might want a longer line length so allow a command line --max-line-length=n control over the long line warnings. The default line length is 80. Signed-off-by: Joe Perches <joe@perches.com> Cc: Constantine Shulyupin <const@makelinux.com> Cc: Andy Whitcroft <apw@canonical.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts/checkpatch.pl')
-rwxr-xr-xscripts/checkpatch.pl9
1 files changed, 6 insertions, 3 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index a1b870d188c4..6fa167758f82 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -33,6 +33,7 @@ my %ignore_type = ();
33my @ignore = (); 33my @ignore = ();
34my $help = 0; 34my $help = 0;
35my $configuration_file = ".checkpatch.conf"; 35my $configuration_file = ".checkpatch.conf";
36my $max_line_length = 80;
36 37
37sub help { 38sub help {
38 my ($exitcode) = @_; 39 my ($exitcode) = @_;
@@ -51,6 +52,7 @@ Options:
51 -f, --file treat FILE as regular source file 52 -f, --file treat FILE as regular source file
52 --subjective, --strict enable more subjective tests 53 --subjective, --strict enable more subjective tests
53 --ignore TYPE(,TYPE2...) ignore various comma separated message types 54 --ignore TYPE(,TYPE2...) ignore various comma separated message types
55 --max-line-length=n set the maximum line length, if exceeded, warn
54 --show-types show the message "types" in the output 56 --show-types show the message "types" in the output
55 --root=PATH PATH to the kernel tree root 57 --root=PATH PATH to the kernel tree root
56 --no-summary suppress the per-file summary 58 --no-summary suppress the per-file summary
@@ -107,6 +109,7 @@ GetOptions(
107 'strict!' => \$check, 109 'strict!' => \$check,
108 'ignore=s' => \@ignore, 110 'ignore=s' => \@ignore,
109 'show-types!' => \$show_types, 111 'show-types!' => \$show_types,
112 'max-line-length=i' => \$max_line_length,
110 'root=s' => \$root, 113 'root=s' => \$root,
111 'summary!' => \$summary, 114 'summary!' => \$summary,
112 'mailback!' => \$mailback, 115 'mailback!' => \$mailback,
@@ -1760,15 +1763,15 @@ sub process {
1760# check we are in a valid source file if not then ignore this hunk 1763# check we are in a valid source file if not then ignore this hunk
1761 next if ($realfile !~ /\.(h|c|s|S|pl|sh)$/); 1764 next if ($realfile !~ /\.(h|c|s|S|pl|sh)$/);
1762 1765
1763#80 column limit 1766#line length limit
1764 if ($line =~ /^\+/ && $prevrawline !~ /\/\*\*/ && 1767 if ($line =~ /^\+/ && $prevrawline !~ /\/\*\*/ &&
1765 $rawline !~ /^.\s*\*\s*\@$Ident\s/ && 1768 $rawline !~ /^.\s*\*\s*\@$Ident\s/ &&
1766 !($line =~ /^\+\s*$logFunctions\s*\(\s*(?:(KERN_\S+\s*|[^"]*))?"[X\t]*"\s*(?:|,|\)\s*;)\s*$/ || 1769 !($line =~ /^\+\s*$logFunctions\s*\(\s*(?:(KERN_\S+\s*|[^"]*))?"[X\t]*"\s*(?:|,|\)\s*;)\s*$/ ||
1767 $line =~ /^\+\s*"[^"]*"\s*(?:\s*|,|\)\s*;)\s*$/) && 1770 $line =~ /^\+\s*"[^"]*"\s*(?:\s*|,|\)\s*;)\s*$/) &&
1768 $length > 80) 1771 $length > $max_line_length)
1769 { 1772 {
1770 WARN("LONG_LINE", 1773 WARN("LONG_LINE",
1771 "line over 80 characters\n" . $herecurr); 1774 "line over $max_line_length characters\n" . $herecurr);
1772 } 1775 }
1773 1776
1774# Check for user-visible strings broken across lines, which breaks the ability 1777# Check for user-visible strings broken across lines, which breaks the ability