util/lint: Update checkpatch & files to upstream linux

- Update checkpatch.pl to version 522b837
(checkpatch: warn when formats use %Z and suggest %z)

- This update moves the const_struct definitions into an external file.
coreboot will want to update this file, but for now I'm just pulling it
in directly from the linux tree.

- Update spelling.txt used by checkpatch.pl to version 505d308
(scripts/spelling.txt: add "overide" pattern and fix typo instances)

- Add better notes where things have been changed for coreboot to make
future merges easier.

Change-Id: I0ef067874fe7b1d23276a10e63858895d6083f69
Signed-off-by: Martin Roth <martinroth@google.com>
Reviewed-on: https://review.coreboot.org/18810
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
This commit is contained in:
Martin Roth 2017-03-14 10:16:29 -06:00
parent 96b89ae5eb
commit edd591d8ca
3 changed files with 492 additions and 153 deletions

View File

@ -38,14 +38,14 @@ my $show_types = 0;
my $list_types = 0; my $list_types = 0;
my $fix = 0; my $fix = 0;
my $fix_inplace = 0; my $fix_inplace = 0;
my $root; my $root = $P; #coreboot
my %debug; my %debug;
my %camelcase = (); my %camelcase = ();
my %use_type = (); my %use_type = ();
my @use = (); my @use = ();
my %ignore_type = (); my %ignore_type = ();
my @ignore = (); my @ignore = ();
my @exclude = (); my @exclude = (); #coreboot
my $help = 0; my $help = 0;
my $configuration_file = ".checkpatch.conf"; my $configuration_file = ".checkpatch.conf";
my $max_line_length = 80; my $max_line_length = 80;
@ -55,7 +55,9 @@ my $min_conf_desc_length = 4;
my $spelling_file = "$D/spelling.txt"; my $spelling_file = "$D/spelling.txt";
my $codespell = 0; my $codespell = 0;
my $codespellfile = "/usr/share/codespell/dictionary.txt"; my $codespellfile = "/usr/share/codespell/dictionary.txt";
my $conststructsfile = "$D/const_structs.checkpatch";
my $color = 1; my $color = 1;
my $allow_c99_comments = 1;
sub help { sub help {
my ($exitcode) = @_; my ($exitcode) = @_;
@ -192,7 +194,7 @@ GetOptions(
'subjective!' => \$check, 'subjective!' => \$check,
'strict!' => \$check, 'strict!' => \$check,
'ignore=s' => \@ignore, 'ignore=s' => \@ignore,
'exclude=s' => \@exclude, 'exclude=s' => \@exclude, #coreboot
'types=s' => \@use, 'types=s' => \@use,
'show-types!' => \$show_types, 'show-types!' => \$show_types,
'list-types!' => \$list_types, 'list-types!' => \$list_types,
@ -230,9 +232,9 @@ if ($^V && $^V lt $minimum_perl_version) {
} }
} }
#if no filenames are given, push '-' to read patch from stdin
if ($#ARGV < 0) { if ($#ARGV < 0) {
print "$P: no input files\n"; push(@ARGV, '-');
exit(1);
} }
sub hash_save_array_words { sub hash_save_array_words {
@ -316,7 +318,6 @@ our $Sparse = qr{
__kernel| __kernel|
__force| __force|
__iomem| __iomem|
__pmem|
__must_check| __must_check|
__init_refok| __init_refok|
__kprobes| __kprobes|
@ -337,7 +338,7 @@ our $Attribute = qr{
__percpu| __percpu|
__nocast| __nocast|
__safe| __safe|
__bitwise__| __bitwise|
__packed__| __packed__|
__packed2__| __packed2__|
__naked| __naked|
@ -426,7 +427,7 @@ our $typeTypedefs = qr{(?x:
our $zero_initializer = qr{(?:(?:0[xX])?0+$Int_type?|NULL|false)\b}; our $zero_initializer = qr{(?:(?:0[xX])?0+$Int_type?|NULL|false)\b};
our $logFunctions = qr{(?x: our $logFunctions = qr{(?x:
printk(?:_ratelimited|_once|)| printk(?:_ratelimited|_once|_deferred_once|_deferred|)|
(?:[a-z0-9]+_){1,2}(?:printk|emerg|alert|crit|err|warning|warn|notice|info|debug|dbg|vdbg|devel|cont|WARN)(?:_ratelimited|_once|)| (?:[a-z0-9]+_){1,2}(?:printk|emerg|alert|crit|err|warning|warn|notice|info|debug|dbg|vdbg|devel|cont|WARN)(?:_ratelimited|_once|)|
WARN(?:_RATELIMIT|_ONCE|)| WARN(?:_RATELIMIT|_ONCE|)|
panic| panic|
@ -526,7 +527,11 @@ our @mode_permission_funcs = (
["module_param_array_named", 5], ["module_param_array_named", 5],
["debugfs_create_(?:file|u8|u16|u32|u64|x8|x16|x32|x64|size_t|atomic_t|bool|blob|regset32|u32_array)", 2], ["debugfs_create_(?:file|u8|u16|u32|u64|x8|x16|x32|x64|size_t|atomic_t|bool|blob|regset32|u32_array)", 2],
["proc_create(?:_data|)", 2], ["proc_create(?:_data|)", 2],
["(?:CLASS|DEVICE|SENSOR)_ATTR", 2], ["(?:CLASS|DEVICE|SENSOR|SENSOR_DEVICE|IIO_DEVICE)_ATTR", 2],
["IIO_DEV_ATTR_[A-Z_]+", 1],
["SENSOR_(?:DEVICE_|)ATTR_2", 2],
["SENSOR_TEMPLATE(?:_2|)", 3],
["__ATTR", 2],
); );
#Create a search pattern for all these functions to speed up a loop below #Create a search pattern for all these functions to speed up a loop below
@ -544,6 +549,32 @@ our $mode_perms_world_writable = qr{
0[0-7][0-7][2367] 0[0-7][0-7][2367]
}x; }x;
our %mode_permission_string_types = (
"S_IRWXU" => 0700,
"S_IRUSR" => 0400,
"S_IWUSR" => 0200,
"S_IXUSR" => 0100,
"S_IRWXG" => 0070,
"S_IRGRP" => 0040,
"S_IWGRP" => 0020,
"S_IXGRP" => 0010,
"S_IRWXO" => 0007,
"S_IROTH" => 0004,
"S_IWOTH" => 0002,
"S_IXOTH" => 0001,
"S_IRWXUGO" => 0777,
"S_IRUGO" => 0444,
"S_IWUGO" => 0222,
"S_IXUGO" => 0111,
);
#Create a search pattern for all these strings to speed up a loop below
our $mode_perms_string_search = "";
foreach my $entry (keys %mode_permission_string_types) {
$mode_perms_string_search .= '|' if ($mode_perms_string_search ne "");
$mode_perms_string_search .= $entry;
}
our $allowed_asm_includes = qr{(?x: our $allowed_asm_includes = qr{(?x:
irq| irq|
memory| memory|
@ -601,6 +632,29 @@ if ($codespell) {
$misspellings = join("|", sort keys %spelling_fix) if keys %spelling_fix; $misspellings = join("|", sort keys %spelling_fix) if keys %spelling_fix;
my $const_structs = "";
if (open(my $conststructs, '<', $conststructsfile)) {
while (<$conststructs>) {
my $line = $_;
$line =~ s/\s*\n?$//g;
$line =~ s/^\s*//g;
next if ($line =~ m/^\s*#/);
next if ($line =~ m/^\s*$/);
if ($line =~ /\s/) {
print("$conststructsfile: '$line' invalid - ignored\n");
next;
}
$const_structs .= '|' if ($const_structs ne "");
$const_structs .= $line;
}
close($conststructsfile);
} else {
warn "No structs that should be const will be found - file '$conststructsfile': $!\n";
}
sub build_types { sub build_types {
my $mods = "(?x: \n" . join("|\n ", (@modifierList, @modifierListFile)) . "\n)"; my $mods = "(?x: \n" . join("|\n ", (@modifierList, @modifierListFile)) . "\n)";
my $all = "(?x: \n" . join("|\n ", (@typeList, @typeListFile)) . "\n)"; my $all = "(?x: \n" . join("|\n ", (@typeList, @typeListFile)) . "\n)";
@ -707,6 +761,16 @@ sub seed_camelcase_file {
} }
} }
sub is_maintained_obsolete {
my ($filename) = @_;
return 0 if (!$tree || !(-e "$root/scripts/get_maintainer.pl"));
my $status = `perl $root/scripts/get_maintainer.pl --status --nom --nol --nogit --nogit-fallback -f $filename 2>&1`;
return $status =~ /obsolete/i;
}
my $camelcase_seeded = 0; my $camelcase_seeded = 0;
sub seed_camelcase_includes { sub seed_camelcase_includes {
return if ($camelcase_seeded); return if ($camelcase_seeded);
@ -1148,6 +1212,11 @@ sub sanitise_line {
$res =~ s@(\#\s*(?:error|warning)\s+).*@$1$clean@; $res =~ s@(\#\s*(?:error|warning)\s+).*@$1$clean@;
} }
if ($allow_c99_comments && $res =~ m@(//.*$)@) {
my $match = $1;
$res =~ s/\Q$match\E/"$;" x length($match)/e;
}
return $res; return $res;
} }
@ -1788,6 +1857,8 @@ my $prefix = '';
sub show_type { sub show_type {
my ($type) = @_; my ($type) = @_;
$type =~ tr/[a-z]/[A-Z]/;
return defined $use_type{$type} if (scalar keys %use_type > 0); return defined $use_type{$type} if (scalar keys %use_type > 0);
return !defined $ignore_type{$type}; return !defined $ignore_type{$type};
@ -2073,7 +2144,8 @@ sub process {
my $is_patch = 0; my $is_patch = 0;
my $in_header_lines = $file ? 0 : 1; my $in_header_lines = $file ? 0 : 1;
my $in_commit_log = 0; #Scanning lines before patch my $in_commit_log = 0; #Scanning lines before patch
my $commit_log_possible_stack_dump = 0; my $has_commit_log = 0; #Encountered lines before patch
my $commit_log_possible_stack_dump = 0;
my $commit_log_long_line = 0; my $commit_log_long_line = 0;
my $commit_log_has_diff = 0; my $commit_log_has_diff = 0;
my $reported_maintainer_file = 0; my $reported_maintainer_file = 0;
@ -2093,6 +2165,7 @@ sub process {
my $realline = 0; my $realline = 0;
my $realcnt = 0; my $realcnt = 0;
my $here = ''; my $here = '';
my $context_function; #undef'd unless there's a known function
my $in_comment = 0; my $in_comment = 0;
my $comment_edge = 0; my $comment_edge = 0;
my $first_line = 0; my $first_line = 0;
@ -2126,12 +2199,13 @@ sub process {
if ($rawline=~/^\+\+\+\s+(\S+)/) { if ($rawline=~/^\+\+\+\s+(\S+)/) {
$setup_docs = 0; $setup_docs = 0;
if ($1 =~ m@Documentation/kernel-parameters.txt$@) { if ($1 =~ m@Documentation/admin-guide/kernel-parameters.rst$@) {
$setup_docs = 1; $setup_docs = 1;
} }
#next; #next;
} }
if ($rawline=~/^\@\@ -\d+(?:,\d+)? \+(\d+)(,(\d+))? \@\@/) { if ($rawline=~/^\@\@ -\d+(?:,\d+)? \+(\d+)(,(\d+))? \@\@(.*)/) {
my $context = $4;
$realline=$1-1; $realline=$1-1;
if (defined $2) { if (defined $2) {
$realcnt=$3+1; $realcnt=$3+1;
@ -2140,6 +2214,12 @@ sub process {
} }
$in_comment = 0; $in_comment = 0;
if ($context =~ /\b(\w+)\s*\(/) {
$context_function = $1;
} else {
undef $context_function;
}
# Guestimate if this is a continuing comment. Run # Guestimate if this is a continuing comment. Run
# the context looking for a comment "edge". If this # the context looking for a comment "edge". If this
# edge is a close comment then we must be in a comment # edge is a close comment then we must be in a comment
@ -2280,6 +2360,7 @@ sub process {
$found_file = 1; $found_file = 1;
} }
# coreboot
my $skipme = 0; my $skipme = 0;
foreach (@exclude) { foreach (@exclude) {
if ($realfile =~ m@^(?:$_/)@) { if ($realfile =~ m@^(?:$_/)@) {
@ -2302,6 +2383,10 @@ sub process {
} }
if ($found_file) { if ($found_file) {
if (is_maintained_obsolete($realfile)) {
WARN("OBSOLETE",
"$realfile is marked as 'obsolete' in the MAINTAINERS hierarchy. No unnecessary modifications please.\n");
}
if ($realfile =~ m@^(?:drivers/net/|net/|drivers/staging/)@) { if ($realfile =~ m@^(?:drivers/net/|net/|drivers/staging/)@) {
$check = 1; $check = 1;
} else { } else {
@ -2473,8 +2558,9 @@ sub process {
# Check for git id commit length and improperly formed commit descriptions # Check for git id commit length and improperly formed commit descriptions
if ($in_commit_log && !$commit_log_possible_stack_dump && if ($in_commit_log && !$commit_log_possible_stack_dump &&
$line !~ /^\s*(?:Link|Patchwork|http|https|BugLink):/i &&
($line =~ /\bcommit\s+[0-9a-f]{5,}\b/i || ($line =~ /\bcommit\s+[0-9a-f]{5,}\b/i ||
($line =~ /\b[0-9a-f]{12,40}\b/i && ($line =~ /(?:\s|^)[0-9a-f]{12,40}(?:[\s"'\(\[]|$)/i &&
$line !~ /[\<\[][0-9a-f]{12,40}[\>\]]/i && $line !~ /[\<\[][0-9a-f]{12,40}[\>\]]/i &&
$line !~ /\bfixes:\s*[0-9a-f]{12,40}/i))) { $line !~ /\bfixes:\s*[0-9a-f]{12,40}/i))) {
my $init_char = "c"; my $init_char = "c";
@ -2533,6 +2619,7 @@ sub process {
$line =~ /^rename (?:from|to) [\w\/\.\-]+\s*$/ || $line =~ /^rename (?:from|to) [\w\/\.\-]+\s*$/ ||
($line =~ /\{\s*([\w\/\.\-]*)\s*\=\>\s*([\w\/\.\-]*)\s*\}/ && ($line =~ /\{\s*([\w\/\.\-]*)\s*\=\>\s*([\w\/\.\-]*)\s*\}/ &&
(defined($1) || defined($2))))) { (defined($1) || defined($2))))) {
$is_patch = 1;
$reported_maintainer_file = 1; $reported_maintainer_file = 1;
WARN("FILE_PATH_CHANGES", WARN("FILE_PATH_CHANGES",
"added, moved or deleted file(s), does MAINTAINERS need updating?\n" . $herecurr); "added, moved or deleted file(s), does MAINTAINERS need updating?\n" . $herecurr);
@ -2545,20 +2632,6 @@ sub process {
$herecurr) if (!$emitted_corrupt++); $herecurr) if (!$emitted_corrupt++);
} }
# Check for absolute kernel paths.
if ($tree) {
while ($line =~ m{(?:^|\s)(/\S*)}g) {
my $file = $1;
if ($file =~ m{^(.*?)(?::\d+)+:?$} &&
check_absolute_file($1, $herecurr)) {
#
} else {
check_absolute_file($file, $herecurr);
}
}
}
# UTF-8 regex found at http://www.w3.org/International/questions/qa-forms-utf-8.en.php # UTF-8 regex found at http://www.w3.org/International/questions/qa-forms-utf-8.en.php
if (($realfile =~ /^$/ || $line =~ /^\+/) && if (($realfile =~ /^$/ || $line =~ /^\+/) &&
$rawline !~ m/^$UTF8*$/) { $rawline !~ m/^$UTF8*$/) {
@ -2579,6 +2652,7 @@ sub process {
$rawline =~ /^(commit\b|from\b|[\w-]+:).*$/i)) { $rawline =~ /^(commit\b|from\b|[\w-]+:).*$/i)) {
$in_header_lines = 0; $in_header_lines = 0;
$in_commit_log = 1; $in_commit_log = 1;
$has_commit_log = 1;
} }
# Check if there is UTF-8 in a commit log when a mail header has explicitly # Check if there is UTF-8 in a commit log when a mail header has explicitly
@ -2595,6 +2669,20 @@ sub process {
"8-bit UTF-8 used in possible commit log\n" . $herecurr); "8-bit UTF-8 used in possible commit log\n" . $herecurr);
} }
# Check for absolute kernel paths in commit message
if ($tree && $in_commit_log) {
while ($line =~ m{(?:^|\s)(/\S*)}g) {
my $file = $1;
if ($file =~ m{^(.*?)(?::\d+)+:?$} &&
check_absolute_file($1, $herecurr)) {
#
} else {
check_absolute_file($file, $herecurr);
}
}
}
# Check for various typo / spelling mistakes # Check for various typo / spelling mistakes
if (defined($misspellings) && if (defined($misspellings) &&
($in_commit_log || $line =~ /^(?:\+|Subject:)/i)) { ($in_commit_log || $line =~ /^(?:\+|Subject:)/i)) {
@ -2637,6 +2725,7 @@ sub process {
# Check for FSF mailing addresses. # Check for FSF mailing addresses.
if ($rawline =~ /\bwrite to the Free/i || if ($rawline =~ /\bwrite to the Free/i ||
$rawline =~ /\b675\s+Mass\s+Ave/i ||
$rawline =~ /\b59\s+Temple\s+Pl/i || $rawline =~ /\b59\s+Temple\s+Pl/i ||
$rawline =~ /\b51\s+Franklin\s+St/i) { $rawline =~ /\b51\s+Franklin\s+St/i) {
my $herevet = "$here\n" . cat_vet($rawline) . "\n"; my $herevet = "$here\n" . cat_vet($rawline) . "\n";
@ -2748,7 +2837,7 @@ 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|dtsi|dts)$/); next if ($realfile !~ /\.(h|c|s|S|sh|dtsi|dts)$/);
# line length limit (with some exclusions) # line length limit (with some exclusions)
# #
@ -2782,6 +2871,10 @@ sub process {
$line =~ /^\+\s*#\s*define\s+\w+\s+$String$/) { $line =~ /^\+\s*#\s*define\s+\w+\s+$String$/) {
$msg_type = ""; $msg_type = "";
# EFI_GUID is another special case
} elsif ($line =~ /^\+.*\bEFI_GUID\s*\(/) {
$msg_type = "";
# Otherwise set the alternate message types # Otherwise set the alternate message types
# a comment starts before $max_line_length # a comment starts before $max_line_length
@ -2946,6 +3039,30 @@ sub process {
"Block comments use a trailing */ on a separate line\n" . $herecurr); "Block comments use a trailing */ on a separate line\n" . $herecurr);
} }
# Block comment * alignment
if ($prevline =~ /$;[ \t]*$/ && #ends in comment
$line =~ /^\+[ \t]*$;/ && #leading comment
$rawline =~ /^\+[ \t]*\*/ && #leading *
(($prevrawline =~ /^\+.*?\/\*/ && #leading /*
$prevrawline !~ /\*\/[ \t]*$/) || #no trailing */
$prevrawline =~ /^\+[ \t]*\*/)) { #leading *
my $oldindent;
$prevrawline =~ m@^\+([ \t]*/?)\*@;
if (defined($1)) {
$oldindent = expand_tabs($1);
} else {
$prevrawline =~ m@^\+(.*/?)\*@;
$oldindent = expand_tabs($1);
}
$rawline =~ m@^\+([ \t]*)\*@;
my $newindent = $1;
$newindent = expand_tabs($newindent);
if (length($oldindent) ne length($newindent)) {
WARN("BLOCK_COMMENT_STYLE",
"Block comments should align the * on each line\n" . $hereprev);
}
}
# check for missing blank lines after struct/union declarations # check for missing blank lines after struct/union declarations
# with exceptions for various attributes and macros # with exceptions for various attributes and macros
if ($prevline =~ /^[\+ ]};?\s*$/ && if ($prevline =~ /^[\+ ]};?\s*$/ &&
@ -3355,8 +3472,20 @@ sub process {
#ignore lines not being added #ignore lines not being added
next if ($line =~ /^[^\+]/); next if ($line =~ /^[^\+]/);
# check for dereferences that span multiple lines
if ($prevline =~ /^\+.*$Lval\s*(?:\.|->)\s*$/ &&
$line =~ /^\+\s*(?!\#\s*(?!define\s+|if))\s*$Lval/) {
$prevline =~ /($Lval\s*(?:\.|->))\s*$/;
my $ref = $1;
$line =~ /^.\s*($Lval)/;
$ref .= $1;
$ref =~ s/\s//g;
WARN("MULTILINE_DEREFERENCE",
"Avoid multiple line dereference - prefer '$ref'\n" . $hereprev);
}
# check for declarations of signed or unsigned without int # check for declarations of signed or unsigned without int
while ($line =~ m{($Declare)\s*(?!char\b|short\b|int\b|long\b)\s*($Ident)?\s*[=,;\[\)\(]}g) { while ($line =~ m{\b($Declare)\s*(?!char\b|short\b|int\b|long\b)\s*($Ident)?\s*[=,;\[\)\(]}g) {
my $type = $1; my $type = $1;
my $var = $2; my $var = $2;
$var = "" if (!defined $var); $var = "" if (!defined $var);
@ -3577,22 +3706,13 @@ sub process {
} }
} }
# check for uses of DEFINE_PCI_DEVICE_TABLE
if ($line =~ /\bDEFINE_PCI_DEVICE_TABLE\s*\(\s*(\w+)\s*\)\s*=/) {
if (WARN("DEFINE_PCI_DEVICE_TABLE",
"Prefer struct pci_device_id over deprecated DEFINE_PCI_DEVICE_TABLE\n" . $herecurr) &&
$fix) {
$fixed[$fixlinenr] =~ s/\b(?:static\s+|)DEFINE_PCI_DEVICE_TABLE\s*\(\s*(\w+)\s*\)\s*=\s*/static const struct pci_device_id $1\[\] = /;
}
}
# check for new typedefs, only function parameters and sparse annotations # check for new typedefs, only function parameters and sparse annotations
# make sense. # make sense.
if ($line =~ /\btypedef\s/ && if ($line =~ /\btypedef\s/ &&
$line !~ /\btypedef\s+$Type\s*\(\s*\*?$Ident\s*\)\s*\(/ && $line !~ /\btypedef\s+$Type\s*\(\s*\*?$Ident\s*\)\s*\(/ &&
$line !~ /\btypedef\s+$Type\s+$Ident\s*\(/ && $line !~ /\btypedef\s+$Type\s+$Ident\s*\(/ &&
$line !~ /\b$typeTypedefs\b/ && $line !~ /\b$typeTypedefs\b/ &&
$line !~ /\b__bitwise(?:__|)\b/) { $line !~ /\b__bitwise\b/) {
WARN("NEW_TYPEDEFS", WARN("NEW_TYPEDEFS",
"do not add new typedefs\n" . $herecurr); "do not add new typedefs\n" . $herecurr);
} }
@ -3736,6 +3856,7 @@ sub process {
# function brace can't be on same line, except for #defines of do while, # function brace can't be on same line, except for #defines of do while,
# or if closed on same line # or if closed on same line
if (($line=~/$Type\s*$Ident\(.*\).*\s*{/) and if (($line=~/$Type\s*$Ident\(.*\).*\s*{/) and
#coreboot - Ignore struct lines with attributes - they're not functions
($line!~/struct.*__attribute__\(\(.*\)\)/) and ($line!~/struct.*__attribute__\(\(.*\)\)/) and
!($line=~/\#\s*define.*do\s\{/) and !($line=~/}/)) { !($line=~/\#\s*define.*do\s\{/) and !($line=~/}/)) {
if (ERROR("OPEN_BRACE", if (ERROR("OPEN_BRACE",
@ -3856,12 +3977,12 @@ sub process {
# 1. with a type on the left -- int [] a; # 1. with a type on the left -- int [] a;
# 2. at the beginning of a line for slice initialisers -- [0...10] = 5, # 2. at the beginning of a line for slice initialisers -- [0...10] = 5,
# 3. inside a curly brace -- = { [0...10] = 5 } # 3. inside a curly brace -- = { [0...10] = 5 }
# 4. in an extended asm instruction -- : [r0]"r"(r0) # 4. in an extended asm instruction -- : [r0]"r"(r0) (coreboot)
while ($line =~ /(.*?\s)\[/g) { while ($line =~ /(.*?\s)\[/g) {
my ($where, $prefix) = ($-[1], $1); my ($where, $prefix) = ($-[1], $1);
if ($prefix !~ /$Type\s+$/ && if ($prefix !~ /$Type\s+$/ &&
($where != 0 || $prefix !~ /^.\s+$/) && ($where != 0 || $prefix !~ /^.\s+$/) &&
$prefix !~ /[{,:]\s+$/) { $prefix !~ /[{,:]\s+$/) { #coreboot
if (ERROR("BRACKET_SPACE", if (ERROR("BRACKET_SPACE",
"space prohibited before open square bracket '['\n" . $herecurr) && "space prohibited before open square bracket '['\n" . $herecurr) &&
$fix) { $fix) {
@ -4683,7 +4804,17 @@ sub process {
$has_flow_statement = 1 if ($ctx =~ /\b(goto|return)\b/); $has_flow_statement = 1 if ($ctx =~ /\b(goto|return)\b/);
$has_arg_concat = 1 if ($ctx =~ /\#\#/ && $ctx !~ /\#\#\s*(?:__VA_ARGS__|args)\b/); $has_arg_concat = 1 if ($ctx =~ /\#\#/ && $ctx !~ /\#\#\s*(?:__VA_ARGS__|args)\b/);
$dstat =~ s/^.\s*\#\s*define\s+$Ident(?:\([^\)]*\))?\s*//; $dstat =~ s/^.\s*\#\s*define\s+$Ident(\([^\)]*\))?\s*//;
my $define_args = $1;
my $define_stmt = $dstat;
my @def_args = ();
if (defined $define_args && $define_args ne "") {
$define_args = substr($define_args, 1, length($define_args) - 2);
$define_args =~ s/\s*//g;
@def_args = split(",", $define_args);
}
$dstat =~ s/$;//g; $dstat =~ s/$;//g;
$dstat =~ s/\\\n.//g; $dstat =~ s/\\\n.//g;
$dstat =~ s/^\s*//s; $dstat =~ s/^\s*//s;
@ -4719,6 +4850,15 @@ sub process {
^\[ ^\[
}x; }x;
#print "REST<$rest> dstat<$dstat> ctx<$ctx>\n"; #print "REST<$rest> dstat<$dstat> ctx<$ctx>\n";
$ctx =~ s/\n*$//;
my $herectx = $here . "\n";
my $stmt_cnt = statement_rawlines($ctx);
for (my $n = 0; $n < $stmt_cnt; $n++) {
$herectx .= raw_line($linenr, $n) . "\n";
}
if ($dstat ne '' && if ($dstat ne '' &&
$dstat !~ /^(?:$Ident|-?$Constant),$/ && # 10, // foo(), $dstat !~ /^(?:$Ident|-?$Constant),$/ && # 10, // foo(),
$dstat !~ /^(?:$Ident|-?$Constant);$/ && # foo(); $dstat !~ /^(?:$Ident|-?$Constant);$/ && # foo();
@ -4730,17 +4870,10 @@ sub process {
$dstat !~ /^do\s*$Constant\s*while\s*$Constant;?$/ && # do {...} while (...); // do {...} while (...) $dstat !~ /^do\s*$Constant\s*while\s*$Constant;?$/ && # do {...} while (...); // do {...} while (...)
$dstat !~ /^for\s*$Constant$/ && # for (...) $dstat !~ /^for\s*$Constant$/ && # for (...)
$dstat !~ /^for\s*$Constant\s+(?:$Ident|-?$Constant)$/ && # for (...) bar() $dstat !~ /^for\s*$Constant\s+(?:$Ident|-?$Constant)$/ && # for (...) bar()
$dstat !~ /^do\s*\{/ && # do {... $dstat !~ /^do\s*{/ && # do {...
$dstat !~ /^\(\{/ && # ({... $dstat !~ /^\(\{/ && # ({...
$ctx !~ /^.\s*#\s*define\s+TRACE_(?:SYSTEM|INCLUDE_FILE|INCLUDE_PATH)\b/) $ctx !~ /^.\s*#\s*define\s+TRACE_(?:SYSTEM|INCLUDE_FILE|INCLUDE_PATH)\b/)
{ {
$ctx =~ s/\n*$//;
my $herectx = $here . "\n";
my $cnt = statement_rawlines($ctx);
for (my $n = 0; $n < $cnt; $n++) {
$herectx .= raw_line($linenr, $n) . "\n";
}
if ($dstat =~ /;/) { if ($dstat =~ /;/) {
ERROR("MULTISTATEMENT_MACRO_USE_DO_WHILE", ERROR("MULTISTATEMENT_MACRO_USE_DO_WHILE",
@ -4749,6 +4882,46 @@ sub process {
ERROR("COMPLEX_MACRO", ERROR("COMPLEX_MACRO",
"Macros with complex values should be enclosed in parentheses\n" . "$herectx"); "Macros with complex values should be enclosed in parentheses\n" . "$herectx");
} }
}
# Make $define_stmt single line, comment-free, etc
my @stmt_array = split('\n', $define_stmt);
my $first = 1;
$define_stmt = "";
foreach my $l (@stmt_array) {
$l =~ s/\\$//;
if ($first) {
$define_stmt = $l;
$first = 0;
} elsif ($l =~ /^[\+ ]/) {
$define_stmt .= substr($l, 1);
}
}
$define_stmt =~ s/$;//g;
$define_stmt =~ s/\s+/ /g;
$define_stmt = trim($define_stmt);
# check if any macro arguments are reused (ignore '...' and 'type')
foreach my $arg (@def_args) {
next if ($arg =~ /\.\.\./);
next if ($arg =~ /^type$/i);
my $tmp = $define_stmt;
$tmp =~ s/\b(typeof|__typeof__|__builtin\w+|typecheck\s*\(\s*$Type\s*,|\#+)\s*\(*\s*$arg\s*\)*\b//g;
$tmp =~ s/\#+\s*$arg\b//g;
$tmp =~ s/\b$arg\s*\#\#//g;
my $use_cnt = $tmp =~ s/\b$arg\b//g;
if ($use_cnt > 1) {
CHK("MACRO_ARG_REUSE",
"Macro argument reuse '$arg' - possible side-effects?\n" . "$herectx");
}
# check if any macro arguments may have other precedence issues
if ($define_stmt =~ m/($Operators)?\s*\b$arg\b\s*($Operators)?/m &&
((defined($1) && $1 ne ',') ||
(defined($2) && $2 ne ','))) {
CHK("MACRO_ARG_PRECEDENCE",
"Macro argument '$arg' may be better as '($arg)' to avoid precedence issues\n" . "$herectx");
}
} }
# check for macros with flow control, but without ## concatenation # check for macros with flow control, but without ## concatenation
@ -4956,6 +5129,12 @@ sub process {
} }
} }
# check for single line unbalanced braces
if ($sline =~ /^.\s*\}\s*else\s*$/ ||
$sline =~ /^.\s*else\s*\{\s*$/) {
CHK("BRACES", "Unbalanced braces around else statement\n" . $herecurr);
}
# check for unnecessary blank lines around braces # check for unnecessary blank lines around braces
if (($line =~ /^.\s*}\s*$/ && $prevrawline =~ /^.\s*$/)) { if (($line =~ /^.\s*}\s*$/ && $prevrawline =~ /^.\s*$/)) {
if (CHK("BRACES", if (CHK("BRACES",
@ -4976,7 +5155,7 @@ sub process {
my $asm_volatile = qr{\b(__asm__|asm)\s+(__volatile__|volatile)\b}; my $asm_volatile = qr{\b(__asm__|asm)\s+(__volatile__|volatile)\b};
if ($line =~ /\bvolatile\b/ && $line !~ /$asm_volatile/) { if ($line =~ /\bvolatile\b/ && $line !~ /$asm_volatile/) {
WARN("VOLATILE", WARN("VOLATILE",
"Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt\n" . $herecurr); "Use of volatile is usually wrong: see Documentation/process/volatile-considered-harmful.rst\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
@ -5018,6 +5197,16 @@ sub process {
"break quoted strings at a space character\n" . $hereprev); "break quoted strings at a space character\n" . $hereprev);
} }
#check for an embedded function name in a string when the function is known
# as part of a diff. This does not work for -f --file checking as it
#depends on patch context providing the function name
if ($line =~ /^\+.*$String/ &&
defined($context_function) &&
get_quoted_string($line, $rawline) =~ /\b$context_function\b/) {
WARN("EMBEDDED_FUNCTION_NAME",
"Prefer using \"%s\", __func__ to embedded function names\n" . $herecurr);
}
# check for spaces before a quoted newline # check for spaces before a quoted newline
if ($rawline =~ /^.*\".*\s\\n/) { if ($rawline =~ /^.*\".*\s\\n/) {
if (WARN("QUOTED_WHITESPACE_BEFORE_NEWLINE", if (WARN("QUOTED_WHITESPACE_BEFORE_NEWLINE",
@ -5040,18 +5229,27 @@ sub process {
"Consecutive strings are generally better as a single string\n" . $herecurr); "Consecutive strings are generally better as a single string\n" . $herecurr);
} }
# check for %L{u,d,i} and 0x%[udi] in strings # check for non-standard and hex prefixed decimal printf formats
my $string; my $show_L = 1; #don't show the same defect twice
my $show_Z = 1;
while ($line =~ /(?:^|")([X\t]*)(?:"|$)/g) { while ($line =~ /(?:^|")([X\t]*)(?:"|$)/g) {
$string = substr($rawline, $-[1], $+[1] - $-[1]); my $string = substr($rawline, $-[1], $+[1] - $-[1]);
$string =~ s/%%/__/g; $string =~ s/%%/__/g;
if ($string =~ /(?<!%)%[\*\d\.\$]*L[udi]/) { # check for %L
if ($show_L && $string =~ /%[\*\d\.\$]*L([diouxX])/) {
WARN("PRINTF_L", WARN("PRINTF_L",
"\%Ld/%Lu are not-standard C, use %lld/%llu\n" . $herecurr); "\%L$1 is non-standard C, use %ll$1\n" . $herecurr);
last; $show_L = 0;
} }
if ($string =~ /0x%[\*\d\.\$\Llzth]*[udi]/) { # check for %Z
ERROR("PRINTF_0xDECIMAL", if ($show_Z && $string =~ /%[\*\d\.\$]*Z([diouxX])/) {
WARN("PRINTF_Z",
"%Z$1 is non-standard C, use %z$1\n" . $herecurr);
$show_Z = 0;
}
# check for 0x<decimal>
if ($string =~ /0x%[\*\d\.\$\Llzth]*[diou]/) {
ERROR("PRINTF_0XDECIMAL",
"Prefixing 0x with decimal output is defective\n" . $herecurr); "Prefixing 0x with decimal output is defective\n" . $herecurr);
} }
} }
@ -5130,6 +5328,12 @@ sub process {
} }
} }
# check for logging continuations
if ($line =~ /\bprintk\s*\(\s*KERN_CONT\b|\bpr_cont\s*\(/) {
WARN("LOGGING_CONTINUATION",
"Avoid logging continuation uses where feasible\n" . $herecurr);
}
# check for mask then right shift without a parentheses # check for mask then right shift without a parentheses
if ($^V && $^V ge 5.10.0 && if ($^V && $^V ge 5.10.0 &&
$line =~ /$LvalOrFunc\s*\&\s*($LvalOrFunc)\s*>>/ && $line =~ /$LvalOrFunc\s*\&\s*($LvalOrFunc)\s*>>/ &&
@ -5423,8 +5627,9 @@ sub process {
"Using weak declarations can have unintended link defects\n" . $herecurr); "Using weak declarations can have unintended link defects\n" . $herecurr);
} }
# check for c99 types like uint8_t used outside of uapi/ # check for c99 types like uint8_t used outside of uapi/ and tools/
if ($realfile !~ m@\binclude/uapi/@ && if ($realfile !~ m@\binclude/uapi/@ &&
$realfile !~ m@\btools/@ &&
$line =~ /\b($Declare)\s*$Ident\s*[=;,\[]/) { $line =~ /\b($Declare)\s*$Ident\s*[=;,\[]/) {
my $type = $1; my $type = $1;
if ($type =~ /\b($typeC99Typedefs)\b/) { if ($type =~ /\b($typeC99Typedefs)\b/) {
@ -5514,46 +5719,46 @@ sub process {
} }
# Check for memcpy(foo, bar, ETH_ALEN) that could be ether_addr_copy(foo, bar) # Check for memcpy(foo, bar, ETH_ALEN) that could be ether_addr_copy(foo, bar)
if ($^V && $^V ge 5.10.0 && # if ($^V && $^V ge 5.10.0 &&
defined $stat && # defined $stat &&
$stat =~ /^\+(?:.*?)\bmemcpy\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\,\s*ETH_ALEN\s*\)/) { # $stat =~ /^\+(?:.*?)\bmemcpy\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\,\s*ETH_ALEN\s*\)/) {
if (WARN("PREFER_ETHER_ADDR_COPY", # if (WARN("PREFER_ETHER_ADDR_COPY",
"Prefer ether_addr_copy() over memcpy() if the Ethernet addresses are __aligned(2)\n" . "$here\n$stat\n") && # "Prefer ether_addr_copy() over memcpy() if the Ethernet addresses are __aligned(2)\n" . "$here\n$stat\n") &&
$fix) { # $fix) {
$fixed[$fixlinenr] =~ s/\bmemcpy\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\,\s*ETH_ALEN\s*\)/ether_addr_copy($2, $7)/; # $fixed[$fixlinenr] =~ s/\bmemcpy\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\,\s*ETH_ALEN\s*\)/ether_addr_copy($2, $7)/;
} # }
} # }
# Check for memcmp(foo, bar, ETH_ALEN) that could be ether_addr_equal*(foo, bar) # Check for memcmp(foo, bar, ETH_ALEN) that could be ether_addr_equal*(foo, bar)
if ($^V && $^V ge 5.10.0 && # if ($^V && $^V ge 5.10.0 &&
defined $stat && # defined $stat &&
$stat =~ /^\+(?:.*?)\bmemcmp\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\,\s*ETH_ALEN\s*\)/) { # $stat =~ /^\+(?:.*?)\bmemcmp\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\,\s*ETH_ALEN\s*\)/) {
WARN("PREFER_ETHER_ADDR_EQUAL", # WARN("PREFER_ETHER_ADDR_EQUAL",
"Prefer ether_addr_equal() or ether_addr_equal_unaligned() over memcmp()\n" . "$here\n$stat\n") # "Prefer ether_addr_equal() or ether_addr_equal_unaligned() over memcmp()\n" . "$here\n$stat\n")
} # }
# check for memset(foo, 0x0, ETH_ALEN) that could be eth_zero_addr # check for memset(foo, 0x0, ETH_ALEN) that could be eth_zero_addr
# check for memset(foo, 0xFF, ETH_ALEN) that could be eth_broadcast_addr # check for memset(foo, 0xFF, ETH_ALEN) that could be eth_broadcast_addr
if ($^V && $^V ge 5.10.0 && # if ($^V && $^V ge 5.10.0 &&
defined $stat && # defined $stat &&
$stat =~ /^\+(?:.*?)\bmemset\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\,\s*ETH_ALEN\s*\)/) { # $stat =~ /^\+(?:.*?)\bmemset\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\,\s*ETH_ALEN\s*\)/) {
#
my $ms_val = $7; # my $ms_val = $7;
#
if ($ms_val =~ /^(?:0x|)0+$/i) { # if ($ms_val =~ /^(?:0x|)0+$/i) {
if (WARN("PREFER_ETH_ZERO_ADDR", # if (WARN("PREFER_ETH_ZERO_ADDR",
"Prefer eth_zero_addr over memset()\n" . "$here\n$stat\n") && # "Prefer eth_zero_addr over memset()\n" . "$here\n$stat\n") &&
$fix) { # $fix) {
$fixed[$fixlinenr] =~ s/\bmemset\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*,\s*ETH_ALEN\s*\)/eth_zero_addr($2)/; # $fixed[$fixlinenr] =~ s/\bmemset\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*,\s*ETH_ALEN\s*\)/eth_zero_addr($2)/;
} # }
} elsif ($ms_val =~ /^(?:0xff|255)$/i) { # } elsif ($ms_val =~ /^(?:0xff|255)$/i) {
if (WARN("PREFER_ETH_BROADCAST_ADDR", # if (WARN("PREFER_ETH_BROADCAST_ADDR",
"Prefer eth_broadcast_addr() over memset()\n" . "$here\n$stat\n") && # "Prefer eth_broadcast_addr() over memset()\n" . "$here\n$stat\n") &&
$fix) { # $fix) {
$fixed[$fixlinenr] =~ s/\bmemset\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*,\s*ETH_ALEN\s*\)/eth_broadcast_addr($2)/; # $fixed[$fixlinenr] =~ s/\bmemset\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*,\s*ETH_ALEN\s*\)/eth_broadcast_addr($2)/;
} # }
} # }
} # }
# typecasts on min/max could be min_t/max_t # typecasts on min/max could be min_t/max_t
if ($^V && $^V ge 5.10.0 && if ($^V && $^V ge 5.10.0 &&
@ -5673,13 +5878,26 @@ sub process {
"externs should be avoided in .c files\n" . $herecurr); "externs should be avoided in .c files\n" . $herecurr);
} }
if ($realfile =~ /\.[ch]$/ && defined $stat &&
$stat =~ /^.\s*(?:extern\s+)?$Type\s*$Ident\s*\(\s*([^{]+)\s*\)\s*;/s &&
$1 ne "void") {
my $args = trim($1);
while ($args =~ m/\s*($Type\s*(?:$Ident|\(\s*\*\s*$Ident?\s*\)\s*$balanced_parens)?)/g) {
my $arg = trim($1);
if ($arg =~ /^$Type$/ && $arg !~ /enum\s+$Ident$/) {
WARN("FUNCTION_ARGUMENTS",
"function definition argument '$arg' should also have an identifier name\n" . $herecurr);
}
}
}
# checks for new __setup's # checks for new __setup's
if ($rawline =~ /\b__setup\("([^"]*)"/) { if ($rawline =~ /\b__setup\("([^"]*)"/) {
my $name = $1; my $name = $1;
if (!grep(/$name/, @setup_docs)) { if (!grep(/$name/, @setup_docs)) {
CHK("UNDOCUMENTED_SETUP", CHK("UNDOCUMENTED_SETUP",
"__setup appears un-documented -- check Documentation/kernel-parameters.txt\n" . $herecurr); "__setup appears un-documented -- check Documentation/admin-guide/kernel-parameters.rst\n" . $herecurr);
} }
} }
@ -5744,8 +5962,9 @@ sub process {
} }
} }
# check for #defines like: 1 << <digit> that could be BIT(digit) # check for #defines like: 1 << <digit> that could be BIT(digit), it is not exported to uapi
if ($line =~ /#\s*define\s+\w+\s+\(?\s*1\s*([ulUL]*)\s*\<\<\s*(?:\d+|$Ident)\s*\)?/) { if ($realfile !~ m@^include/uapi/@ &&
$line =~ /#\s*define\s+\w+\s+\(?\s*1\s*([ulUL]*)\s*\<\<\s*(?:\d+|$Ident)\s*\)?/) {
my $ull = ""; my $ull = "";
$ull = "_ULL" if (defined($1) && $1 =~ /ll/i); $ull = "_ULL" if (defined($1) && $1 =~ /ll/i);
if (CHK("BIT_MACRO", if (CHK("BIT_MACRO",
@ -5786,7 +6005,7 @@ sub process {
} }
if (!$has_break && $has_statement) { if (!$has_break && $has_statement) {
WARN("MISSING_BREAK", WARN("MISSING_BREAK",
"Possible switch case/default not preceeded by break or fallthrough comment\n" . $herecurr); "Possible switch case/default not preceded by break or fallthrough comment\n" . $herecurr);
} }
} }
@ -5871,46 +6090,6 @@ sub process {
} }
# check for various structs that are normally const (ops, kgdb, device_tree) # check for various structs that are normally const (ops, kgdb, device_tree)
my $const_structs = qr{
acpi_dock_ops|
address_space_operations|
backlight_ops|
block_device_operations|
dentry_operations|
dev_pm_ops|
dma_map_ops|
extent_io_ops|
file_lock_operations|
file_operations|
hv_ops|
ide_dma_ops|
intel_dvo_dev_ops|
item_operations|
iwl_ops|
kgdb_arch|
kgdb_io|
kset_uevent_ops|
lock_manager_operations|
microcode_ops|
mtrr_ops|
neigh_ops|
nlmsvc_binding|
of_device_id|
pci_raw_ops|
pipe_buf_operations|
platform_hibernation_ops|
platform_suspend_ops|
proto_ops|
rpc_pipe_ops|
seq_operations|
snd_ac97_build_ops|
soc_pcmcia_socket_ops|
stacktrace_ops|
sysfs_ops|
tty_operations|
uart_ops|
usb_mon_operations|
wd_ops}x;
if ($line !~ /\bconst\b/ && if ($line !~ /\bconst\b/ &&
$line =~ /\bstruct\s+($const_structs)\b/) { $line =~ /\bstruct\s+($const_structs)\b/) {
WARN("CONST_STRUCT", WARN("CONST_STRUCT",
@ -5977,6 +6156,12 @@ sub process {
} }
} }
# check for mutex_trylock_recursive usage
if ($line =~ /mutex_trylock_recursive/) {
ERROR("LOCKING",
"recursive locking is bad, do not use this ever.\n" . $herecurr);
}
# check for lockdep_set_novalidate_class # check for lockdep_set_novalidate_class
if ($line =~ /^.\s*lockdep_set_novalidate_class\s*\(/ || if ($line =~ /^.\s*lockdep_set_novalidate_class\s*\(/ ||
$line =~ /__lockdep_no_validate__\s*\)/ ) { $line =~ /__lockdep_no_validate__\s*\)/ ) {
@ -5997,34 +6182,69 @@ sub process {
# Mode permission misuses where it seems decimal should be octal # Mode permission misuses where it seems decimal should be octal
# This uses a shortcut match to avoid unnecessary uses of a slow foreach loop # This uses a shortcut match to avoid unnecessary uses of a slow foreach loop
if ($^V && $^V ge 5.10.0 && if ($^V && $^V ge 5.10.0 &&
defined $stat &&
$line =~ /$mode_perms_search/) { $line =~ /$mode_perms_search/) {
foreach my $entry (@mode_permission_funcs) { foreach my $entry (@mode_permission_funcs) {
my $func = $entry->[0]; my $func = $entry->[0];
my $arg_pos = $entry->[1]; my $arg_pos = $entry->[1];
my $lc = $stat =~ tr@\n@@;
$lc = $lc + $linenr;
my $stat_real = raw_line($linenr, 0);
for (my $count = $linenr + 1; $count <= $lc; $count++) {
$stat_real = $stat_real . "\n" . raw_line($count, 0);
}
my $skip_args = ""; my $skip_args = "";
if ($arg_pos > 1) { if ($arg_pos > 1) {
$arg_pos--; $arg_pos--;
$skip_args = "(?:\\s*$FuncArg\\s*,\\s*){$arg_pos,$arg_pos}"; $skip_args = "(?:\\s*$FuncArg\\s*,\\s*){$arg_pos,$arg_pos}";
} }
my $test = "\\b$func\\s*\\(${skip_args}([\\d]+)\\s*[,\\)]"; my $test = "\\b$func\\s*\\(${skip_args}($FuncArg(?:\\|\\s*$FuncArg)*)\\s*[,\\)]";
if ($line =~ /$test/) { if ($stat =~ /$test/) {
my $val = $1; my $val = $1;
$val = $6 if ($skip_args ne ""); $val = $6 if ($skip_args ne "");
if (($val =~ /^$Int$/ && $val !~ /^$Octal$/) ||
if ($val !~ /^0$/ && ($val =~ /^$Octal$/ && length($val) ne 4)) {
(($val =~ /^$Int$/ && $val !~ /^$Octal$/) ||
length($val) ne 4)) {
ERROR("NON_OCTAL_PERMISSIONS", ERROR("NON_OCTAL_PERMISSIONS",
"Use 4 digit octal (0777) not decimal permissions\n" . $herecurr); "Use 4 digit octal (0777) not decimal permissions\n" . "$here\n" . $stat_real);
} elsif ($val =~ /^$Octal$/ && (oct($val) & 02)) { }
if ($val =~ /^$Octal$/ && (oct($val) & 02)) {
ERROR("EXPORTED_WORLD_WRITABLE", ERROR("EXPORTED_WORLD_WRITABLE",
"Exporting writable files is usually an error. Consider more restrictive permissions.\n" . $herecurr); "Exporting writable files is usually an error. Consider more restrictive permissions.\n" . "$here\n" . $stat_real);
} }
} }
} }
} }
# check for uses of S_<PERMS> that could be octal for readability
if ($line =~ /\b$mode_perms_string_search\b/) {
my $val = "";
my $oval = "";
my $to = 0;
my $curpos = 0;
my $lastpos = 0;
while ($line =~ /\b(($mode_perms_string_search)\b(?:\s*\|\s*)?\s*)/g) {
$curpos = pos($line);
my $match = $2;
my $omatch = $1;
last if ($lastpos > 0 && ($curpos - length($omatch) != $lastpos));
$lastpos = $curpos;
$to |= $mode_permission_string_types{$match};
$val .= '\s*\|\s*' if ($val ne "");
$val .= $match;
$oval .= $omatch;
}
$oval =~ s/^\s*\|\s*//;
$oval =~ s/\s*\|\s*$//;
my $octal = sprintf("%04o", $to);
if (WARN("SYMBOLIC_PERMS",
"Symbolic permissions '$oval' are not preferred. Consider using octal permissions '$octal'.\n" . $herecurr) &&
$fix) {
$fixed[$fixlinenr] =~ s/$val/$octal/;
}
}
# validate content of MODULE_LICENSE against list from include/linux/module.h # validate content of MODULE_LICENSE against list from include/linux/module.h
if ($line =~ /\bMODULE_LICENSE\s*\(\s*($String)\s*\)/) { if ($line =~ /\bMODULE_LICENSE\s*\(\s*($String)\s*\)/) {
my $extracted_string = get_quoted_string($line, $rawline); my $extracted_string = get_quoted_string($line, $rawline);
@ -6066,7 +6286,7 @@ sub process {
ERROR("NOT_UNIFIED_DIFF", ERROR("NOT_UNIFIED_DIFF",
"Does not appear to be a unified-diff format patch\n"); "Does not appear to be a unified-diff format patch\n");
} }
if ($is_patch && $filename ne '-' && $chk_signoff && $signoff == 0) { if ($is_patch && $has_commit_log && $chk_signoff && $signoff == 0) {
ERROR("MISSING_SIGN_OFF", ERROR("MISSING_SIGN_OFF",
"Missing Signed-off-by: line(s)\n"); "Missing Signed-off-by: line(s)\n");
} }

View File

@ -0,0 +1,39 @@
acpi_dock_ops
address_space_operations
backlight_ops
block_device_operations
dentry_operations
dev_pm_ops
dma_map_ops
extent_io_ops
file_lock_operations
file_operations
hv_ops
ide_dma_ops
intel_dvo_dev_ops
item_operations
iwl_ops
kgdb_arch
kgdb_io
kset_uevent_ops
lock_manager_operations
microcode_ops
mtrr_ops
neigh_ops
nlmsvc_binding
of_device_id
pci_raw_ops
pipe_buf_operations
platform_hibernation_ops
platform_suspend_ops
proto_ops
rpc_pipe_ops
seq_operations
snd_ac97_build_ops
soc_pcmcia_socket_ops
stacktrace_ops
sysfs_ops
tty_operations
uart_ops
usb_mon_operations
wd_ops

View File

@ -16,6 +16,7 @@ absense||absence
absolut||absolute absolut||absolute
absoulte||absolute absoulte||absolute
acccess||access acccess||access
acceess||access
acceleratoin||acceleration acceleratoin||acceleration
accelleration||acceleration accelleration||acceleration
accesing||accessing accesing||accessing
@ -39,13 +40,14 @@ achitecture||architecture
acient||ancient acient||ancient
acitions||actions acitions||actions
acitve||active acitve||active
acknowldegement||acknowldegement acknowldegement||acknowledgment
acknowledgement||acknowledgment acknowledgement||acknowledgment
ackowledge||acknowledge ackowledge||acknowledge
ackowledged||acknowledged ackowledged||acknowledged
acording||according acording||according
activete||activate activete||activate
acumulating||accumulating acumulating||accumulating
acumulator||accumulator
adapater||adapter adapater||adapter
addional||additional addional||additional
additionaly||additionally additionaly||additionally
@ -60,15 +62,19 @@ adress||address
adresses||addresses adresses||addresses
adviced||advised adviced||advised
afecting||affecting afecting||affecting
againt||against
agaist||against agaist||against
albumns||albums albumns||albums
alegorical||allegorical alegorical||allegorical
algined||aligned
algorith||algorithm algorith||algorithm
algorithmical||algorithmically algorithmical||algorithmically
algoritm||algorithm algoritm||algorithm
algoritms||algorithms algoritms||algorithms
algorrithm||algorithm algorrithm||algorithm
algorritm||algorithm algorritm||algorithm
aligment||alignment
alignement||alignment
allign||align allign||align
allocatrd||allocated allocatrd||allocated
allocte||allocate allocte||allocate
@ -84,6 +90,10 @@ alue||value
ambigious||ambiguous ambigious||ambiguous
amoung||among amoung||among
amout||amount amout||amount
an union||a union
an user||a user
an userspace||a userspace
an one||a one
analysator||analyzer analysator||analyzer
ang||and ang||and
anniversery||anniversary anniversery||anniversary
@ -96,6 +106,7 @@ appearence||appearance
applicaion||application applicaion||application
appliction||application appliction||application
applictions||applications applictions||applications
applys||applies
appplications||applications appplications||applications
appropiate||appropriate appropiate||appropriate
appropriatly||appropriately appropriatly||appropriately
@ -184,6 +195,7 @@ cacluated||calculated
caculation||calculation caculation||calculation
calender||calendar calender||calendar
calle||called calle||called
callibration||calibration
calucate||calculate calucate||calculate
calulate||calculate calulate||calculate
cancelation||cancellation cancelation||cancellation
@ -234,6 +246,9 @@ commited||committed
commiting||committing commiting||committing
committ||commit committ||commit
commoditiy||commodity commoditiy||commodity
comsume||consume
comsumer||consumer
comsuming||consuming
compability||compatibility compability||compatibility
compaibility||compatibility compaibility||compatibility
compatability||compatibility compatability||compatibility
@ -244,6 +259,7 @@ compatiblity||compatibility
competion||completion competion||completion
compilant||compliant compilant||compliant
compleatly||completely compleatly||completely
completition||completion
completly||completely completly||completely
complient||compliant complient||compliant
componnents||components componnents||components
@ -254,9 +270,11 @@ comunication||communication
conbination||combination conbination||combination
conditionaly||conditionally conditionaly||conditionally
conected||connected conected||connected
configuartion||configuration
configuratoin||configuration configuratoin||configuration
configuraton||configuration configuraton||configuration
configuretion||configuration configuretion||configuration
configutation||configuration
conider||consider conider||consider
conjuction||conjunction conjuction||conjunction
connectinos||connections connectinos||connections
@ -305,6 +323,9 @@ defintion||definition
defintions||definitions defintions||definitions
defualt||default defualt||default
defult||default defult||default
deintializing||deinitializing
deintialize||deinitialize
deintialized||deinitialized
deivce||device deivce||device
delared||declared delared||declared
delare||declare delare||declare
@ -317,6 +338,7 @@ dependant||dependent
depreacted||deprecated depreacted||deprecated
depreacte||deprecate depreacte||deprecate
desactivate||deactivate desactivate||deactivate
desciptor||descriptor
desciptors||descriptors desciptors||descriptors
descripton||description descripton||description
descrition||description descrition||description
@ -346,9 +368,12 @@ differrence||difference
difinition||definition difinition||definition
diplay||display diplay||display
direectly||directly direectly||directly
disassocation||disassociation
disapear||disappear disapear||disappear
disapeared||disappeared disapeared||disappeared
disappared||disappeared disappared||disappeared
disble||disable
disbled||disabled
disconnet||disconnect disconnet||disconnect
discontinous||discontinuous discontinous||discontinuous
dispertion||dispersion dispertion||dispersion
@ -369,10 +394,12 @@ easilly||easily
ecspecially||especially ecspecially||especially
edditable||editable edditable||editable
editting||editing editting||editing
efective||effective
efficently||efficiently efficently||efficiently
ehther||ether ehther||ether
eigth||eight eigth||eight
eletronic||electronic eletronic||electronic
embeded||embedded
enabledi||enabled enabledi||enabled
enchanced||enhanced enchanced||enhanced
encorporating||incorporating encorporating||incorporating
@ -408,6 +435,7 @@ expecially||especially
explicite||explicit explicite||explicit
explicitely||explicitly explicitely||explicitly
explict||explicit explict||explicit
explictely||explicitly
explictly||explicitly explictly||explicitly
expresion||expression expresion||expression
exprimental||experimental exprimental||experimental
@ -417,9 +445,12 @@ extention||extension
extracter||extractor extracter||extractor
faild||failed faild||failed
faill||fail faill||fail
failied||failed
faillure||failure
failue||failure failue||failure
failuer||failure failuer||failure
faireness||fairness faireness||fairness
falied||failed
faliure||failure faliure||failure
familar||familiar familar||familiar
fatser||faster fatser||faster
@ -436,11 +467,13 @@ finsih||finish
flusing||flushing flusing||flushing
folloing||following folloing||following
followign||following followign||following
followings||following
follwing||following follwing||following
forseeable||foreseeable forseeable||foreseeable
forse||force forse||force
fortan||fortran fortan||fortran
forwardig||forwarding forwardig||forwarding
framming||framing
framwork||framework framwork||framework
frequncy||frequency frequncy||frequency
frome||from frome||from
@ -482,6 +515,7 @@ howver||however
hsould||should hsould||should
hypter||hyper hypter||hyper
identidier||identifier identidier||identifier
illigal||illegal
imblance||imbalance imblance||imbalance
immeadiately||immediately immeadiately||immediately
immedaite||immediate immedaite||immediate
@ -520,11 +554,13 @@ informtion||information
infromation||information infromation||information
ingore||ignore ingore||ignore
inital||initial inital||initial
initalized||initialized
initalised||initialized initalised||initialized
initalise||initialize initalise||initialize
initalize||initialize initalize||initialize
initation||initiation initation||initiation
initators||initiators initators||initiators
initialiazation||initialization
initializiation||initialization initializiation||initialization
initialzed||initialized initialzed||initialized
initilization||initialization initilization||initialization
@ -532,6 +568,7 @@ initilize||initialize
inofficial||unofficial inofficial||unofficial
insititute||institute insititute||institute
instal||install instal||install
instanciated||instantiated
inteface||interface inteface||interface
integreated||integrated integreated||integrated
integrety||integrity integrety||integrity
@ -553,13 +590,15 @@ interruptted||interrupted
interupted||interrupted interupted||interrupted
interupt||interrupt interupt||interrupt
intial||initial intial||initial
intialization||initialization
intialized||initialized intialized||initialized
intialize||initialize intialize||initialize
intregral||integral intregral||integral
intrrupt||interrupt intrrupt||interrupt
intterrupt||interrupt
intuative||intuitive intuative||intuitive
invaid||invalid invaid||invalid
invalde||invald invalde||invalid
invalide||invalid invalide||invalid
invididual||individual invididual||individual
invokation||invocation invokation||invocation
@ -567,6 +606,8 @@ invokations||invocations
irrelevent||irrelevant irrelevent||irrelevant
isnt||isn't isnt||isn't
isssue||issue isssue||issue
iternations||iterations
itertation||iteration
itslef||itself itslef||itself
jave||java jave||java
jeffies||jiffies jeffies||jiffies
@ -621,6 +662,7 @@ messsage||message
messsages||messages messsages||messages
microprocesspr||microprocessor microprocesspr||microprocessor
milliseonds||milliseconds milliseonds||milliseconds
minium||minimum
minumum||minimum minumum||minimum
miscelleneous||miscellaneous miscelleneous||miscellaneous
misformed||malformed misformed||malformed
@ -629,7 +671,6 @@ mispelt||misspelt
miximum||maximum miximum||maximum
mmnemonic||mnemonic mmnemonic||mnemonic
mnay||many mnay||many
modeled||modelled
modulues||modules modulues||modules
monochorome||monochrome monochorome||monochrome
monochromo||monochrome monochromo||monochrome
@ -650,6 +691,7 @@ neccecary||necessary
neccesary||necessary neccesary||necessary
neccessary||necessary neccessary||necessary
necesary||necessary necesary||necessary
neded||needed
negaive||negative negaive||negative
negoitation||negotiation negoitation||negotiation
negotation||negotiation negotation||negotiation
@ -669,8 +711,11 @@ occurances||occurrences
occured||occurred occured||occurred
occurence||occurrence occurence||occurrence
occure||occurred occure||occurred
occured||occurred
occuring||occurring occuring||occurring
offet||offset offet||offset
omited||omitted
omiting||omitting
omitt||omit omitt||omit
ommiting||omitting ommiting||omitting
ommitted||omitted ommitted||omitted
@ -682,13 +727,19 @@ optionnal||optional
optmizations||optimizations optmizations||optimizations
orientatied||orientated orientatied||orientated
orientied||oriented orientied||oriented
orignal||original
otherise||otherwise otherise||otherwise
ouput||output ouput||output
oustanding||outstanding
overaall||overall overaall||overall
overhread||overhead overhread||overhead
overlaping||overlapping overlaping||overlapping
overide||override
overrided||overridden
overriden||overridden overriden||overridden
overun||overrun overun||overrun
overwritting||overwriting
overwriten||overwritten
pacakge||package pacakge||package
pachage||package pachage||package
packacge||package packacge||package
@ -699,6 +750,7 @@ pakage||package
pallette||palette pallette||palette
paln||plan paln||plan
paramameters||parameters paramameters||parameters
paramaters||parameters
paramater||parameter paramater||parameter
parametes||parameters parametes||parameters
parametised||parametrised parametised||parametrised
@ -706,6 +758,7 @@ paramter||parameter
paramters||parameters paramters||parameters
particuarly||particularly particuarly||particularly
particularily||particularly particularily||particularly
partiton||partition
pased||passed pased||passed
passin||passing passin||passing
pathes||paths pathes||paths
@ -725,6 +778,7 @@ pleaes||please
ploting||plotting ploting||plotting
plugable||pluggable plugable||pluggable
poinnter||pointer poinnter||pointer
pointeur||pointer
poiter||pointer poiter||pointer
posible||possible posible||possible
positon||position positon||position
@ -753,6 +807,7 @@ procceed||proceed
proccesors||processors proccesors||processors
procesed||processed procesed||processed
proces||process proces||process
procesing||processing
processessing||processing processessing||processing
processess||processes processess||processes
processpr||processor processpr||processor
@ -781,6 +836,7 @@ protable||portable
protcol||protocol protcol||protocol
protecion||protection protecion||protection
protocoll||protocol protocoll||protocol
promixity||proximity
psudo||pseudo psudo||pseudo
psuedo||pseudo psuedo||pseudo
psychadelic||psychedelic psychadelic||psychedelic
@ -802,6 +858,7 @@ recommanded||recommended
recyle||recycle recyle||recycle
redircet||redirect redircet||redirect
redirectrion||redirection redirectrion||redirection
reename||rename
refcounf||refcount refcounf||refcount
refence||reference refence||reference
refered||referred refered||referred
@ -938,6 +995,7 @@ straming||streaming
struc||struct struc||struct
structres||structures structres||structures
stuct||struct stuct||struct
strucuture||structure
stucture||structure stucture||structure
sturcture||structure sturcture||structure
subdirectoires||subdirectories subdirectoires||subdirectories
@ -945,7 +1003,9 @@ suble||subtle
substract||subtract substract||subtract
succesfully||successfully succesfully||successfully
succesful||successful succesful||successful
successed||succeeded
successfull||successful successfull||successful
successfuly||successfully
sucessfully||successfully sucessfully||successfully
sucess||success sucess||success
superflous||superfluous superflous||superfluous
@ -961,13 +1021,22 @@ suppport||support
supress||suppress supress||suppress
surpresses||suppresses surpresses||suppresses
susbsystem||subsystem susbsystem||subsystem
suspeneded||suspended
suspicously||suspiciously suspicously||suspiciously
swaping||swapping swaping||swapping
switchs||switches switchs||switches
swith||switch
swithable||switchable
swithc||switch
swithced||switched
swithcing||switching
swithed||switched
swithing||switching
symetric||symmetric symetric||symmetric
synax||syntax synax||syntax
synchonized||synchronized synchonized||synchronized
syncronize||synchronize syncronize||synchronize
syncronized||synchronized
syncronizing||synchronizing syncronizing||synchronizing
syncronus||synchronous syncronus||synchronous
syste||system syste||system
@ -979,6 +1048,7 @@ targetting||targeting
teh||the teh||the
temorary||temporary temorary||temporary
temproarily||temporarily temproarily||temporarily
therfore||therefore
thier||their thier||their
threds||threads threds||threads
threshhold||threshold threshhold||threshold
@ -992,7 +1062,7 @@ tramsmitted||transmitted
tramsmit||transmit tramsmit||transmit
tranfer||transfer tranfer||transfer
transciever||transceiver transciever||transceiver
transferd||transferrd transferd||transferred
transfered||transferred transfered||transferred
transfering||transferring transfering||transferring
transision||transition transision||transition
@ -1006,22 +1076,31 @@ ture||true
tyep||type tyep||type
udpate||update udpate||update
uesd||used uesd||used
uncommited||uncommitted
unconditionaly||unconditionally unconditionaly||unconditionally
underun||underrun underun||underrun
unecessary||unnecessary unecessary||unnecessary
unexecpted||unexpected unexecpted||unexpected
unexpcted||unexpected
unexpectd||unexpected unexpectd||unexpected
unexpeted||unexpected unexpeted||unexpected
unexpexted||unexpected
unfortunatelly||unfortunately unfortunatelly||unfortunately
unifiy||unify unifiy||unify
unintialized||uninitialized unintialized||uninitialized
unkmown||unknown
unknonw||unknown unknonw||unknown
unknow||unknown unknow||unknown
unkown||unknown unkown||unknown
unneded||unneeded
unneedingly||unnecessarily unneedingly||unnecessarily
unnsupported||unsupported
unmached||unmatched
unresgister||unregister unresgister||unregister
unrgesiter||unregister
unsinged||unsigned unsinged||unsigned
unstabel||unstable unstabel||unstable
unsolicitied||unsolicited
unsuccessfull||unsuccessful unsuccessfull||unsuccessful
unsuported||unsupported unsuported||unsupported
untill||until untill||until
@ -1042,6 +1121,7 @@ vaid||valid
vaild||valid vaild||valid
valide||valid valide||valid
variantions||variations variantions||variations
varible||variable
varient||variant varient||variant
vaule||value vaule||value
verbse||verbose verbse||verbose