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>
This commit is contained in:
parent
03df4b51f3
commit
6cd7f3869c
|
@ -33,6 +33,7 @@ my %ignore_type = ();
|
||||||
my @ignore = ();
|
my @ignore = ();
|
||||||
my $help = 0;
|
my $help = 0;
|
||||||
my $configuration_file = ".checkpatch.conf";
|
my $configuration_file = ".checkpatch.conf";
|
||||||
|
my $max_line_length = 80;
|
||||||
|
|
||||||
sub help {
|
sub help {
|
||||||
my ($exitcode) = @_;
|
my ($exitcode) = @_;
|
||||||
|
@ -51,6 +52,7 @@ Options:
|
||||||
-f, --file treat FILE as regular source file
|
-f, --file treat FILE as regular source file
|
||||||
--subjective, --strict enable more subjective tests
|
--subjective, --strict enable more subjective tests
|
||||||
--ignore TYPE(,TYPE2...) ignore various comma separated message types
|
--ignore TYPE(,TYPE2...) ignore various comma separated message types
|
||||||
|
--max-line-length=n set the maximum line length, if exceeded, warn
|
||||||
--show-types show the message "types" in the output
|
--show-types show the message "types" in the output
|
||||||
--root=PATH PATH to the kernel tree root
|
--root=PATH PATH to the kernel tree root
|
||||||
--no-summary suppress the per-file summary
|
--no-summary suppress the per-file summary
|
||||||
|
@ -107,6 +109,7 @@ GetOptions(
|
||||||
'strict!' => \$check,
|
'strict!' => \$check,
|
||||||
'ignore=s' => \@ignore,
|
'ignore=s' => \@ignore,
|
||||||
'show-types!' => \$show_types,
|
'show-types!' => \$show_types,
|
||||||
|
'max-line-length=i' => \$max_line_length,
|
||||||
'root=s' => \$root,
|
'root=s' => \$root,
|
||||||
'summary!' => \$summary,
|
'summary!' => \$summary,
|
||||||
'mailback!' => \$mailback,
|
'mailback!' => \$mailback,
|
||||||
|
@ -1760,15 +1763,15 @@ sub process {
|
||||||
# check we are in a valid source file if not then ignore this hunk
|
# check we are in a valid source file if not then ignore this hunk
|
||||||
next if ($realfile !~ /\.(h|c|s|S|pl|sh)$/);
|
next if ($realfile !~ /\.(h|c|s|S|pl|sh)$/);
|
||||||
|
|
||||||
#80 column limit
|
#line length limit
|
||||||
if ($line =~ /^\+/ && $prevrawline !~ /\/\*\*/ &&
|
if ($line =~ /^\+/ && $prevrawline !~ /\/\*\*/ &&
|
||||||
$rawline !~ /^.\s*\*\s*\@$Ident\s/ &&
|
$rawline !~ /^.\s*\*\s*\@$Ident\s/ &&
|
||||||
!($line =~ /^\+\s*$logFunctions\s*\(\s*(?:(KERN_\S+\s*|[^"]*))?"[X\t]*"\s*(?:|,|\)\s*;)\s*$/ ||
|
!($line =~ /^\+\s*$logFunctions\s*\(\s*(?:(KERN_\S+\s*|[^"]*))?"[X\t]*"\s*(?:|,|\)\s*;)\s*$/ ||
|
||||||
$line =~ /^\+\s*"[^"]*"\s*(?:\s*|,|\)\s*;)\s*$/) &&
|
$line =~ /^\+\s*"[^"]*"\s*(?:\s*|,|\)\s*;)\s*$/) &&
|
||||||
$length > 80)
|
$length > $max_line_length)
|
||||||
{
|
{
|
||||||
WARN("LONG_LINE",
|
WARN("LONG_LINE",
|
||||||
"line over 80 characters\n" . $herecurr);
|
"line over $max_line_length characters\n" . $herecurr);
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check for user-visible strings broken across lines, which breaks the ability
|
# Check for user-visible strings broken across lines, which breaks the ability
|
||||||
|
|
Loading…
Reference in New Issue