History

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.

Joe Perches committed 13 years ago

Commit 6cd7f381 parent 03df4b51 file · +6 −3Browse files

Showing the changes to scripts/checkpatch.pl (1 of 1 file). Show all

Unified · Split

scripts/checkpatch.pl+6−3
@@ -33,6 +33,7 @@ my %ignore_type = (); · 32 unmodified lines
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: · 12 unmodified lines
51 -f, --file treat FILE as regular source file52 -f, --file treat FILE as regular source file
52 --subjective, --strict enable more subjective tests53 --subjective, --strict enable more subjective tests
53 --ignore TYPE(,TYPE2...) ignore various comma separated message types54 --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 output56 --show-types show the message "types" in the output
55 --root=PATH PATH to the kernel tree root57 --root=PATH PATH to the kernel tree root
56 --no-summary suppress the per-file summary58 --no-summary suppress the per-file summary
@@ -107,6 +109,7 @@ GetOptions( · 50 unmodified lines
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 { · 1647 unmodified lines
1760# check we are in a valid source file if not then ignore this hunk1763# 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 limit1766#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 ability1777# Check for user-visible strings broken across lines, which breaks the ability

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t