Skip to content

Commit 6cd7f38

Browse files
JoePerchestorvalds
authored andcommitted
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>
1 parent 03df4b5 commit 6cd7f38

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

‎scripts/checkpatch.pl‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
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 @@ sub help {
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 @@ sub help {
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 {
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

0 commit comments

Comments
 (0)