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
3333 my @ignore = ();
3434 my $help = 0;
3535 my $configuration_file = ".checkpatch.conf";
36+my $max_line_length = 80;
3637
3738 sub help {
3839 my ($exitcode) = @_;
@@ -51,6 +52,7 @@ Options: · 12 unmodified lines
5152 -f, --file treat FILE as regular source file
5253 --subjective, --strict enable more subjective tests
5354 --ignore TYPE(,TYPE2...) ignore various comma separated message types
55+ --max-line-length=n set the maximum line length, if exceeded, warn
5456 --show-types show the message "types" in the output
5557 --root=PATH PATH to the kernel tree root
5658 --no-summary suppress the per-file summary
@@ -107,6 +109,7 @@ GetOptions( · 50 unmodified lines
107109 'strict!' => \$check,
108110 'ignore=s' => \@ignore,
109111 'show-types!' => \$show_types,
112+ 'max-line-length=i' => \$max_line_length,
110113 'root=s' => \$root,
111114 'summary!' => \$summary,
112115 'mailback!' => \$mailback,
@@ -1760,15 +1763,15 @@ sub process { · 1647 unmodified lines
17601763 # check we are in a valid source file if not then ignore this hunk
17611764 next if ($realfile !~ /\.(h|c|s|S|pl|sh)$/);
17621765
1763−#80 column limit
1766+#line length limit
17641767 if ($line =~ /^\+/ && $prevrawline !~ /\/\*\*/ &&
17651768 $rawline !~ /^.\s*\*\s*\@$Ident\s/ &&
17661769 !($line =~ /^\+\s*$logFunctions\s*\(\s*(?:(KERN_\S+\s*|[^"]*))?"[X\t]*"\s*(?:|,|\)\s*;)\s*$/ ||
17671770 $line =~ /^\+\s*"[^"]*"\s*(?:\s*|,|\)\s*;)\s*$/) &&
1768− $length > 80)
1771+ $length > $max_line_length)
17691772 {
17701773 WARN("LONG_LINE",
1771− "line over 80 characters\n" . $herecurr);
1774+ "line over $max_line_length characters\n" . $herecurr);
17721775 }
17731776
17741777 # 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