mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-06 03:45:24 -04:00
Merge android11-5.4.58+ (33cc3e7) into msm-5.4
* refs/heads/tmp-33cc3e7:
ANDROID: db845c: set BUILD_INITRAMFS=1
ANDROID: GKI: Build CEC_{CORE,NOTIFIER,PIN} in
ANDROID: GKI: Enable CEC support
ANDROID: ABI: Update ABI snapshot after additions to struct io_pgtable_cfg
ANDROID: iommu/io-pgtable: Allow IOMMU drivers to allocate/free page-table memory
ANDROID: update ABI
UPSTREAM: update to latest version of scripts/checkpatch.pl
FROMLIST: ufs: change the way to complete fDeviceInit
ANDROID: GKI: add built-in BCM Bluetooth driver
Revert "Revert "genetlink: remove genl_bind""
ANDROID: GKI: enable CONFIG_LEDS_TRIGGER_TIMER
ANDROID: GKI: add abi_gki_aarch64_oplus
ANDROID: GKI: fix up abi .xml file due to previous changes.
ANDROID: GKI: add some padding to some driver core structures
ANDROID: vendor_hooks: add waiting information for blocked tasks
ANDROID: GKI: Update abi_gki_aarch64_exynos
ANDROID: include/linux: add low power mode and fps to notifier
BACKPORT: scsi: ufs: Fix and simplify setup_xfer_req variant operation
ANDROID: GKI: enable USB UVC drivers
ANDROID: GKI: enabled CONFIG_USB_CONFIGFS_NCM=y
ANDROID: GKI: enable LEDS_CLASS_FLASH
Conflicts:
drivers/iommu/io-pgtable-arm.c
drivers/iommu/io-pgtable.c
include/linux/io-pgtable.h
scripts/checkpatch.pl
Change-Id: I6cbac7d913653388280a4c58f4f98e6f8b6b29f7
Signed-off-by: Ivaylo Georgiev <irgeorgiev@codeaurora.org>
Signed-off-by: Blagovest Kolenichev <bkolenichev@codeaurora.org>
This commit is contained in:
commit
7546983cd7
28 changed files with 11643 additions and 10076 deletions
|
|
@ -58,7 +58,7 @@ my %ignore_type = ();
|
|||
my @ignore = ();
|
||||
my $help = 0;
|
||||
my $configuration_file = ".checkpatch.conf";
|
||||
my $max_line_length = 80;
|
||||
my $max_line_length = 100;
|
||||
my $ignore_perl_version = 0;
|
||||
my $minimum_perl_version = 5.10.0;
|
||||
my $min_conf_desc_length = 4;
|
||||
|
|
@ -66,11 +66,12 @@ my $spelling_file = "$D/spelling.txt";
|
|||
my $codespell = 0;
|
||||
my $codespellfile = "/usr/share/codespell/dictionary.txt";
|
||||
my $conststructsfile = "$D/const_structs.checkpatch";
|
||||
my $typedefsfile = "";
|
||||
my $typedefsfile;
|
||||
my $color = "auto";
|
||||
my $allow_c99_comments = 1; # Can be overridden by --ignore C99_COMMENT_TOLERANCE
|
||||
# git output parsing needs US English output, so first set backtick child process LANGUAGE
|
||||
my $git_command ='export LANGUAGE=en_US.UTF-8; git';
|
||||
my $tabsize = 8;
|
||||
|
||||
sub help {
|
||||
my ($exitcode) = @_;
|
||||
|
|
@ -103,8 +104,11 @@ Options:
|
|||
--types TYPE(,TYPE2...) show only these comma separated message types
|
||||
--ignore TYPE(,TYPE2...) ignore various comma separated message types
|
||||
--show-types show the specific message type in the output
|
||||
--max-line-length=n set the maximum line length, if exceeded, warn
|
||||
--max-line-length=n set the maximum line length, (default $max_line_length)
|
||||
if exceeded, warn on patches
|
||||
requires --strict for use with --file
|
||||
--min-conf-desc-length=n set the min description length, if shorter, warn
|
||||
--tab-size=n set the number of spaces for tab (default $tabsize)
|
||||
--root=PATH PATH to the kernel tree root
|
||||
--no-summary suppress the per-file summary
|
||||
--mailback only produce a report in case of warnings/errors
|
||||
|
|
@ -222,6 +226,7 @@ GetOptions(
|
|||
'list-types!' => \$list_types,
|
||||
'max-line-length=i' => \$max_line_length,
|
||||
'min-conf-desc-length=i' => \$min_conf_desc_length,
|
||||
'tab-size=i' => \$tabsize,
|
||||
'root=s' => \$root,
|
||||
'summary!' => \$summary,
|
||||
'mailback!' => \$mailback,
|
||||
|
|
@ -248,6 +253,8 @@ list_types(0) if ($list_types);
|
|||
$fix = 1 if ($fix_inplace);
|
||||
$check_orig = $check;
|
||||
|
||||
die "$P: --git cannot be used with --file or --fix\n" if ($git && ($file || $fix));
|
||||
|
||||
my $exit = 0;
|
||||
|
||||
my $perl_version_ok = 1;
|
||||
|
|
@ -271,9 +278,12 @@ if ($color =~ /^[01]$/) {
|
|||
} elsif ($color =~ /^auto$/i) {
|
||||
$color = (-t STDOUT);
|
||||
} else {
|
||||
die "Invalid color mode: $color\n";
|
||||
die "$P: Invalid color mode: $color\n";
|
||||
}
|
||||
|
||||
# skip TAB size 1 to avoid additional checks on $tabsize - 1
|
||||
die "$P: Invalid TAB size: $tabsize\n" if ($tabsize < 2);
|
||||
|
||||
sub hash_save_array_words {
|
||||
my ($hashRef, $arrayRef) = @_;
|
||||
|
||||
|
|
@ -480,7 +490,7 @@ our $allocFunctions = qr{(?x:
|
|||
(?:kv|k|v)[czm]alloc(?:_node|_array)? |
|
||||
kstrdup(?:_const)? |
|
||||
kmemdup(?:_nul)?) |
|
||||
(?:\w+)?alloc_skb(?:ip_align)? |
|
||||
(?:\w+)?alloc_skb(?:_ip_align)? |
|
||||
# dev_alloc_skb/netdev_alloc_skb, et al
|
||||
dma_alloc_coherent
|
||||
)};
|
||||
|
|
@ -585,6 +595,8 @@ our @mode_permission_funcs = (
|
|||
["__ATTR", 2],
|
||||
);
|
||||
|
||||
my $word_pattern = '\b[A-Z]?[a-z]{2,}\b';
|
||||
|
||||
#Create a search pattern for all these functions to speed up a loop below
|
||||
our $mode_perms_search = "";
|
||||
foreach my $entry (@mode_permission_funcs) {
|
||||
|
|
@ -753,7 +765,7 @@ sub read_words {
|
|||
next;
|
||||
}
|
||||
|
||||
$$wordsRef .= '|' if ($$wordsRef ne "");
|
||||
$$wordsRef .= '|' if (defined $$wordsRef);
|
||||
$$wordsRef .= $line;
|
||||
}
|
||||
close($file);
|
||||
|
|
@ -763,16 +775,18 @@ sub read_words {
|
|||
return 0;
|
||||
}
|
||||
|
||||
my $const_structs = "";
|
||||
read_words(\$const_structs, $conststructsfile)
|
||||
or warn "No structs that should be const will be found - file '$conststructsfile': $!\n";
|
||||
my $const_structs;
|
||||
if (show_type("CONST_STRUCT")) {
|
||||
read_words(\$const_structs, $conststructsfile)
|
||||
or warn "No structs that should be const will be found - file '$conststructsfile': $!\n";
|
||||
}
|
||||
|
||||
my $typeOtherTypedefs = "";
|
||||
if (length($typedefsfile)) {
|
||||
if (defined($typedefsfile)) {
|
||||
my $typeOtherTypedefs;
|
||||
read_words(\$typeOtherTypedefs, $typedefsfile)
|
||||
or warn "No additional types will be considered - file '$typedefsfile': $!\n";
|
||||
$typeTypedefs .= '|' . $typeOtherTypedefs if (defined $typeOtherTypedefs);
|
||||
}
|
||||
$typeTypedefs .= '|' . $typeOtherTypedefs if ($typeOtherTypedefs ne "");
|
||||
|
||||
sub build_types {
|
||||
my $mods = "(?x: \n" . join("|\n ", (@modifierList, @modifierListFile)) . "\n)";
|
||||
|
|
@ -811,12 +825,12 @@ sub build_types {
|
|||
}x;
|
||||
$Type = qr{
|
||||
$NonptrType
|
||||
(?:(?:\s|\*|\[\])+\s*const|(?:\s|\*\s*(?:const\s*)?|\[\])+|(?:\s*\[\s*\])+)?
|
||||
(?:(?:\s|\*|\[\])+\s*const|(?:\s|\*\s*(?:const\s*)?|\[\])+|(?:\s*\[\s*\])+){0,4}
|
||||
(?:\s+$Inline|\s+$Modifier)*
|
||||
}x;
|
||||
$TypeMisordered = qr{
|
||||
$NonptrTypeMisordered
|
||||
(?:(?:\s|\*|\[\])+\s*const|(?:\s|\*\s*(?:const\s*)?|\[\])+|(?:\s*\[\s*\])+)?
|
||||
(?:(?:\s|\*|\[\])+\s*const|(?:\s|\*\s*(?:const\s*)?|\[\])+|(?:\s*\[\s*\])+){0,4}
|
||||
(?:\s+$Inline|\s+$Modifier)*
|
||||
}x;
|
||||
$Declare = qr{(?:$Storage\s+(?:$Inline\s+)?)?$Type};
|
||||
|
|
@ -837,7 +851,6 @@ our $FuncArg = qr{$Typecast{0,1}($LvalOrFunc|$Constant|$String)};
|
|||
our $declaration_macros = qr{(?x:
|
||||
(?:$Storage\s+)?(?:[A-Z_][A-Z0-9]*_){0,2}(?:DEFINE|DECLARE)(?:_[A-Z0-9]+){1,6}\s*\(|
|
||||
(?:$Storage\s+)?[HLP]?LIST_HEAD\s*\(|
|
||||
(?:$Storage\s+)?${Type}\s+uninitialized_var\s*\(|
|
||||
(?:SKCIPHER_REQUEST|SHASH_DESC|AHASH_REQUEST)_ON_STACK\s*\(
|
||||
)};
|
||||
|
||||
|
|
@ -881,14 +894,18 @@ sub seed_camelcase_file {
|
|||
}
|
||||
}
|
||||
|
||||
our %maintained_status = ();
|
||||
|
||||
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`;
|
||||
if (!exists($maintained_status{$filename})) {
|
||||
$maintained_status{$filename} = `perl $root/scripts/get_maintainer.pl --status --nom --nol --nogit --nogit-fallback -f $filename 2>&1`;
|
||||
}
|
||||
|
||||
return $status =~ /obsolete/i;
|
||||
return $maintained_status{$filename} =~ /obsolete/i;
|
||||
}
|
||||
|
||||
sub is_SPDX_License_valid {
|
||||
|
|
@ -1055,6 +1072,7 @@ for my $filename (@ARGV) {
|
|||
while (<$FILE>) {
|
||||
chomp;
|
||||
push(@rawlines, $_);
|
||||
$vname = qq("$1") if ($filename eq '-' && $_ =~ m/^Subject:\s+(.+)/i);
|
||||
}
|
||||
close($FILE);
|
||||
|
||||
|
|
@ -1121,6 +1139,7 @@ sub parse_email {
|
|||
my ($formatted_email) = @_;
|
||||
|
||||
my $name = "";
|
||||
my $name_comment = "";
|
||||
my $address = "";
|
||||
my $comment = "";
|
||||
|
||||
|
|
@ -1153,6 +1172,10 @@ sub parse_email {
|
|||
|
||||
$name = trim($name);
|
||||
$name =~ s/^\"|\"$//g;
|
||||
$name =~ s/(\s*\([^\)]+\))\s*//;
|
||||
if (defined($1)) {
|
||||
$name_comment = trim($1);
|
||||
}
|
||||
$address = trim($address);
|
||||
$address =~ s/^\<|\>$//g;
|
||||
|
||||
|
|
@ -1161,7 +1184,7 @@ sub parse_email {
|
|||
$name = "\"$name\"";
|
||||
}
|
||||
|
||||
return ($name, $address, $comment);
|
||||
return ($name, $name_comment, $address, $comment);
|
||||
}
|
||||
|
||||
sub format_email {
|
||||
|
|
@ -1187,6 +1210,23 @@ sub format_email {
|
|||
return $formatted_email;
|
||||
}
|
||||
|
||||
sub reformat_email {
|
||||
my ($email) = @_;
|
||||
|
||||
my ($email_name, $name_comment, $email_address, $comment) = parse_email($email);
|
||||
return format_email($email_name, $email_address);
|
||||
}
|
||||
|
||||
sub same_email_addresses {
|
||||
my ($email1, $email2) = @_;
|
||||
|
||||
my ($email1_name, $name1_comment, $email1_address, $comment1) = parse_email($email1);
|
||||
my ($email2_name, $name2_comment, $email2_address, $comment2) = parse_email($email2);
|
||||
|
||||
return $email1_name eq $email2_name &&
|
||||
$email1_address eq $email2_address;
|
||||
}
|
||||
|
||||
sub which {
|
||||
my ($bin) = @_;
|
||||
|
||||
|
|
@ -1220,7 +1260,7 @@ sub expand_tabs {
|
|||
if ($c eq "\t") {
|
||||
$res .= ' ';
|
||||
$n++;
|
||||
for (; ($n % 8) != 0; $n++) {
|
||||
for (; ($n % $tabsize) != 0; $n++) {
|
||||
$res .= ' ';
|
||||
}
|
||||
next;
|
||||
|
|
@ -1649,8 +1689,16 @@ sub ctx_statement_level {
|
|||
sub ctx_locate_comment {
|
||||
my ($first_line, $end_line) = @_;
|
||||
|
||||
# If c99 comment on the current line, or the line before or after
|
||||
my ($current_comment) = ($rawlines[$end_line - 1] =~ m@^\+.*(//.*$)@);
|
||||
return $current_comment if (defined $current_comment);
|
||||
($current_comment) = ($rawlines[$end_line - 2] =~ m@^[\+ ].*(//.*$)@);
|
||||
return $current_comment if (defined $current_comment);
|
||||
($current_comment) = ($rawlines[$end_line] =~ m@^[\+ ].*(//.*$)@);
|
||||
return $current_comment if (defined $current_comment);
|
||||
|
||||
# Catch a comment on the end of the line itself.
|
||||
my ($current_comment) = ($rawlines[$end_line - 1] =~ m@.*(/\*.*\*/)\s*(?:\\\s*)?$@);
|
||||
($current_comment) = ($rawlines[$end_line - 1] =~ m@.*(/\*.*\*/)\s*(?:\\\s*)?$@);
|
||||
return $current_comment if (defined $current_comment);
|
||||
|
||||
# Look through the context and try and figure out if there is a
|
||||
|
|
@ -2233,7 +2281,7 @@ sub string_find_replace {
|
|||
sub tabify {
|
||||
my ($leading) = @_;
|
||||
|
||||
my $source_indent = 8;
|
||||
my $source_indent = $tabsize;
|
||||
my $max_spaces_before_tab = $source_indent - 1;
|
||||
my $spaces_to_tab = " " x $source_indent;
|
||||
|
||||
|
|
@ -2302,6 +2350,19 @@ sub pos_last_openparen {
|
|||
return length(expand_tabs(substr($line, 0, $last_openparen))) + 1;
|
||||
}
|
||||
|
||||
sub get_raw_comment {
|
||||
my ($line, $rawline) = @_;
|
||||
my $comment = '';
|
||||
|
||||
for my $i (0 .. (length($line) - 1)) {
|
||||
if (substr($line, $i, 1) eq "$;") {
|
||||
$comment .= substr($rawline, $i, 1);
|
||||
}
|
||||
}
|
||||
|
||||
return $comment;
|
||||
}
|
||||
|
||||
sub process {
|
||||
my $filename = shift;
|
||||
|
||||
|
|
@ -2326,6 +2387,7 @@ sub process {
|
|||
my $is_binding_patch = -1;
|
||||
my $in_header_lines = $file ? 0 : 1;
|
||||
my $in_commit_log = 0; #Scanning lines before patch
|
||||
my $has_patch_separator = 0; #Found a --- line
|
||||
my $has_commit_log = 0; #Encountered lines before patch
|
||||
my $commit_log_lines = 0; #Number of commit log lines
|
||||
my $commit_log_possible_stack_dump = 0;
|
||||
|
|
@ -2389,7 +2451,7 @@ sub process {
|
|||
|
||||
if ($rawline=~/^\+\+\+\s+(\S+)/) {
|
||||
$setup_docs = 0;
|
||||
if ($1 =~ m@Documentation/admin-guide/kernel-parameters.rst$@) {
|
||||
if ($1 =~ m@Documentation/admin-guide/kernel-parameters.txt$@) {
|
||||
$setup_docs = 1;
|
||||
}
|
||||
#next;
|
||||
|
|
@ -2470,6 +2532,7 @@ sub process {
|
|||
$sline =~ s/$;/ /g; #with comments as spaces
|
||||
|
||||
my $rawline = $rawlines[$linenr - 1];
|
||||
my $raw_comment = get_raw_comment($line, $rawline);
|
||||
|
||||
# check if it's a mode change, rename or start of a patch
|
||||
if (!$in_commit_log &&
|
||||
|
|
@ -2588,7 +2651,7 @@ sub process {
|
|||
if (($last_binding_patch != -1) &&
|
||||
($last_binding_patch ^ $is_binding_patch)) {
|
||||
WARN("DT_SPLIT_BINDING_PATCH",
|
||||
"DT binding docs and includes should be a separate patch. See: Documentation/devicetree/bindings/submitting-patches.txt\n");
|
||||
"DT binding docs and includes should be a separate patch. See: Documentation/devicetree/bindings/submitting-patches.rst\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2734,21 +2797,26 @@ sub process {
|
|||
$author = $1;
|
||||
$author = encode("utf8", $author) if ($line =~ /=\?utf-8\?/i);
|
||||
$author =~ s/"//g;
|
||||
$author = reformat_email($author);
|
||||
}
|
||||
|
||||
# Check the patch for a signoff:
|
||||
if ($line =~ /^\s*signed-off-by:/i) {
|
||||
if ($line =~ /^\s*signed-off-by:\s*(.*)/i) {
|
||||
$signoff++;
|
||||
$in_commit_log = 0;
|
||||
if ($author ne '') {
|
||||
my $l = $line;
|
||||
$l =~ s/"//g;
|
||||
if ($l =~ /^\s*signed-off-by:\s*\Q$author\E/i) {
|
||||
$authorsignoff = 1;
|
||||
if (same_email_addresses($1, $author)) {
|
||||
$authorsignoff = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Check for patch separator
|
||||
if ($line =~ /^---$/) {
|
||||
$has_patch_separator = 1;
|
||||
$in_commit_log = 0;
|
||||
}
|
||||
|
||||
# Check if MAINTAINERS is being updated. If so, there's probably no need to
|
||||
# emit the "does MAINTAINERS need updating?" message on file add/move/delete
|
||||
if ($line =~ /^\s*MAINTAINERS\s*\|/) {
|
||||
|
|
@ -2794,7 +2862,7 @@ sub process {
|
|||
}
|
||||
}
|
||||
|
||||
my ($email_name, $email_address, $comment) = parse_email($email);
|
||||
my ($email_name, $name_comment, $email_address, $comment) = parse_email($email);
|
||||
my $suggested_email = format_email(($email_name, $email_address));
|
||||
if ($suggested_email eq "") {
|
||||
ERROR("BAD_SIGN_OFF",
|
||||
|
|
@ -2805,9 +2873,7 @@ sub process {
|
|||
$dequoted =~ s/" </ </;
|
||||
# Don't force email to have quotes
|
||||
# Allow just an angle bracketed address
|
||||
if ("$dequoted$comment" ne $email &&
|
||||
"<$email_address>$comment" ne $email &&
|
||||
"$suggested_email$comment" ne $email) {
|
||||
if (!same_email_addresses($email, $suggested_email)) {
|
||||
WARN("BAD_SIGN_OFF",
|
||||
"email address '$email' might be better as '$suggested_email$comment'\n" . $herecurr);
|
||||
}
|
||||
|
|
@ -2850,10 +2916,10 @@ sub process {
|
|||
"A patch subject line should describe the change not the tool that found it\n" . $herecurr);
|
||||
}
|
||||
|
||||
# Check for unwanted Gerrit info
|
||||
if ($in_commit_log && $line =~ /^\s*change-id:/i) {
|
||||
# Check for Gerrit Change-Ids not in any patch context
|
||||
if ($realfile eq '' && !$has_patch_separator && $line =~ /^\s*change-id:/i) {
|
||||
ERROR("GERRIT_CHANGE_ID",
|
||||
"Remove Gerrit Change-Id's before submitting upstream.\n" . $herecurr);
|
||||
"Remove Gerrit Change-Id's before submitting upstream\n" . $herecurr);
|
||||
}
|
||||
|
||||
# Check if the commit log is in a possible stack dump
|
||||
|
|
@ -2891,7 +2957,7 @@ sub process {
|
|||
|
||||
# Check for git id commit length and improperly formed commit descriptions
|
||||
if ($in_commit_log && !$commit_log_possible_stack_dump &&
|
||||
$line !~ /^\s*(?:Link|Patchwork|http|https|BugLink):/i &&
|
||||
$line !~ /^\s*(?:Link|Patchwork|http|https|BugLink|base-commit):/i &&
|
||||
$line !~ /^This reverts commit [0-9a-f]{7,40}/ &&
|
||||
($line =~ /\bcommit\s+[0-9a-f]{5,}\b/i ||
|
||||
($line =~ /(?:\s|^)[0-9a-f]{12,40}(?:[\s"'\(\[]|$)/i &&
|
||||
|
|
@ -2960,6 +3026,14 @@ sub process {
|
|||
"added, moved or deleted file(s), does MAINTAINERS need updating?\n" . $herecurr);
|
||||
}
|
||||
|
||||
# Check for adding new DT bindings not in schema format
|
||||
if (!$in_commit_log &&
|
||||
($line =~ /^new file mode\s*\d+\s*$/) &&
|
||||
($realfile =~ m@^Documentation/devicetree/bindings/.*\.txt$@)) {
|
||||
WARN("DT_SCHEMA_BINDING_PATCH",
|
||||
"DT bindings should be in DT schema format. See: Documentation/devicetree/writing-schema.rst\n");
|
||||
}
|
||||
|
||||
# Check for wrappage within a valid hunk of the file
|
||||
if ($realcnt != 0 && $line !~ m{^(?:\+|-| |\\ No newline|$)}) {
|
||||
ERROR("CORRUPTED_PATCH",
|
||||
|
|
@ -3136,14 +3210,43 @@ sub process {
|
|||
#print "is_start<$is_start> is_end<$is_end> length<$length>\n";
|
||||
}
|
||||
|
||||
# check for MAINTAINERS entries that don't have the right form
|
||||
if ($realfile =~ /^MAINTAINERS$/ &&
|
||||
$rawline =~ /^\+[A-Z]:/ &&
|
||||
$rawline !~ /^\+[A-Z]:\t\S/) {
|
||||
if (WARN("MAINTAINERS_STYLE",
|
||||
"MAINTAINERS entries use one tab after TYPE:\n" . $herecurr) &&
|
||||
$fix) {
|
||||
$fixed[$fixlinenr] =~ s/^(\+[A-Z]):\s*/$1:\t/;
|
||||
# check MAINTAINERS entries
|
||||
if ($realfile =~ /^MAINTAINERS$/) {
|
||||
# check MAINTAINERS entries for the right form
|
||||
if ($rawline =~ /^\+[A-Z]:/ &&
|
||||
$rawline !~ /^\+[A-Z]:\t\S/) {
|
||||
if (WARN("MAINTAINERS_STYLE",
|
||||
"MAINTAINERS entries use one tab after TYPE:\n" . $herecurr) &&
|
||||
$fix) {
|
||||
$fixed[$fixlinenr] =~ s/^(\+[A-Z]):\s*/$1:\t/;
|
||||
}
|
||||
}
|
||||
# check MAINTAINERS entries for the right ordering too
|
||||
my $preferred_order = 'MRLSWQBCPTFXNK';
|
||||
if ($rawline =~ /^\+[A-Z]:/ &&
|
||||
$prevrawline =~ /^[\+ ][A-Z]:/) {
|
||||
$rawline =~ /^\+([A-Z]):\s*(.*)/;
|
||||
my $cur = $1;
|
||||
my $curval = $2;
|
||||
$prevrawline =~ /^[\+ ]([A-Z]):\s*(.*)/;
|
||||
my $prev = $1;
|
||||
my $prevval = $2;
|
||||
my $curindex = index($preferred_order, $cur);
|
||||
my $previndex = index($preferred_order, $prev);
|
||||
if ($curindex < 0) {
|
||||
WARN("MAINTAINERS_STYLE",
|
||||
"Unknown MAINTAINERS entry type: '$cur'\n" . $herecurr);
|
||||
} else {
|
||||
if ($previndex >= 0 && $curindex < $previndex) {
|
||||
WARN("MAINTAINERS_STYLE",
|
||||
"Misordered MAINTAINERS entry - list '$cur:' before '$prev:'\n" . $hereprev);
|
||||
} elsif ((($prev eq 'F' && $cur eq 'F') ||
|
||||
($prev eq 'X' && $cur eq 'X')) &&
|
||||
($prevval cmp $curval) > 0) {
|
||||
WARN("MAINTAINERS_STYLE",
|
||||
"Misordered MAINTAINERS entry - list file patterns in alphabetic order\n" . $hereprev);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3209,7 +3312,7 @@ sub process {
|
|||
$comment = '/*';
|
||||
} elsif ($realfile =~ /\.(c|dts|dtsi)$/) {
|
||||
$comment = '//';
|
||||
} elsif (($checklicenseline == 2) || $realfile =~ /\.(sh|pl|py|awk|tc)$/) {
|
||||
} elsif (($checklicenseline == 2) || $realfile =~ /\.(sh|pl|py|awk|tc|yaml)$/) {
|
||||
$comment = '#';
|
||||
} elsif ($realfile =~ /\.rst$/) {
|
||||
$comment = '..';
|
||||
|
|
@ -3233,6 +3336,17 @@ sub process {
|
|||
WARN("SPDX_LICENSE_TAG",
|
||||
"'$spdx_license' is not supported in LICENSES/...\n" . $herecurr);
|
||||
}
|
||||
if ($realfile =~ m@^Documentation/devicetree/bindings/@ &&
|
||||
not $spdx_license =~ /GPL-2\.0.*BSD-2-Clause/) {
|
||||
my $msg_level = \&WARN;
|
||||
$msg_level = \&CHK if ($file);
|
||||
if (&{$msg_level}("SPDX_LICENSE_TAG",
|
||||
|
||||
"DT binding documents should be licensed (GPL-2.0-only OR BSD-2-Clause)\n" . $herecurr) &&
|
||||
$fix) {
|
||||
$fixed[$fixlinenr] =~ s/SPDX-License-Identifier: .*/SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)/;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3309,8 +3423,10 @@ sub process {
|
|||
|
||||
if ($msg_type ne "" &&
|
||||
(show_type("LONG_LINE") || show_type($msg_type))) {
|
||||
WARN($msg_type,
|
||||
"line over $max_line_length characters\n" . $herecurr);
|
||||
my $msg_level = \&WARN;
|
||||
$msg_level = \&CHK if ($file);
|
||||
&{$msg_level}($msg_type,
|
||||
"line length of $length exceeds $max_line_length columns\n" . $herecurr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3324,7 +3440,7 @@ sub process {
|
|||
next if ($realfile !~ /\.(h|c|pl|dtsi|dts)$/);
|
||||
|
||||
# at the beginning of a line any tabs must come first and anything
|
||||
# more than 8 must use tabs.
|
||||
# more than $tabsize must use tabs.
|
||||
if ($rawline =~ /^\+\s* \t\s*\S/ ||
|
||||
$rawline =~ /^\+\s* \s*/) {
|
||||
my $herevet = "$here\n" . cat_vet($rawline) . "\n";
|
||||
|
|
@ -3336,6 +3452,42 @@ sub process {
|
|||
}
|
||||
}
|
||||
|
||||
# check for repeated words separated by a single space
|
||||
if ($rawline =~ /^\+/) {
|
||||
while ($rawline =~ /\b($word_pattern) (?=($word_pattern))/g) {
|
||||
|
||||
my $first = $1;
|
||||
my $second = $2;
|
||||
|
||||
if ($first =~ /(?:struct|union|enum)/) {
|
||||
pos($rawline) += length($first) + length($second) + 1;
|
||||
next;
|
||||
}
|
||||
|
||||
next if ($first ne $second);
|
||||
next if ($first eq 'long');
|
||||
|
||||
if (WARN("REPEATED_WORD",
|
||||
"Possible repeated word: '$first'\n" . $herecurr) &&
|
||||
$fix) {
|
||||
$fixed[$fixlinenr] =~ s/\b$first $second\b/$first/;
|
||||
}
|
||||
}
|
||||
|
||||
# if it's a repeated word on consecutive lines in a comment block
|
||||
if ($prevline =~ /$;+\s*$/ &&
|
||||
$prevrawline =~ /($word_pattern)\s*$/) {
|
||||
my $last_word = $1;
|
||||
if ($rawline =~ /^\+\s*\*\s*$last_word /) {
|
||||
if (WARN("REPEATED_WORD",
|
||||
"Possible repeated word: '$last_word'\n" . $hereprev) &&
|
||||
$fix) {
|
||||
$fixed[$fixlinenr] =~ s/(\+\s*\*\s*)$last_word /$1/;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# check for space before tabs.
|
||||
if ($rawline =~ /^\+/ && $rawline =~ / \t/) {
|
||||
my $herevet = "$here\n" . cat_vet($rawline) . "\n";
|
||||
|
|
@ -3343,7 +3495,7 @@ sub process {
|
|||
"please, no space before tabs\n" . $herevet) &&
|
||||
$fix) {
|
||||
while ($fixed[$fixlinenr] =~
|
||||
s/(^\+.*) {8,8}\t/$1\t\t/) {}
|
||||
s/(^\+.*) {$tabsize,$tabsize}\t/$1\t\t/) {}
|
||||
while ($fixed[$fixlinenr] =~
|
||||
s/(^\+.*) +\t/$1\t/) {}
|
||||
}
|
||||
|
|
@ -3365,11 +3517,11 @@ sub process {
|
|||
if ($perl_version_ok &&
|
||||
$sline =~ /^\+\t+( +)(?:$c90_Keywords\b|\{\s*$|\}\s*(?:else\b|while\b|\s*$)|$Declare\s*$Ident\s*[;=])/) {
|
||||
my $indent = length($1);
|
||||
if ($indent % 8) {
|
||||
if ($indent % $tabsize) {
|
||||
if (WARN("TABSTOP",
|
||||
"Statements should start on a tabstop\n" . $herecurr) &&
|
||||
$fix) {
|
||||
$fixed[$fixlinenr] =~ s@(^\+\t+) +@$1 . "\t" x ($indent/8)@e;
|
||||
$fixed[$fixlinenr] =~ s@(^\+\t+) +@$1 . "\t" x ($indent/$tabsize)@e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3387,8 +3539,8 @@ sub process {
|
|||
my $newindent = $2;
|
||||
|
||||
my $goodtabindent = $oldindent .
|
||||
"\t" x ($pos / 8) .
|
||||
" " x ($pos % 8);
|
||||
"\t" x ($pos / $tabsize) .
|
||||
" " x ($pos % $tabsize);
|
||||
my $goodspaceindent = $oldindent . " " x $pos;
|
||||
|
||||
if ($newindent ne $goodtabindent &&
|
||||
|
|
@ -3859,11 +4011,11 @@ sub process {
|
|||
#print "line<$line> prevline<$prevline> indent<$indent> sindent<$sindent> check<$check> continuation<$continuation> s<$s> cond_lines<$cond_lines> stat_real<$stat_real> stat<$stat>\n";
|
||||
|
||||
if ($check && $s ne '' &&
|
||||
(($sindent % 8) != 0 ||
|
||||
(($sindent % $tabsize) != 0 ||
|
||||
($sindent < $indent) ||
|
||||
($sindent == $indent &&
|
||||
($s !~ /^\s*(?:\}|\{|else\b)/)) ||
|
||||
($sindent > $indent + 8))) {
|
||||
($sindent > $indent + $tabsize))) {
|
||||
WARN("SUSPECT_CODE_INDENT",
|
||||
"suspect code indent for conditional statements ($indent, $sindent)\n" . $herecurr . "$stat_real\n");
|
||||
}
|
||||
|
|
@ -4140,7 +4292,7 @@ sub process {
|
|||
}
|
||||
|
||||
# check for function declarations without arguments like "int foo()"
|
||||
if ($line =~ /(\b$Type\s+$Ident)\s*\(\s*\)/) {
|
||||
if ($line =~ /(\b$Type\s*$Ident)\s*\(\s*\)/) {
|
||||
if (ERROR("FUNCTION_WITHOUT_ARGS",
|
||||
"Bad function definition - $1() should probably be $1(void)\n" . $herecurr) &&
|
||||
$fix) {
|
||||
|
|
@ -4251,15 +4403,6 @@ sub process {
|
|||
"Prefer [subsystem eg: netdev]_$level2([subsystem]dev, ... then dev_$level2(dev, ... then pr_$level(... to printk(KERN_$orig ...\n" . $herecurr);
|
||||
}
|
||||
|
||||
if ($line =~ /\bpr_warning\s*\(/) {
|
||||
if (WARN("PREFER_PR_LEVEL",
|
||||
"Prefer pr_warn(... to pr_warning(...\n" . $herecurr) &&
|
||||
$fix) {
|
||||
$fixed[$fixlinenr] =~
|
||||
s/\bpr_warning\b/pr_warn/;
|
||||
}
|
||||
}
|
||||
|
||||
if ($line =~ /\bdev_printk\s*\(\s*KERN_([A-Z]+)/) {
|
||||
my $orig = $1;
|
||||
my $level = lc($orig);
|
||||
|
|
@ -4277,6 +4420,17 @@ sub process {
|
|||
"ENOSYS means 'invalid syscall nr' and nothing else\n" . $herecurr);
|
||||
}
|
||||
|
||||
# ENOTSUPP is not a standard error code and should be avoided in new patches.
|
||||
# Folks usually mean EOPNOTSUPP (also called ENOTSUP), when they type ENOTSUPP.
|
||||
# Similarly to ENOSYS warning a small number of false positives is expected.
|
||||
if (!$file && $line =~ /\bENOTSUPP\b/) {
|
||||
if (WARN("ENOTSUPP",
|
||||
"ENOTSUPP is not a SUSV4 error code, prefer EOPNOTSUPP\n" . $herecurr) &&
|
||||
$fix) {
|
||||
$fixed[$fixlinenr] =~ s/\bENOTSUPP\b/EOPNOTSUPP/;
|
||||
}
|
||||
}
|
||||
|
||||
# function brace can't be on same line, except for #defines of do while,
|
||||
# or if closed on same line
|
||||
if ($perl_version_ok &&
|
||||
|
|
@ -4717,7 +4871,7 @@ sub process {
|
|||
($op eq '>' &&
|
||||
$ca =~ /<\S+\@\S+$/))
|
||||
{
|
||||
$ok = 1;
|
||||
$ok = 1;
|
||||
}
|
||||
|
||||
# for asm volatile statements
|
||||
|
|
@ -5044,15 +5198,37 @@ sub process {
|
|||
my ($s, $c) = ($stat, $cond);
|
||||
|
||||
if ($c =~ /\bif\s*\(.*[^<>!=]=[^=].*/s) {
|
||||
ERROR("ASSIGN_IN_IF",
|
||||
"do not use assignment in if condition\n" . $herecurr);
|
||||
if (ERROR("ASSIGN_IN_IF",
|
||||
"do not use assignment in if condition\n" . $herecurr) &&
|
||||
$fix && $perl_version_ok) {
|
||||
if ($rawline =~ /^\+(\s+)if\s*\(\s*(\!)?\s*\(\s*(($Lval)\s*=\s*$LvalOrFunc)\s*\)\s*(?:($Compare)\s*($FuncArg))?\s*\)\s*(\{)?\s*$/) {
|
||||
my $space = $1;
|
||||
my $not = $2;
|
||||
my $statement = $3;
|
||||
my $assigned = $4;
|
||||
my $test = $8;
|
||||
my $against = $9;
|
||||
my $brace = $15;
|
||||
fix_delete_line($fixlinenr, $rawline);
|
||||
fix_insert_line($fixlinenr, "$space$statement;");
|
||||
my $newline = "${space}if (";
|
||||
$newline .= '!' if defined($not);
|
||||
$newline .= '(' if (defined $not && defined($test) && defined($against));
|
||||
$newline .= "$assigned";
|
||||
$newline .= " $test $against" if (defined($test) && defined($against));
|
||||
$newline .= ')' if (defined $not && defined($test) && defined($against));
|
||||
$newline .= ')';
|
||||
$newline .= " {" if (defined($brace));
|
||||
fix_insert_line($fixlinenr + 1, $newline);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Find out what is on the end of the line after the
|
||||
# conditional.
|
||||
substr($s, 0, length($c), '');
|
||||
$s =~ s/\n.*//g;
|
||||
$s =~ s/$;//g; # Remove any comments
|
||||
$s =~ s/$;//g; # Remove any comments
|
||||
if (length($c) && $s !~ /^\s*{?\s*\\*\s*$/ &&
|
||||
$c !~ /}\s*while\s*/)
|
||||
{
|
||||
|
|
@ -5091,7 +5267,7 @@ sub process {
|
|||
# if and else should not have general statements after it
|
||||
if ($line =~ /^.\s*(?:}\s*)?else\b(.*)/) {
|
||||
my $s = $1;
|
||||
$s =~ s/$;//g; # Remove any comments
|
||||
$s =~ s/$;//g; # Remove any comments
|
||||
if ($s !~ /^\s*(?:\sif|(?:{|)\s*\\?\s*$)/) {
|
||||
ERROR("TRAILING_STATEMENTS",
|
||||
"trailing statements should be on next line\n" . $herecurr);
|
||||
|
|
@ -5168,8 +5344,9 @@ sub process {
|
|||
$var =~ /[A-Z][a-z]|[a-z][A-Z]/ &&
|
||||
#Ignore Page<foo> variants
|
||||
$var !~ /^(?:Clear|Set|TestClear|TestSet|)Page[A-Z]/ &&
|
||||
#Ignore SI style variants like nS, mV and dB (ie: max_uV, regulator_min_uA_show)
|
||||
$var !~ /^(?:[a-z_]*?)_?[a-z][A-Z](?:_[a-z_]+)?$/ &&
|
||||
#Ignore SI style variants like nS, mV and dB
|
||||
#(ie: max_uV, regulator_min_uA_show, RANGE_mA_VALUE)
|
||||
$var !~ /^(?:[a-z0-9_]*|[A-Z0-9_]*)?_?[a-z][A-Z](?:_[a-z0-9_]+|_[A-Z0-9_]+)?$/ &&
|
||||
#Ignore some three character SI units explicitly, like MiB and KHz
|
||||
$var !~ /^(?:[a-z_]*?)_?(?:[KMGT]iB|[KMGT]?Hz)(?:_[a-z_]+)?$/) {
|
||||
while ($var =~ m{($Ident)}g) {
|
||||
|
|
@ -5272,7 +5449,7 @@ sub process {
|
|||
# to gobble any hanging open-parens.
|
||||
$dstat =~ s/\(.+\\$/1/;
|
||||
|
||||
# Flatten any obvious string concatentation.
|
||||
# Flatten any obvious string concatenation.
|
||||
while ($dstat =~ s/($String)\s*$Ident/$1/ ||
|
||||
$dstat =~ s/$Ident\s*($String)/$1/)
|
||||
{
|
||||
|
|
@ -5951,8 +6128,7 @@ sub process {
|
|||
my $barriers = qr{
|
||||
mb|
|
||||
rmb|
|
||||
wmb|
|
||||
read_barrier_depends
|
||||
wmb
|
||||
}x;
|
||||
my $barrier_stems = qr{
|
||||
mb__before_atomic|
|
||||
|
|
@ -5993,10 +6169,12 @@ sub process {
|
|||
}
|
||||
}
|
||||
|
||||
# check for smp_read_barrier_depends and read_barrier_depends
|
||||
if (!$file && $line =~ /\b(smp_|)read_barrier_depends\s*\(/) {
|
||||
WARN("READ_BARRIER_DEPENDS",
|
||||
"$1read_barrier_depends should only be used in READ_ONCE or DEC Alpha code\n" . $herecurr);
|
||||
# check for data_race without a comment.
|
||||
if ($line =~ /\bdata_race\s*\(/) {
|
||||
if (!ctx_has_comment($first_line, $linenr)) {
|
||||
WARN("DATA_RACE",
|
||||
"data_race without comment\n" . $herecurr);
|
||||
}
|
||||
}
|
||||
|
||||
# check of hardware specific defines
|
||||
|
|
@ -6179,14 +6357,18 @@ sub process {
|
|||
for (my $count = $linenr; $count <= $lc; $count++) {
|
||||
my $specifier;
|
||||
my $extension;
|
||||
my $qualifier;
|
||||
my $bad_specifier = "";
|
||||
my $fmt = get_quoted_string($lines[$count - 1], raw_line($count, 0));
|
||||
$fmt =~ s/%%//g;
|
||||
|
||||
while ($fmt =~ /(\%[\*\d\.]*p(\w))/g) {
|
||||
while ($fmt =~ /(\%[\*\d\.]*p(\w)(\w*))/g) {
|
||||
$specifier = $1;
|
||||
$extension = $2;
|
||||
if ($extension !~ /[SsBKRraEhMmIiUDdgVCbGNOxt]/) {
|
||||
$qualifier = $3;
|
||||
if ($extension !~ /[SsBKRraEehMmIiUDdgVCbGNOxtf]/ ||
|
||||
($extension eq "f" &&
|
||||
defined $qualifier && $qualifier !~ /^w/)) {
|
||||
$bad_specifier = $specifier;
|
||||
last;
|
||||
}
|
||||
|
|
@ -6203,7 +6385,6 @@ sub process {
|
|||
my $ext_type = "Invalid";
|
||||
my $use = "";
|
||||
if ($bad_specifier =~ /p[Ff]/) {
|
||||
$ext_type = "Deprecated";
|
||||
$use = " - use %pS instead";
|
||||
$use =~ s/pS/ps/ if ($bad_specifier =~ /pf/);
|
||||
}
|
||||
|
|
@ -6367,8 +6548,7 @@ sub process {
|
|||
if (defined $cond) {
|
||||
substr($s, 0, length($cond), '');
|
||||
}
|
||||
if ($s =~ /^\s*;/ &&
|
||||
$function_name ne 'uninitialized_var')
|
||||
if ($s =~ /^\s*;/)
|
||||
{
|
||||
WARN("AVOID_EXTERNS",
|
||||
"externs should be avoided in .c files\n" . $herecurr);
|
||||
|
|
@ -6429,7 +6609,7 @@ sub process {
|
|||
|
||||
if (!grep(/$name/, @setup_docs)) {
|
||||
CHK("UNDOCUMENTED_SETUP",
|
||||
"__setup appears un-documented -- check Documentation/admin-guide/kernel-parameters.rst\n" . $herecurr);
|
||||
"__setup appears un-documented -- check Documentation/admin-guide/kernel-parameters.txt\n" . $herecurr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -6511,6 +6691,12 @@ sub process {
|
|||
}
|
||||
}
|
||||
|
||||
# check for IS_ENABLED() without CONFIG_<FOO> ($rawline for comments too)
|
||||
if ($rawline =~ /\bIS_ENABLED\s*\(\s*(\w+)\s*\)/ && $1 !~ /^CONFIG_/) {
|
||||
WARN("IS_ENABLED_CONFIG",
|
||||
"IS_ENABLED($1) is normally used as IS_ENABLED(CONFIG_$1)\n" . $herecurr);
|
||||
}
|
||||
|
||||
# check for #if defined CONFIG_<FOO> || defined CONFIG_<FOO>_MODULE
|
||||
if ($line =~ /^\+\s*#\s*if\s+defined(?:\s*\(?\s*|\s+)(CONFIG_[A-Z_]+)\s*\)?\s*\|\|\s*defined(?:\s*\(?\s*|\s+)\1_MODULE\s*\)?\s*$/) {
|
||||
my $config = $1;
|
||||
|
|
@ -6521,28 +6707,25 @@ sub process {
|
|||
}
|
||||
}
|
||||
|
||||
# check for case / default statements not preceded by break/fallthrough/switch
|
||||
if ($line =~ /^.\s*(?:case\s+(?:$Ident|$Constant)\s*|default):/) {
|
||||
my $has_break = 0;
|
||||
my $has_statement = 0;
|
||||
my $count = 0;
|
||||
my $prevline = $linenr;
|
||||
while ($prevline > 1 && ($file || $count < 3) && !$has_break) {
|
||||
$prevline--;
|
||||
my $rline = $rawlines[$prevline - 1];
|
||||
my $fline = $lines[$prevline - 1];
|
||||
last if ($fline =~ /^\@\@/);
|
||||
next if ($fline =~ /^\-/);
|
||||
next if ($fline =~ /^.(?:\s*(?:case\s+(?:$Ident|$Constant)[\s$;]*|default):[\s$;]*)*$/);
|
||||
$has_break = 1 if ($rline =~ /fall[\s_-]*(through|thru)/i);
|
||||
next if ($fline =~ /^.[\s$;]*$/);
|
||||
$has_statement = 1;
|
||||
$count++;
|
||||
$has_break = 1 if ($fline =~ /\bswitch\b|\b(?:break\s*;[\s$;]*$|exit\s*\(\b|return\b|goto\b|continue\b)/);
|
||||
}
|
||||
if (!$has_break && $has_statement) {
|
||||
WARN("MISSING_BREAK",
|
||||
"Possible switch case/default not preceded by break or fallthrough comment\n" . $herecurr);
|
||||
# check for /* fallthrough */ like comment, prefer fallthrough;
|
||||
my @fallthroughs = (
|
||||
'fallthrough',
|
||||
'@fallthrough@',
|
||||
'lint -fallthrough[ \t]*',
|
||||
'intentional(?:ly)?[ \t]*fall(?:(?:s | |-)[Tt]|t)hr(?:ough|u|ew)',
|
||||
'(?:else,?\s*)?FALL(?:S | |-)?THR(?:OUGH|U|EW)[ \t.!]*(?:-[^\n\r]*)?',
|
||||
'Fall(?:(?:s | |-)[Tt]|t)hr(?:ough|u|ew)[ \t.!]*(?:-[^\n\r]*)?',
|
||||
'fall(?:s | |-)?thr(?:ough|u|ew)[ \t.!]*(?:-[^\n\r]*)?',
|
||||
);
|
||||
if ($raw_comment ne '') {
|
||||
foreach my $ft (@fallthroughs) {
|
||||
if ($raw_comment =~ /$ft/) {
|
||||
my $msg_level = \&WARN;
|
||||
$msg_level = \&CHK if ($file);
|
||||
&{$msg_level}("PREFER_FALLTHROUGH",
|
||||
"Prefer 'fallthrough;' over fallthrough comment\n" . $herecurr);
|
||||
last;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -6645,7 +6828,8 @@ sub process {
|
|||
|
||||
# check for various structs that are normally const (ops, kgdb, device_tree)
|
||||
# and avoid what seem like struct definitions 'struct foo {'
|
||||
if ($line !~ /\bconst\b/ &&
|
||||
if (defined($const_structs) &&
|
||||
$line !~ /\bconst\b/ &&
|
||||
$line =~ /\bstruct\s+($const_structs)\b(?!\s*\{)/) {
|
||||
WARN("CONST_STRUCT",
|
||||
"struct $1 should normally be const\n" . $herecurr);
|
||||
|
|
|
|||
Loading…
Reference in a new issue