Commit 6cd7f3869c925622bbf420e1107a026d91dbd7f2

Authored by Joe Perches
Committed by Linus Torvalds
1 parent 03df4b51f3

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>

Showing 1 changed file with 6 additions and 3 deletions Side-by-side Diff

scripts/checkpatch.pl
... ... @@ -33,6 +33,7 @@
33 33 my @ignore = ();
34 34 my $help = 0;
35 35 my $configuration_file = ".checkpatch.conf";
  36 +my $max_line_length = 80;
36 37  
37 38 sub help {
38 39 my ($exitcode) = @_;
... ... @@ -51,6 +52,7 @@
51 52 -f, --file treat FILE as regular source file
52 53 --subjective, --strict enable more subjective tests
53 54 --ignore TYPE(,TYPE2...) ignore various comma separated message types
  55 + --max-line-length=n set the maximum line length, if exceeded, warn
54 56 --show-types show the message "types" in the output
55 57 --root=PATH PATH to the kernel tree root
56 58 --no-summary suppress the per-file summary
... ... @@ -107,6 +109,7 @@
107 109 'strict!' => \$check,
108 110 'ignore=s' => \@ignore,
109 111 'show-types!' => \$show_types,
  112 + 'max-line-length=i' => \$max_line_length,
110 113 'root=s' => \$root,
111 114 'summary!' => \$summary,
112 115 'mailback!' => \$mailback,
113 116  
114 117  
... ... @@ -1760,15 +1763,15 @@
1760 1763 # check we are in a valid source file if not then ignore this hunk
1761 1764 next if ($realfile !~ /\.(h|c|s|S|pl|sh)$/);
1762 1765  
1763   -#80 column limit
  1766 +#line length limit
1764 1767 if ($line =~ /^\+/ && $prevrawline !~ /\/\*\*/ &&
1765 1768 $rawline !~ /^.\s*\*\s*\@$Ident\s/ &&
1766 1769 !($line =~ /^\+\s*$logFunctions\s*\(\s*(?:(KERN_\S+\s*|[^"]*))?"[X\t]*"\s*(?:|,|\)\s*;)\s*$/ ||
1767 1770 $line =~ /^\+\s*"[^"]*"\s*(?:\s*|,|\)\s*;)\s*$/) &&
1768   - $length > 80)
  1771 + $length > $max_line_length)
1769 1772 {
1770 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 1777 # Check for user-visible strings broken across lines, which breaks the ability