Lines Matching +full:- +full:s
2 # SPDX-License-Identifier: GPL-2.0
7 # (c) 2008-2010 Andy Whitcroft <apw@canonical.com>
8 # (c) 2010-2018 Joe Perches <joe@perches.com>
67 my $git_command ='export LANGUAGE=en_US.UTF-8; git';
78 -q, --quiet quiet
79 --no-tree run without a kernel tree
80 --no-signoff do not check for 'Signed-off-by' line
81 --patch treat FILE as patchfile (default)
82 --emacs emacs compile window format
83 --terse one line per report
84 --showfile emit diffed file position, not input file position
85 -g, --git treat FILE as a single commit or git revision range
93 <rev>-<count>
95 -f, --file treat FILE as regular source file
96 --subjective, --strict enable more subjective tests
97 --list-types list the possible message types
98 --types TYPE(,TYPE2...) show only these comma separated message types
99 --ignore TYPE(,TYPE2...) ignore various comma separated message types
100 --exclude DIR (--exclude DIR2...) exclude directories
101 --show-types show the specific message type in the output
102 --max-line-length=n set the maximum line length, (default $max_line_length)
104 requires --strict for use with --file
105 --min-conf-desc-length=n set the min description length, if shorter, warn
106 --tab-size=n set the number of spaces for tab (default $tabsize)
107 --root=PATH PATH to the kernel tree root
108 --no-summary suppress the per-file summary
109 --mailback only produce a report in case of warnings/errors
110 --summary-file include the filename in summary
111 --debug KEY=[0|1] turn on/off debugging of KEY, where KEY is one of
114 --test-only=WORD report only warnings/errors containing WORD
116 --fix EXPERIMENTAL - may create horrible results
117 If correctable single-line errors exist, create
118 "<inputfile>.EXPERIMENTAL-checkpatch-fixes"
121 --fix-inplace EXPERIMENTAL - may create horrible results
122 Is the same as --fix, but overwrites the input
123 file. It's your fault if there's no backup or git
124 --ignore-perl-version override checking of perl version. expect
126 --codespell Use the codespell dictionary for spelling/typos
128 --codespellfile Use this codespell dictionary
129 --typedefsfile Read additional types from this file
130 --color[=WHEN] Use colors 'always', 'never', or only when output
132 -h, --help, --version display this help and exit
134 When FILE is - read standard input.
160 for ($text =~ /(?:(?:\bCHK|\bWARN|\bERROR|&\{\$msg_level})\s*\(|\$msg_type\s*=)\s*"([^"]+)"/g) {
173 if (-f $conf) {
181 $line =~ s/\s*\n?$//g;
182 $line =~ s/^\s*//g;
183 $line =~ s/\s+/ /g;
185 next if ($line =~ m/^\s*#/);
186 next if ($line =~ m/^\s*$/);
198 # Perl's Getopt::Long allows options to take optional arguments after a space.
199 # Prevent --color by itself from consuming other arguments
201 if ($_ eq "--color" || $_ eq "-color") {
202 $_ = "--color=$color";
218 'ignore=s' => \@ignore,
219 'exclude=s' => \@exclude,
220 'types=s' => \@use,
221 'show-types!' => \$show_types,
222 'list-types!' => \$list_types,
223 'max-line-length=i' => \$max_line_length,
224 'min-conf-desc-length=i' => \$min_conf_desc_length,
225 'tab-size=i' => \$tabsize,
226 'root=s' => \$root,
229 'summary-file!' => \$summary_file,
231 'fix-inplace!' => \$fix_inplace,
232 'ignore-perl-version!' => \$ignore_perl_version,
233 'debug=s' => \%debug,
234 'test-only=s' => \$tst_only,
236 'codespellfile=s' => \$codespellfile,
237 'typedefsfile=s' => \$typedefsfile,
238 'color=s' => \$color,
239 'no-color' => \$color, #keep old behaviors of -nocolor
240 'nocolor' => \$color, #keep old behaviors of -nocolor
252 die "$P: --git cannot be used with --file or --fix\n" if ($git && ($file || $fix));
263 #if no filenames are given, push '-' to read patch from stdin
265 push(@ARGV, '-');
275 $color = (-t STDOUT);
280 # skip TAB size 1 to avoid additional checks on $tabsize - 1
288 $word =~ s/\s*\n?$//g;
289 $word =~ s/^\s*//g;
290 $word =~ s/\s+/ /g;
291 $word =~ tr/[a-z]/[A-Z]/;
293 next if ($word =~ m/^\s*#/);
294 next if ($word =~ m/^\s*$/);
296 $hashRef->{$word}++;
335 die "$P: $root: --root does not point at a valid tree\n";
347 print "Must be run from the top-level dir. of a kernel tree\n";
355 [A-Za-z_][A-Za-z\d_]*
356 (?:\s*\#\#\s*[A-Za-z_][A-Za-z\d_]*)*
409 our $Member = qr{->$Ident|\.$Ident|\[[^]]*\]};
414 our $Hex = qr{(?i)0x[0-9a-f]+$Int_type?};
415 our $Int = qr{[0-9]+$Int_type?};
416 our $Octal = qr{0[0-7]+$Int_type?};
418 our $Float_hex = qr{(?i)0x[0-9a-f]+p-?[0-9]+[fl]?};
419 our $Float_dec = qr{(?i)(?:[0-9]+\.[0-9]*|[0-9]*\.[0-9]+)(?:e-?[0-9]+)?[fl]?};
420 our $Float_int = qr{(?i)[0-9]+e-?[0-9]+[fl]?};
423 our $Assignment = qr{\*\=|/=|%=|\+=|-=|<<=|>>=|&=|\^=|\|=|=};
424 our $Compare = qr{<=|>=|==|!=|<|(?<!-)>};
425 our $Arithmetic = qr{\+|-|\*|\/|%};
428 =>|->|<<|>>|<|>|!|~|
429 &&|\|\||,|\^|\+\+|--|&|\||$Arithmetic
444 [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte
445 | \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs
446 | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte
447 | \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates
448 | \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3
449 | [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15
450 | \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16
454 [\x09\x0A\x0D\x20-\x7E] # ASCII
464 (?:__)?(?:u|s|be|le)(?:8|16|32|64)|
477 …(?:[a-z0-9]+_){1,2}(?:printk|emerg|alert|crit|err|warning|warn|notice|info|debug|dbg|vdbg|devel|co…
481 MODULE_[A-Z_]+|
496 Signed-off-by:|
497 Co-authored-by:|
498 Co-developed-by:|
499 Acked-by:|
500 Tested-by:|
501 Reviewed-by:|
502 Reported-by:|
503 Suggested-by:|
509 qr{char\s+(?:un)?signed},
510 qr{int\s+(?:(?:un)?signed\s+)?short\s},
511 qr{int\s+short(?:\s+(?:un)?signed)},
512 qr{short\s+int(?:\s+(?:un)?signed)},
513 qr{(?:un)?signed\s+int\s+short},
514 qr{short\s+(?:un)?signed},
515 qr{long\s+int\s+(?:un)?signed},
516 qr{int\s+long\s+(?:un)?signed},
517 qr{long\s+(?:un)?signed\s+int},
518 qr{int\s+(?:un)?signed\s+long},
519 qr{int\s+(?:un)?signed},
520 qr{int\s+long\s+long\s+(?:un)?signed},
521 qr{long\s+long\s+int\s+(?:un)?signed},
522 qr{long\s+long\s+(?:un)?signed\s+int},
523 qr{long\s+long\s+(?:un)?signed},
524 qr{long\s+(?:un)?signed},
529 qr{(?:(?:un)?signed\s+)?char},
530 qr{(?:(?:un)?signed\s+)?short\s+int},
531 qr{(?:(?:un)?signed\s+)?short},
532 qr{(?:(?:un)?signed\s+)?int},
533 qr{(?:(?:un)?signed\s+)?long\s+int},
534 qr{(?:(?:un)?signed\s+)?long\s+long\s+int},
535 qr{(?:(?:un)?signed\s+)?long\s+long},
536 qr{(?:(?:un)?signed\s+)?long},
541 qr{struct\s+$Ident},
542 qr{union\s+$Ident},
543 qr{enum\s+$Ident},
551 long\s+long\s+int\s+(?:un)?signed|
552 long\s+long\s+(?:un)?signed\s+int|
553 long\s+long\s+(?:un)?signed|
554 (?:(?:un)?signed\s+)?long\s+long\s+int|
555 (?:(?:un)?signed\s+)?long\s+long|
556 int\s+long\s+long\s+(?:un)?signed|
557 int\s+(?:(?:un)?signed\s+)?long\s+long|
559 long\s+int\s+(?:un)?signed|
560 long\s+(?:un)?signed\s+int|
561 long\s+(?:un)?signed|
562 (?:(?:un)?signed\s+)?long\s+int|
563 (?:(?:un)?signed\s+)?long|
564 int\s+long\s+(?:un)?signed|
565 int\s+(?:(?:un)?signed\s+)?long|
567 int\s+(?:un)?signed|
568 (?:(?:un)?signed\s+)?int
574 qr{struct\s+$InitAttribute\s+$Ident},
575 qr{union\s+$InitAttribute\s+$Ident},
590 ["IIO_DEV_ATTR_[A-Z_]+", 1],
610 my $word_pattern = '\b[A-Z]?[a-z]{2,}\b';
616 $mode_perms_search .= $entry->[0];
646 0[0-7][0-7][2367]
677 (?:\s*\|\s*${single_mode_perms_string_search})*
683 return trim($string) if ($string =~ /^\s*0[0-7]{3,3}\s*$/);
690 while ($string =~ /\b(($single_mode_perms_string_search)\b(?:\s*\|\s*)?\s*)/g) {
694 last if ($lastpos > 0 && ($curpos - length($omatch) != $lastpos));
697 $val .= '\s*\|\s*' if ($val ne "");
701 $oval =~ s/^\s*\|\s*//;
702 $oval =~ s/\s*\|\s*$//;
722 $line =~ s/\s*\n?$//g;
723 $line =~ s/^\s*//g;
725 next if ($line =~ m/^\s*#/);
726 next if ($line =~ m/^\s*$/);
734 warn "No typos will be found - file '$spelling_file': $!\n";
742 $line =~ s/\s*\n?$//g;
743 $line =~ s/^\s*//g;
745 next if ($line =~ m/^\s*#/);
746 next if ($line =~ m/^\s*$/);
749 $line =~ s/,.*$//;
751 my ($suspect, $fix) = split(/->/, $line);
757 warn "No codespell typos will be found - file '$codespellfile': $!\n";
770 $line =~ s/\s*\n?$//g;
771 $line =~ s/^\s*//g;
773 next if ($line =~ m/^\s*#/);
774 next if ($line =~ m/^\s*$/);
775 if ($line =~ /\s/) {
776 print("$file: '$line' invalid - ignored\n");
793 # or warn "No structs that should be const will be found - file '$conststructsfile': $!\n";
799 or warn "No additional types will be considered - file '$typedefsfile': $!\n";
814 (?:$Modifier\s+|const\s+)*
816 (?:typeof|__typeof__)\s*\([^\)]*\)|
820 (?:\s+$Modifier|\s+const)*
823 (?:$Modifier\s+|const\s+)*
827 (?:\s+$Modifier|\s+const)*
830 (?:$Modifier\s+|const\s+)*
832 (?:typeof|__typeof__)\s*\([^\)]*\)|
836 (?:\s+$Modifier|\s+const)*
840 (?:(?:\s|\*|\[\])+\s*const|(?:\s|\*\s*(?:const\s*)?|\[\])+|(?:\s*\[\s*\])+){0,4}
841 (?:\s+$Inline|\s+$Modifier)*
845 (?:(?:\s|\*|\[\])+\s*const|(?:\s|\*\s*(?:const\s*)?|\[\])+|(?:\s*\[\s*\])+){0,4}
846 (?:\s+$Inline|\s+$Modifier)*
848 $Declare = qr{(?:$Storage\s+(?:$Inline\s+)?)?$Type};
849 $DeclareMisordered = qr{(?:$Storage\s+(?:$Inline\s+)?)?$TypeMisordered};
853 our $Typecast = qr{\s*(\(\s*$NonptrType\s*\)){0,1}\s*};
859 our $balanced_parens = qr/(\((?:[^\(\)]++|(?-1))*\))/;
860 our $LvalOrFunc = qr{((?:[\&\*]\s*)?$Lval)\s*($balanced_parens{0,1})\s*};
864 (?:$Storage\s+)?(?:[A-Z_][A-Z0-9]*_){0,2}(?:DEFINE|DECLARE)(?:_[A-Z0-9]+){1,6}\s*\(|
865 (?:$Storage\s+)?[HLP]?LIST_HEAD\s*\(|
866 (?:SKCIPHER_REQUEST|SHASH_DESC|AHASH_REQUEST)_ON_STACK\s*\(
873 while ($string =~ /^\s*\(.*\)\s*$/) {
874 $string =~ s@^\s*\(\s*@@;
875 $string =~ s@\s*\)\s*$@@;
878 $string =~ s@\s+@ @g;
886 return if (!(-f $file));
898 next if ($line !~ /(?:[A-Z][a-z]|[a-z][A-Z])/);
899 if ($line =~ /^[ \t]*(?:#[ \t]*define|typedef\s+$Type)\s+(\w*(?:[A-Z][a-z]|[a-z][A-Z])\w*)/) {
901 } elsif ($line =~ /^\s*$Declare\s+(\w*(?:[A-Z][a-z]|[a-z][A-Z])\w*)\s*[\(\[,;]/) {
903 } elsif ($line =~ /^\s*(?:union|struct|enum)\s+(\w*(?:[A-Z][a-z]|[a-z][A-Z])\w*)\s*[;\{]/) {
914 return 0 if (!$tree || !(-e "$root/scripts/get_maintainer.pl"));
917 …s{$filename} = `perl $root/scripts/get_maintainer.pl --status --nom --nol --nogit --nogit-fallback…
926 …return 1 if (!$tree || which("python") eq "" || !(-e "$root/scripts/spdxcheck.py") || !(-e "$root/…
929 my $status = `cd "$root_path"; echo "$license" | python scripts/spdxcheck.py -`;
944 if (-e ".git") {
945 …my $git_last_include_commit = `${git_command} log --no-merges --pretty=format:"%h%n" -1 -- include…
947 $camelcase_cache = ".checkpatch-camelcase.git.$git_last_include_commit";
950 $files = `find $root/include -name "*.h"`;
957 $camelcase_cache = ".checkpatch-camelcase.date.$last_mod_date";
960 if ($camelcase_cache ne "" && -f $camelcase_cache) {
972 if (-e ".git") {
973 $files = `${git_command} ls-files "include/*.h"`;
982 unlink glob ".checkpatch-camelcase.*";
995 return ($id, $desc) if ((which("git") eq "") || !(-e ".git"));
997 my $output = `${git_command} log --no-color --format='%H %s' -1 $commit 2>&1`;
998 $output =~ s/^\s*//gm;
1005 # all matching commit ids, but it's very slow...
1008 # git rev-list --remotes | grep -i "^$1" |
1010 # git log --format='%H %s' -1 $line |
1011 # echo "commit $(cut -c 1-12,41-)"
1030 my $fixlinenr = -1;
1033 # For example, HEAD-3 means we need check 'HEAD, HEAD~1, HEAD~2'.
1034 die "$P: No git repository found\n" if ($git && !-e ".git");
1040 if ($commit_expr =~ m/^(.*)-(\d+)$/) {
1041 $git_range = "-$2 $1";
1045 $git_range = "-1 $commit_expr";
1047 my $lines = `${git_command} log --no-color --no-merges --pretty=format:'%H %s' $git_range`;
1049 $line =~ /^([0-9a-fA-F]{40,40}) (.*)$/;
1066 open($FILE, '-|', "git format-patch -M --stdout -1 $filename") ||
1067 die "$P: $filename: git format-patch failed - $!\n";
1069 open($FILE, '-|', "diff -u /dev/null $filename") ||
1070 die "$P: $filename: diff failed - $!\n";
1071 } elsif ($filename eq '-') {
1075 die "$P: $filename: open failed - $!\n";
1077 if ($filename eq '-') {
1087 $vname = qq("$1") if ($filename eq '-' && $_ =~ m/^Subject:\s+(.+)/i);
1092 print '-' x length($vname) . "\n";
1094 print '-' x length($vname) . "\n";
1105 $fixlinenr = -1;
1143 if (! -e $root . '/' . $check) {
1157 if ($formatted_email =~ /^(.*)<(\S+\@\S+)>(.*)$/) {
1161 } elsif ($formatted_email =~ /^\s*<(\S+\@\S+)>(.*)$/) {
1164 } elsif ($formatted_email =~ /(\S+\@\S+)(.*)$/) {
1167 $formatted_email =~ s/\Q$address\E.*$//;
1170 $name =~ s/^\"|\"$//g;
1171 # If there's a name left after stripping spaces and
1185 $name =~ s/^\"|\"$//g;
1187 $address =~ s/^\<|\>$//g;
1189 if ($name =~ /[^\w \-]/i) { ##has "must quote" chars
1190 $name =~ s/(?<!\\)"/\\"/g; ##escape quotes
1203 $name =~ s/^\"|\"$//g;
1206 if ($name =~ /[^\w \-]/i) { ##has "must quote" chars
1207 $name =~ s/(?<!\\)"/\\"/g; ##escape quotes
1224 if (-e "$path/$bin") {
1236 if (-e "$path/$conf") {
1273 $line =~ s/^.//;
1277 my ($white) = ($line =~ /^(\s*)/);
1368 if ($res =~ /^.\s*\#\s*include\s+\<(.*)\>/) {
1370 $res =~ s@\<.*\>@<$clean>@;
1373 } elsif ($res =~ /^.\s*\#\s*(?:error|warning)\s+(.*)\b/) {
1375 $res =~ s@(\#\s*(?:error|warning)\s+).*@$1$clean@;
1380 $res =~ s/\Q$match\E/"$;" x length($match)/e;
1391 return substr($rawline, $-[0], $+[0] - $-[0]);
1396 my $line = $linenr - 1;
1399 my $coff = $off - 1;
1413 @stack = (['', 0]) if ($#stack == -1);
1421 next if ($lines[$line] =~ /^-/);
1422 $remain--;
1434 if ($level == 0 && substr($blk, $off) =~ /^.\s*#\s*define/) {
1446 if ($remainder =~ /^#\s*(?:ifndef|ifdef|if)\s/) {
1448 } elsif ($remainder =~ /^#\s*(?:else|elif)\b/) {
1449 ($type, $level) = @{$stack[$#stack - 1]};
1450 } elsif ($remainder =~ /^#\s*endif\b/) {
1462 (!defined($p) || $p =~ /(?:\s|\}|\+)/) &&
1463 $remainder =~ /^(else)(?:\s|{)/ &&
1464 $remainder !~ /^else\s+if\b/) {
1465 $coff = $off + length($1) - 1;
1468 #warn "[" . substr($blk, $soff, $coff - $soff + 1) . "]\n";
1476 $level--;
1490 $level--;
1502 $level--;
1513 $remain--;
1516 my $statement = substr($blk, $soff, $off - $soff + 1);
1517 my $condition = substr($blk, $soff, $coff - $soff + 1);
1525 $line, $remain + 1, $off - $loff + 1, $level);
1532 $stmt =~ s/(^|\n)./$1/g;
1533 $stmt =~ s/^\s*//;
1534 $stmt =~ s/\s*$//;
1552 $stmt =~ s/(^|\n)./$1/g;
1553 $stmt =~ s/^\s*{//;
1554 $stmt =~ s/}\s*$//;
1555 $stmt =~ s/^\s*//;
1556 $stmt =~ s/\s*$//;
1580 #print "F: c<$condition> s<$statement> remain<$remain>\n";
1582 if (!($remain > 0 && $condition =~ /^\s*(?:\n[+-])?\s*(?:if|else|do)\b/s)) {
1591 #print "C: c<$condition> s<$statement> remain<$remain>\n";
1592 last if (!($remain > 0 && $condition =~ /^(?:\s*\n[+-])*\s*(?:else|do)\b/s));
1603 my $start = $linenr - 1;
1612 next if ($rawlines[$line] =~ /^-/);
1613 $remain--;
1618 if ($lines[$line] =~ /^.\s*#\s*(?:ifndef|ifdef|if)\s/) {
1620 } elsif ($lines[$line] =~ /^.\s*#\s*(?:else|elif)\b/) {
1621 $level = $stack[$#stack - 1];
1622 } elsif ($lines[$line] =~ /^.\s*#\s*endif\b/) {
1629 $off--;
1634 $level--;
1683 my ($current_comment) = ($rawlines[$end_line - 1] =~ m@^\+.*(//.*$)@);
1685 ($current_comment) = ($rawlines[$end_line - 2] =~ m@^[\+ ].*(//.*$)@);
1691 ($current_comment) = ($rawlines[$end_line - 1] =~ m@.*(/\*.*\*/)\s*(?:\\\s*)?$@);
1699 my $line = $rawlines[$linenr - 1];
1701 if ($linenr == $first_line and $line =~ m@^.\s*\*@) {
1723 ##print "LINE: $rawlines[$end_line - 1 ]\n";
1732 my $offset = $linenr - 1;
1738 next if (defined($line) && $line =~ /^-/);
1739 $cnt--;
1779 $res =~ s/$/\$/;
1809 if ($cur =~ /^(\s+)/o) {
1816 } elsif ($cur =~ /^(\(\s*$Type\s*)\)/ && $av_pending eq '_') {
1821 } elsif ($cur =~ /^($Type)\s*(?:$Ident|,|\)|\(|\s*$)/) {
1825 } elsif ($cur =~ /^($Modifier)\s*/) {
1829 } elsif ($cur =~ /^(\#\s*define\s*$Ident)(\(?)/o) {
1838 } elsif ($cur =~ /^(\#\s*(?:undef\s*$Ident|include\b))/o) {
1843 } elsif ($cur =~ /^(\#\s*(?:ifdef|ifndef|if))/o) {
1851 } elsif ($cur =~ /^(\#\s*(?:else|elif))/o) {
1859 } elsif ($cur =~ /^(\#\s*(?:endif))/o) {
1873 } elsif ($cur =~ /^(__attribute__)\s*\(?/o) {
1878 } elsif ($cur =~ /^(sizeof)\s*(\()?/o) {
1909 print "PAREN('$1') -> $type\n"
1915 } elsif ($cur =~ /^($Ident)\s*\(/o) {
1920 } elsif ($cur =~ /^($Ident\s*):(?:\s*\d+\s*(,|=|;))?/) {
1965 } elsif ($cur =~ /^(-(?![->])|\+(?!\+)|\*|\&\&|\&)/o) {
1980 if ($1 ne '++' && $1 ne '--') {
2003 DEFINE_\S+
2014 )(?:\s|$)|
2020 $possible =~ s/\s*$Storage\s*//g;
2021 $possible =~ s/\s*$Sparse\s*//g;
2022 if ($possible =~ /^\s*$/) {
2024 } elsif ($possible =~ /\s/) {
2025 $possible =~ s/\s*$Type\s*//g;
2048 $type =~ tr/[a-z]/[A-Z]/;
2081 my @lines = split("\n", $output, -1);
2099 if ($$lineRef =~ /^\@\@ -\d+,\d+ \+(\d+),(\d+) \@\@/) {
2104 $$lineRef =~ s/\+$o,$l \@\@/\+$no,$nl \@\@/;
2128 if ($line =~ /^(?:\+\+\+|\-\-\-)\s+\S+/) { #new filename
2130 } elsif ($line =~ /^\@\@ -\d+,\d+ \+\d+,\d+ \@\@/) { #new hunk
2138 fixup_current_range(\$lines[$range_last_linenr], $delta_offset--, -1);
2218 while ($file =~ s@^[^/]*/@@) {
2219 if (-f "$root/$file") {
2224 if (! -f _) {
2230 substr($prefix, -length($file)) = '';
2242 $string =~ s/^\s+|\s+$//g;
2250 $string =~ s/^\s+//;
2258 $string =~ s/\s+$//;
2266 $string =~ s/$find/$replace/g;
2275 my $max_spaces_before_tab = $source_indent - 1;
2279 1 while $leading =~ s@^([\t]*)$spaces_to_tab@$1\t@g;
2281 1 while $leading =~ s@^([\t]*)( {1,$max_spaces_before_tab})\t@$1\t@g;
2297 return -1;
2305 $pos += length($1) - 1;
2308 } elsif (index($string, '(') == -1) {
2335 my $is_binding_patch = -1;
2338 my $has_patch_separator = 0; #Found a --- line
2348 my $last_coalesced_string_linenr = -1;
2361 my $context_function; #undef'd unless there's a known function
2377 # Pre-scan the patch sanitizing the lines.
2378 # Pre-scan the patch looking for any __setup documentation.
2395 if ($rawline=~/^\+\+\+\s+(\S+)/) {
2397 if ($1 =~ m@Documentation/admin-guide/kernel-parameters.txt$@) {
2402 if ($rawline =~ /^\@\@ -\d+(?:,\d+)? \+(\d+)(,(\d+))? \@\@/) {
2403 $realline=$1-1;
2418 next if (defined $rawlines[$ln - 1] &&
2419 $rawlines[$ln - 1] =~ /^-/);
2420 $cnt--;
2421 #print "RAW<$rawlines[$ln - 1]>\n";
2422 last if (!defined $rawlines[$ln - 1]);
2423 if ($rawlines[$ln - 1] =~ m@(/\*|\*/)@ &&
2424 $rawlines[$ln - 1] !~ m@"[^"]*(?:/\*|\*/)[^"]*"@) {
2437 $rawlines[$linenr] =~ m@^.\s*(?:\*\*+| \*)(?:\s|$)@)
2447 # simplify matching -- only bother with positive lines.
2453 $realcnt-- if ($line =~ /^(?:\+| |$)/);
2459 #print "-->$line\n";
2470 $fixlinenr = -1;
2475 $sline =~ s/$;/ /g; #with comments as spaces
2477 my $rawline = $rawlines[$linenr - 1];
2479 # check if it's a mode change, rename or start of a patch
2481 ($line =~ /^ mode change [0-7]+ => [0-7]+ \S+\s*$/ ||
2482 ($line =~ /^rename (?:from|to) \S+\s*$/ ||
2483 $line =~ /^diff --git a\/[\w\/\.\_\-]+ b\/\S+\s*$/))) {
2489 $line =~ /^\@\@ -\d+(?:,\d+)? \+(\d+)(,(\d+))? \@\@(.*)/) {
2493 $realline=$1-1;
2506 if ($context =~ /\b(\w+)\s*\(/) {
2518 $realcnt-- if ($realcnt != 0);
2531 $realcnt--;
2541 if ($line =~ /^diff --git.*?(\S+)$/) {
2543 $realfile =~ s@^([^/]*)/@@ if (!$file);
2546 } elsif ($line =~ /^\+\+\+\s+(\S+)/) {
2548 $realfile =~ s@^([^/]*)/@@ if (!$file);
2553 -e "$root/$p1_prefix") {
2555 "patch prefix '$p1_prefix' exists, appears to be a -p0 patch\n");
2560 …"do not modify files in include/asm, change architecture specific files in include/asm-<architectu…
2600 $is_binding_patch = () = $realfile =~ m@^(?:Documentation/devicetree/|include/dt-bindings/)@;
2602 if (($last_binding_patch != -1) &&
2605 …udes should be a separate patch. See: Documentation/devicetree/bindings/submitting-patches.rst\n");
2623 if ($line !~ /^\s*$/) {
2628 "Missing commit description - Add an appropriate one\n");
2634 (($line =~ m@^\s+diff\b.*a/[\w/]+@ &&
2635 $line =~ m@^\s+diff\b.*a/([\w/]+)\s+b/$1\b@) ||
2636 $line =~ m@^\s*(?:\-\-\-\s+a/|\+\+\+\s+b/)@ ||
2637 $line =~ m/^\s*\@\@ \-\d+,\d+ \+\d+,\d+ \@\@/)) {
2639 "Avoid using diff content in the commit message - patch(1) might not work\n" . $herecurr);
2654 if (decode("MIME-Header", $line) =~ /^From:\s*(.*)/) {
2656 $author = encode("utf8", $author) if ($line =~ /=\?utf-8\?/i);
2657 $author =~ s/"//g;
2661 if ($line =~ /^\s*signed-off-by:/i) {
2666 $l =~ s/"//g;
2667 if ($l =~ /^\s*signed-off-by:\s*\Q$author\E/i) {
2674 if ($line =~ /^---$/) {
2679 # Check if CODEOWNERS is being updated. If so, there's probably no need to
2681 if ($line =~ /^\s*CODEOWNERS\s*\|/) {
2687 $line =~ /^(\s*)([a-z0-9_-]+by:|$signature_tags)(\s*)(.*)/i) {
2696 "Non-standard signature: $sign_off\n" . $herecurr);
2706 if ($sign_off =~ /-by:$/i && $sign_off ne $ucfirst_sign_off) {
2731 $dequoted =~ s/^"//;
2732 $dequoted =~ s/" </ </;
2745 $sig_nospace =~ s/\s//g;
2754 # Check Co-developed-by: immediately followed by Signed-off-by: with same name and email
2755 if ($sign_off =~ /^co-developed-by:$/i) {
2758 …"Co-developed-by: should not be used to attribute nominal patch author '$author'\n" . "$here\n" . …
2762 … "Co-developed-by: must be immediately followed by Signed-off-by:\n" . "$here\n" . $rawline);
2763 } elsif ($rawlines[$linenr] !~ /^\s*signed-off-by:\s*(.*)/i) {
2765 …"Co-developed-by: must be immediately followed by Signed-off-by:\n" . "$here\n" . $rawline . "\n" …
2768 …"Co-developed-by and Signed-off-by: name/email do not match \n" . "$here\n" . $rawline . "\n" .$ra…
2780 # Check for Gerrit Change-Ids not in any patch context
2781 if ($realfile eq '' && !$has_patch_separator && $line =~ /^\s*change-id:/i) {
2783 "Remove Gerrit Change-Id's before submitting upstream\n" . $herecurr);
2788 ($line =~ /^\s*(?:WARNING:|BUG:)/ ||
2789 $line =~ /^\s*\[\s*\d+\.\d{6,6}\s*\]/ ||
2791 $line =~ /^\s*\[\<[0-9a-fA-F]{8,}\>\]/) ||
2792 $line =~ /^(?:\s+\w+:\s+[0-9a-fA-F]+){3,3}/ ||
2793 $line =~ /^\s*\#\d+\s*\[[0-9a-fA-F]+\]\s*\w+ at [0-9a-fA-F]+/) {
2801 !($line =~ /^\s*[a-zA-Z0-9_\/\.]+\s+\|\s+\d+/ ||
2803 $line =~ /^\s*(?:[\w\.\-]+\/)++[\w\.\-]+:/ ||
2805 $line =~ /^\s*(?:Fixes:|Link:)/i ||
2815 $line =~ /^\s*$/) {
2821 $line !~ /^\s*(?:Link|Patchwork|http|https|BugLink|base-commit):/i &&
2822 $line !~ /^This reverts commit [0-9a-f]{7,40}/ &&
2823 ($line =~ /\bcommit\s+[0-9a-f]{5,}\b/i ||
2824 ($line =~ /(?:\s|^)[0-9a-f]{12,40}(?:[\s"'\(\[]|$)/i &&
2825 $line !~ /[\<\[][0-9a-f]{12,40}[\>\]]/i &&
2826 $line !~ /\bfixes:\s*[0-9a-f]{12,40}/i))) {
2839 if ($line =~ /\b(c)ommit\s+([0-9a-f]{5,})\b/i) {
2842 } elsif ($line =~ /\b([0-9a-f]{12,40})\b/i) {
2846 $short = 0 if ($line =~ /\bcommit\s+[0-9a-f]{12,40}/i);
2847 $long = 1 if ($line =~ /\bcommit\s+[0-9a-f]{41,}/i);
2848 $space = 0 if ($line =~ /\bcommit [0-9a-f]/i);
2849 $case = 0 if ($line =~ /\b[Cc]ommit\s+[0-9a-f]{5,40}[^A-F]/);
2850 if ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("([^"]+)"\)/i) {
2853 } elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s*$/i &&
2855 $rawlines[$linenr] =~ /^\s*\("([^"]+)"\)/) {
2858 } elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("[^"]+$/i &&
2860 $rawlines[$linenr] =~ /^\s*[^"]+"\)/) {
2861 $line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("([^"]+)$/i;
2863 $rawlines[$linenr] =~ /^\s*([^"]+)"\)/;
2874 …it commit description style 'commit <12+ chars of sha1> (\"<title line>\")' - ie: '${init_char}omm…
2880 ($line =~ /^(?:new|deleted) file mode\s*\d+\s*$/ ||
2881 $line =~ /^rename (?:from|to) [\w\/\.\-]+\s*$/ ||
2882 ($line =~ /\{\s*([\w\/\.\-]*)\s*\=\>\s*([\w\/\.\-]*)\s*\}/ &&
2887 "added, moved or deleted file(s), does CODEOWNERS need updating?\n" . $herecurr);
2892 ($line =~ /^new file mode\s*\d+\s*$/) &&
2895 … "DT bindings should be in DT schema format. See: Documentation/devicetree/writing-schema.rst\n");
2899 if ($realcnt != 0 && $line !~ m{^(?:\+|-| |\\ No newline|$)}) {
2905 # UTF-8 regex found at http://www.w3.org/International/questions/qa-forms-utf-8.en.php
2915 "Invalid UTF-8, patch and commit message should be encoded in UTF-8\n" . $hereptr);
2918 # Check if it's the start of a commit log
2921 !($rawline =~ /^\s+(?:\S|$)/ ||
2922 $rawline =~ /^(?:commit\b|from\b|[\w-]+:)/i)) {
2928 # Check if there is UTF-8 in a commit log when a mail header has explicitly
2931 $rawline =~ /^Content-Type:.+charset="(.+)".*$/ &&
2932 $1 !~ /utf-8/i) {
2939 "8-bit UTF-8 used in possible commit log\n" . $herecurr);
2944 while ($line =~ m{(?:^|\s)(/\S*)}g) {
2960 while ($rawline =~ /(?:^|[^a-z@])($misspellings)(?:\b|$|[^a-z@])/gi) {
2963 $typo_fix = ucfirst($typo_fix) if ($typo =~ /^[A-Z]/);
2964 $typo_fix = uc($typo_fix) if ($typo =~ /^[A-Z]+$/);
2968 "'$typo' may be misspelled - perhaps '$typo_fix'?\n" . $herecurr) &&
2970 $fixed[$fixlinenr] =~ s/(^|[^A-Za-z@])($typo)($|[^A-Za-z@])/$1$typo_fix$3/;
2976 if ($in_commit_log && $line =~ /(^fixes:|\bcommit)\s+([0-9a-f]{6,40})\b/i) {
2986 # ignore non-hunk lines and lines being removed
2987 next if (!$hunk_line || $line =~ /^-/);
2995 $fixed[$fixlinenr] =~ s/[\s\015]+$//;
2997 } elsif ($rawline =~ /^\+.*\S\s+$/ || $rawline =~ /^\+\s+$/) {
3002 $fixed[$fixlinenr] =~ s/\s+$//;
3010 $rawline =~ /\b675\s+Mass\s+Ave/i ||
3011 $rawline =~ /\b59\s+Temple\s+Pl/i ||
3012 $rawline =~ /\b51\s+Franklin\s+St/i) {
3017 …"Do not include the paragraph about writing to the Free Software Foundation's mailing address from…
3026 # (\b) rather than a whitespace character (\s)
3027 $line =~ /^\+\s*(?:config|menuconfig|choice)\b/) {
3034 for (; $cnt > 0 && defined $lines[$ln - 1]; $ln++) {
3035 $f = $lines[$ln - 1];
3036 $cnt-- if ($lines[$ln - 1] !~ /^-/);
3037 $is_end = $lines[$ln - 1] =~ /^\+/;
3039 next if ($f =~ /^-/);
3042 if ($lines[$ln - 1] =~ /^\+\s*(?:bool|tristate|prompt)\s*["']/) {
3044 } elsif ($lines[$ln - 1] =~ /^\+\s*(?:---)?help(?:---)?$/) {
3045 $length = -1;
3048 $f =~ s/^.//;
3049 $f =~ s/#.*//;
3050 $f =~ s/^\s+//;
3057 if ($f =~ /^\s*(?:config|menuconfig|choice|endchoice|
3074 if ($rawline =~ /^\+[A-Z]:/ &&
3075 $rawline !~ /^\+[A-Z]:\t\S/) {
3079 $fixed[$fixlinenr] =~ s/^(\+[A-Z]):\s*/$1:\t/;
3084 if ($rawline =~ /^\+[A-Z]:/ &&
3085 $prevrawline =~ /^[\+ ][A-Z]:/) {
3086 $rawline =~ /^\+([A-Z]):\s*(.*)/;
3089 $prevrawline =~ /^[\+ ]([A-Z]):\s*(.*)/;
3100 "Misordered MAINTAINERS entry - list '$cur:' before '$prev:'\n" . $hereprev);
3105 "Misordered MAINTAINERS entry - list file patterns in alphabetic order\n" . $hereprev);
3113 $line =~ /^\+\s*\bboolean\b/) {
3119 ($line =~ /\+(EXTRA_[A-Z]+FLAGS).*/)) {
3122 'EXTRA_AFLAGS' => 'asflags-y',
3123 'EXTRA_CFLAGS' => 'ccflags-y',
3124 'EXTRA_CPPFLAGS' => 'cppflags-y',
3125 'EXTRA_LDFLAGS' => 'ldflags-y',
3129 … of $flag is deprecated, please use \`$replacement->{$flag} instead.\n" . $herecurr) if ($replacem…
3140 (($realfile =~ /\.dtsi?$/ && $line =~ /^\+\s*compatible\s*=\s*\"/) ||
3141 ($realfile =~ /\.[ch]$/ && $line =~ /^\+.*\.compatible\s*=\s*\"/))) {
3143 my @compats = $rawline =~ /\"([a-zA-Z0-9\-\,\.\+_]+)\"/g;
3146 my $vp_file = $dt_path . "vendor-prefixes.txt";
3150 $compat2 =~ s/\,[a-zA-Z0-9]*\-/\,<\.\*>\-/;
3152 $compat3 =~ s/\,([a-z]*)[0-9]*\-/\,$1<\.\*>\-/;
3153 `grep -Erq "$compat|$compat2|$compat3" $dt_path`;
3156 "DT compatible string \"$compat\" appears un-documented -- check $dt_path\n" . $herecurr);
3159 next if $compat !~ /^([a-zA-Z0-9\-]+)\,/;
3161 `grep -Eq "^$vendor\\b" $vp_file`;
3164 … "DT compatible string vendor \"$vendor\" appears un-documented -- check $vp_file\n" . $herecurr);
3171 if ($rawline =~ /^[ \+]\s*\#\!\s*\//) {
3175 if ($realfile =~ /\.(h|s|S)$/) {
3187 $rawline =~ /SPDX-License-Identifier:/ &&
3188 $rawline !~ m@^\+\s*\Q$comment\E\s*@) {
3194 $rawline !~ m@^\+\Q$comment\E SPDX-License-Identifier: @) {
3196 … "Missing or malformed SPDX-License-Identifier tag in line $checklicenseline\n" . $herecurr);
3197 } elsif ($rawline =~ /(SPDX-License-Identifier: .*)/) {
3204 not $spdx_license =~ /GPL-2\.0.*BSD-2-Clause/) {
3209 "DT binding documents should be licensed (GPL-2.0-only OR BSD-2-Clause)\n" . $herecurr) &&
3211 …$fixed[$fixlinenr] =~ s/SPDX-License-Identifier: .*/SPDX-License-Identifier: (GPL-2.0-only OR BSD-…
3219 next if ($realfile !~ /\.(h|c|s|S|sh|dtsi|dts)$/);
3221 # check for using SPDX-License-Identifier on the wrong line number
3223 $rawline =~ /\bSPDX-License-Identifier:/ &&
3224 substr($line, @-, @+ - @-) eq "$;" x (@+ - @-)) {
3226 "Misplaced SPDX-License-Identifier tag - use line $checklicenseline instead\n" . $herecurr);
3252 …if ($line =~ /^\+\s*$logFunctions\s*\(\s*(?:(?:KERN_\S+\s*|[^"]*))?($String\s*(?:|,|\)\s*;)\s*)$/ …
3253 length(expand_tabs(substr($line, 1, length($line) - length($1) - 1))) <= $max_line_length) {
3258 } elsif ($line =~ /^\+\s*$String\s*(?:\s*|,|\)\s*;)\s*$/ ||
3259 $line =~ /^\+\s*#\s*define\s+\w+\s+$String$/) {
3263 } elsif ($line =~ /^\+.*\bEFI_GUID\s*\(/ ||
3264 $line =~ /^\+\s*(?:\w+)?\s*DEFINE_PER_CPU/) {
3268 } elsif ($rawline =~ /^\+.*\b[a-z][\w\.\+\-]*:\/\/\S+/i) {
3274 } elsif ($line =~ /($;[\s$;]*)$/ &&
3275 length(expand_tabs(substr($line, 1, length($line) - length($1) - 1))) <= $max_line_length) {
3279 } elsif ($sline =~ /\s*($String(?:\s*(?:\\|,\s*|\)\s*;\s*))?)$/ &&
3280 length(expand_tabs(substr($line, 1, length($line) - length($1) - 1))) <= $max_line_length) {
3303 # more than $tabsize must use tabs, except multi-line macros which may start
3305 if ($rawline =~ /^\+\s* \t\s*\S/ ||
3306 $rawline =~ /^\+\s* \s*/ &&
3307 $rawline !~ /^\+\s*\\$/) {
3313 $fixed[$fixlinenr] =~ s/^\+([ \t]+)/"\+" . tabify($1)/e;
3335 $fixed[$fixlinenr] =~ s/\b$first $second\b/$first/;
3339 # if it's a repeated word on consecutive lines in a comment block
3340 if ($prevline =~ /$;+\s*$/ &&
3341 $prevrawline =~ /($word_pattern)\s*$/) {
3343 if ($rawline =~ /^\+\s*\*\s*$last_word /) {
3347 $fixed[$fixlinenr] =~ s/(\+\s*\*\s*)$last_word /$1/;
3360 s/(^\+.*) {$tabsize,$tabsize}\t/$1\t\t/) {}
3362 s/(^\+.*) +\t/$1\t/) {}
3367 if ($sline =~ /^\+\s+($Assignment)[^=]/) {
3373 if ($rawline =~ /^\+\s*(&&|\|\|)/) {
3380 …$sline =~ /^\+\t+( +)(?:$c90_Keywords\b|\{\s*$|\}\s*(?:else\b|while\b|\s*$)|$Declare\s*$Ident\s*[;…
3386 $fixed[$fixlinenr] =~ s@(^\+\t+) +@$1 . "\t" x ($indent/$tabsize)@e;
3391 # check multi-line statement indentation matches previous line
3393 …(?:$c90_Keywords(?:\s+if)\s*)|(?:$Declare\s*)?(?:$Ident|\(\s*\*\s*$Ident\s*\))\s*|(?:\*\s*)*$Lval\…
3415 s/^\+[ \t]*/\+$goodtabindent/;
3428 if ($line =~ /^\+(.*)\(\s*$Type\s*\)([ \t]++)((?![={]|\\$|$Attribute|__attribute__))/ &&
3429 (!defined($1) || $1 !~ /\b(?:sizeof|__alignof__)\s*$/)) {
3434 s/(\(\s*$Type\s*\))[ \t]+/$1/;
3493 if ($prevline =~ /^[\+ ]};?\s*$/ &&
3495 !($line =~ /^\+\s*$/ ||
3496 $line =~ /^\+\s*EXPORT_SYMBOL/ ||
3497 $line =~ /^\+\s*MODULE_/i ||
3498 $line =~ /^\+\s*\#\s*(?:end|elif|else)/ ||
3499 $line =~ /^\+[a-z_]*init/ ||
3500 $line =~ /^\+\s*(?:static\s+)?[A-Z_]*ATTR/ ||
3501 $line =~ /^\+\s*DECLARE/ ||
3502 $line =~ /^\+\s*builtin_[\w_]*driver/ ||
3503 $line =~ /^\+\s*__setup/)) {
3512 if ($prevline =~ /^[\+ ]\s*$/ &&
3513 $line =~ /^\+\s*$/ &&
3514 $last_blank_line != ($linenr - 1)) {
3525 if ($sline =~ /^\+\s+\S/ && #Not at char 1
3527 ($prevline =~ /^\+\s+$Declare\s*$Ident\s*[=,;:\[]/ ||
3529 $prevline =~ /^\+\s+$Declare\s*\(\s*\*\s*$Ident\s*\)\s*[=,;:\[\(]/ ||
3531 $prevline =~ /^\+\s+$Ident(?:\s+|\s*\*\s*)$Ident\s*[=,;\[]/ ||
3533 $prevline =~ /^\+\s+$declaration_macros/) &&
3535 !($prevline =~ /^\+\s+$c90_Keywords\b/ ||
3537 $prevline =~ /(?:$Compare|$Assignment|$Operators)\s*$/ ||
3539 $prevline =~ /(?:\{\s*|\\)$/) &&
3541 !($sline =~ /^\+\s+$Declare\s*$Ident\s*[=,;:\[]/ ||
3543 $sline =~ /^\+\s+$Declare\s*\(\s*\*\s*$Ident\s*\)\s*[=,;:\[\(]/ ||
3545 $sline =~ /^\+\s+(?:volatile\s+)?$Ident(?:\s+|\s*\*\s*)$Ident\s*[=,;\[]/ ||
3547 $sline =~ /^\+\s+$declaration_macros/ ||
3549 $sline =~ /^\+\s+(?:static\s+)?(?:const\s+)?(?:union|struct|enum|typedef)\b/ ||
3551 $sline =~ /^\+\s+(?:$|[\{\}\.\#\"\?\:\(\[])/ ||
3553 $sline =~ /^\+\s+$Ident\s*:\s*\d+\s*[,;]/ ||
3555 $sline =~ /^\+\s+\(?\s*(?:$Compare|$Assignment|$Operators)/) &&
3557 (($prevline =~ /\+(\s+)\S/) && $sline =~ /^\+$1\S/)) {
3570 # 4) empty lines in multi-line macros
3572 $rawline !~ /^\+\s+\\$/) {
3577 $fixed[$fixlinenr] =~ s/^\+([ \t]+)/"\+" . tabify($1)/e;
3585 if ($line =~ /^\+.*([\[\(])\s*$/) {
3591 if ($sline =~ /^\+\{\s*$/ &&
3592 $prevline =~ /^\+(?:(?:(?:$Storage|$Inline)\s*)*\s*$Type\s*)?($Ident)\(/) {
3597 if ($sline =~ /^\+\}\s*$/) {
3604 if ($sline =~ /^\+([\t]+)(?:}[ \t]*)?else(?:[ \t]*{)?\s*$/) {
3617 if ($sline =~ /^\+([\t]+)break\s*;\s*$/) {
3642 $realcnt && $sline =~ /.\s*\S/) {
3645 $stat =~ s/\n./\n /g;
3646 $cond =~ s/\n./\n /g;
3652 my $frag = $stat; $frag =~ s/;+\s*$//;
3661 (!defined $lines[$realline_next - 1] ||
3662 substr($lines[$realline_next - 1], $off_next) =~ /^\s*$/)) {
3666 my $s = $stat;
3667 $s =~ s/{.*$//s;
3670 if ($s =~ /$Ident:\*$/s) {
3673 } elsif ($s =~ /^.\s*$Ident\s*\(/s) {
3675 } elsif ($s =~ /^.\s*else\b/s) {
3678 …s =~ /^.\s*(?:$Storage\s+)?(?:$Inline\s+)?(?:const\s+)?((?:\s*$Ident)+?)\b(?:\s+$Sparse)?\s*\**\s*…
3680 $type =~ s/\s+/ /g;
3681 possible($type, "A:" . $s);
3684 } elsif ($s =~ /^.(?:$Storage\s+)?(?:$Inline\s+)?(?:const\s+)?($Ident)\b\s*(?!:)/s) {
3685 possible($1, "B:" . $s);
3689 while ($s =~ /\(($Ident)(?:\s+$Sparse)*[\s\*]+\s*\)/sg) {
3690 possible($1, "C:" . $s);
3696 …f ($prev_values eq 'E' && $s =~ /^(.(?:typedef\s*)?(?:(?:$Storage|$Inline)\s*)*\s*$Type\s*(?:\b$Id…
3699 my $ctx = $s;
3701 $ctx =~ s/\)[^\)]*$//;
3703 for my $arg (split(/\s*,\s*/, $ctx)) {
3704 …if ($arg =~ /^(?:const\s+)?($Ident)(?:\s+$Sparse)*\s*\**\s*(:?\b$Ident)?$/s || $arg =~ /^($Ident)$…
3706 possible($1, "D:" . $s);
3719 if ($line=~/\bswitch\s*\(.*\)/) {
3726 if ($ctx =~ /^\+\s*(case\s+|default:)/ &&
3742 … /(.*)\b((?:if|while|for|switch|(?:[A-Z_]+|)FOR_EACH(?!_NONEMPTY_TERM)[A-Z_]+)\s*\(|do\b|else\b)/ …
3749 "Too many leading tabs - consider code refactoring\n" . $herecurr);
3752 my $ctx_cnt = $realcnt - $#ctx - 1;
3759 defined $lines[$ctx_ln - 1] &&
3760 $lines[$ctx_ln - 1] =~ /^-/)) {
3762 $ctx_skip-- if (!defined $lines[$ctx_ln - 1] || $lines[$ctx_ln - 1] !~ /^-/);
3767 #print "pre<$pre_ctx>\nline<$line>\nctx<$ctx>\nnext<$lines[$ctx_ln - 1]>\n";
3769 if ($ctx !~ /{\s*/ && defined($lines[$ctx_ln - 1]) && $lines[$ctx_ln - 1] =~ /^\+\s*{/) {
3772 "$here\n$ctx\n$rawlines[$ctx_ln - 1]\n");
3774 if ($level == 0 && $pre_ctx !~ /}\s*while\s*\($/ &&
3775 $ctx =~ /\)\s*\;\s*$/ &&
3776 defined $lines[$ctx_ln - 1])
3778 my ($nlength, $nindent) = line_stats($lines[$ctx_ln - 1]);
3782 "$here\n$ctx\n$rawlines[$ctx_ln - 1]\n");
3788 …|(?:[A-Z_]+|)FOR_EACH(?!_NONEMPTY_TERM|_IDX|_FIXED_ARG|_IDX_FIXED_ARG)[A-Z_]+)\s*\(|(?:do|else)\b)…
3792 my ($s, $c) = ($stat, $cond);
3794 substr($s, 0, length($c), '');
3797 $s =~ s/$;/ /g;
3798 $c =~ s/$;/ /g;
3807 $s =~ s/\n./\n/gs;
3808 while ($s =~ /\n\s+\\\n/) {
3809 $cond_lines += $s =~ s/\n\s+\\\n/\n/g;
3819 $s =~ s/^.*\bdo\b//;
3820 $s =~ s/^\s*{//;
3821 if ($s =~ s/^\s*\\//) {
3824 if ($s =~ s/^\s*?\n//) {
3831 if (($prevline =~ /^.\s*#\s*define\s/ ||
3832 $prevline =~ /\\\s*$/) && $continuation == 0) {
3836 my $cond_ptr = -1;
3843 if ($s =~ /^\s*\#\s*(?:else|elif)/) {
3852 $s =~ /^\s*?\n/ ||
3853 $s =~ /^\s*#\s*?/ ||
3854 $s =~ /^\s*$Ident\s*:/) {
3855 $continuation = ($s =~ /^.*?\\\n/) ? 1 : 0;
3856 if ($s =~ s/^.*?\n//) {
3862 my (undef, $sindent) = line_stats("+" . $s);
3866 # this is not this patch's fault.
3875 …dent<$indent> sindent<$sindent> check<$check> continuation<$continuation> s<$s> cond_lines<$cond_l…
3877 if ($check && $s ne '' &&
3881 ($s !~ /^\s*(?:\}|\{|else\b)/)) ||
3889 my $opline = $line; $opline =~ s/^./ /;
3894 my $outline = $opline; $outline =~ s/\t/ /g;
3899 $prev_values = substr($curr_values, -1);
3905 if ($prevline =~ /^\+.*$Lval\s*(?:\.|->)\s*$/ &&
3906 $line =~ /^\+\s*(?!\#\s*(?!define\s+|if))\s*$Lval/) {
3907 $prevline =~ /($Lval\s*(?:\.|->))\s*$/;
3909 $line =~ /^.\s*($Lval)/;
3911 $ref =~ s/\s//g;
3913 "Avoid multiple line dereference - prefer '$ref'\n" . $hereprev);
3917 while ($line =~ m{\b($Declare)\s*(?!char\b|short\b|int\b|long\b)\s*($Ident)?\s*[=,;\[\)\(]}g) {
3921 if ($type =~ /^(?:(?:$Storage|$Inline|$Attribute)\s+)*((?:un)?signed)((?:\s*\*)*)\s*$/) {
3932 $comp_pointer =~ s/\s//g;
3935 $fixed[$fixlinenr] =~ s@\b$sign\s*\Q$pointer\E\s*$var\b@$decl$var@;
3942 if ($line =~ /^.\s*$Declare\s*$/) {
3953 if ($line =~ /^.\s*$Modifier\s*$/) {
3964 if ($line =~ /^.\s*{/ &&
3965 $prevline =~ /(?:^|[^=])=\s*$/) {
3969 fix_delete_line($fixlinenr - 1, $prevrawline);
3972 $fixedline =~ s/\s*=\s*$/ = {/;
3975 $fixedline =~ s/^(.\s*)\{\s*/$1/;
3985 if ($rawline =~ m{^.\s*\#\s*include\s+[<"](.*)[">]}) {
4005 $fixed[$fixlinenr] =~ s@\/\/(.*)$@/\* $comment \*/@;
4010 $line =~ s@//.*@@;
4011 $opline =~ s@//.*@@;
4015 #print "APW <$lines[$realline_next - 1]>\n";
4017 exists $lines[$realline_next - 1] &&
4019 ($lines[$realline_next - 1] =~ /EXPORT_SYMBOL.*\((.*)\)/ ||
4020 $lines[$realline_next - 1] =~ /EXPORT_UNUSED_SYMBOL.*\((.*)\)/)) {
4026 if ($stat =~ /^(?:.\s*}\s*\n)?.([A-Z_]+)\s*\(\s*($Ident)/ &&
4032 \n.}\s*$|
4036 ^.(?:$Storage\s+)?$Type\s*\(\s*\*\s*\Q$name\E\s*\)\s*\(|
4037 \b\Q$name\E(?:\s+$Attribute)*\s*(?:;|=|\[|\()
4039 #print "FOO A<$lines[$realline_next - 1]> stat<$stat> name<$name>\n";
4046 $prevline =~ /^.\s*$/ &&
4049 #print "FOO B <$lines[$linenr - 1]>\n";
4059 if ($line =~ /^\+$Type\s*$Ident(?:\s+$Modifier)*\s*=\s*($zero_initializer)\s*;/) {
4063 $fixed[$fixlinenr] =~ s/(^.$Type\s*$Ident(?:\s+$Modifier)*)\s*=\s*$zero_initializer\s*;/$1;/;
4067 if ($line =~ /^\+.*\bstatic\s.*=\s*($zero_initializer)\s*;/) {
4072 $fixed[$fixlinenr] =~ s/(\bstatic\s.*?)\s*=\s*$zero_initializer\s*;/$1;/;
4084 while ($sline =~ m{\b($TypeMisordered(\s*\*)*|$C90_int_types)\b}g) {
4087 next if ($type !~ /\b(?:short|long\s+long|long)\b/);
4089 $new_type =~ s/\b\s*int\s*\b/ /;
4090 $new_type =~ s/\b\s*(?:un)?signed\b\s*/ /;
4091 $new_type =~ s/^const\s+//;
4094 $new_type =~ s/\s+/ /g;
4099 $fixed[$fixlinenr] =~ s/\b\Q$type\E\b/$new_type/;
4104 if ($line =~ /\bstatic\s+const\s+char\s*\*\s*(\w+)\s*\[\s*\]\s*=\s*/) {
4111 …if ($line =~ /^\+\s*const\s+(char|unsigned\s+char|_*u8|(?:[us]_)?int8_t)\s+\w+\s*\[\s*(?:\w+\s*)?\…
4115 $fixed[$fixlinenr] =~ s/(^.\s*)const\b/${1}static const/;
4120 if ($line =~ /\bstatic\s+char\s+(\w+)\s*\[\s*\]\s*=\s*"/) {
4127 if ($sline =~ /\bconst\s+($BasicType)\s+const\b/) {
4129 if ($sline =~ /\bconst\s+\Q$found\E\s+const\b\s*\*/) {
4132 } elsif ($sline !~ /\bconst\s+\Q$found\E\s+const\s+\w+\s*\[/) {
4138 # check for non-global char *foo[] = {"bar", ...} declarations.
4139 if ($line =~ /^.\s+(?:static\s+|const\s+)?char\s+\*\s*\w+\s*\[\s*\]\s*=\s*\{/) {
4146 if ($line =~ m@\bsizeof\s*\(\s*($Lval)\s*\)@) {
4148 …if ($line =~ m@\b(sizeof\s*\(\s*\Q$array\E\s*\)\s*/\s*sizeof\s*\(\s*\Q$array\E\s*\[\s*0\s*\]\s*\))…
4153 $fixed[$fixlinenr] =~ s/\Q$array_div\E/ARRAY_SIZE($array)/;
4159 if ($line =~ /(\b$Type\s*$Ident)\s*\(\s*\)/) {
4161 "Bad function definition - $1() should probably be $1(void)\n" . $herecurr) &&
4163 $fixed[$fixlinenr] =~ s/(\b($Type)\s+($Ident))\s*\(\s*\)/$2 $3(void)/;
4170 if ($line =~ /\btypedef\s/ &&
4171 $line !~ /\btypedef\s+$Type\s*\(\s*\*?$Ident\s*\)\s*\(/ &&
4172 $line !~ /\btypedef\s+$Type\s+$Ident\s*\(/ &&
4182 while ($line =~ m{(\($NonptrType(\s*(?:$Modifier\b\s*|\*\s*)+)\))}g) {
4187 $to =~ s/^(\S)/ $1/;
4189 $to =~ s/\s+$//;
4190 # '*'s should not have spaces between.
4191 while ($to =~ s/\*\s+\*/\*\*/) {
4201 $sub_to =~ s/\Q$from\E/$to/;
4203 s@\Q$sub_from\E@$sub_to@;
4207 while ($line =~ m{(\b$NonptrType(\s*(?:$Modifier\b\s*|\*\s*)+)($Ident))}g) {
4212 $to =~ s/^(\S)/ $1/;
4214 $to =~ s/\s+$//;
4215 # '*'s should not have spaces between.
4216 while ($to =~ s/\*\s+\*/\*\*/) {
4219 $to =~ s/(\b$Modifier$)/$1 /;
4229 $sub_to =~ s/\Q$from\E/$to/;
4231 s@\Q$sub_from\E@$sub_to@;
4241 …"Avoid crashing the kernel - try using WARN_ON & recovery code rather than BUG() or BUG_ON()\n" . …
4251 if ($line =~ /\bprintk_ratelimit\s*\(/) {
4257 if ($line =~ /\bprintk\s*\(\s*(?!KERN_[A-Z]+\b)/) {
4262 if ($line =~ /\bprintk\s*\(\s*KERN_([A-Z]+)/) {
4272 if ($line =~ /\bdev_printk\s*\(\s*KERN_([A-Z]+)/) {
4296 $fixed[$fixlinenr] =~ s/\bENOTSUPP\b/EOPNOTSUPP/;
4303 $sline =~ /$Type\s*$Ident\s*$balanced_parens\s*\{/ &&
4304 $sline !~ /\#\s*define\b.*do\s*\{/ &&
4311 $fixed_line =~ /(^..*$Type\s*$Ident\(.*\)\s*){(.*)$/;
4316 if ($line2 !~ /^\s*$/) {
4323 if ($line =~ /^.\s*{/ &&
4324 $prevline =~ /^.\s*(?:typedef\s+)?(enum|union|struct)(?:\s+$Ident)?\s*$/) {
4328 fix_delete_line($fixlinenr - 1, $prevrawline);
4333 $fixedline =~ s/^(.\s*)\{\s*/$1\t/;
4334 if ($fixedline !~ /^\+\s*$/) {
4341 if ($line =~ /^.\s*(?:typedef\s+)?(enum|union|struct)(?:\s+$Ident){1,2}[=\{]/) {
4346 s/^(.\s*(?:typedef\s+)?(?:enum|union|struct)(?:\s+$Ident){1,2})([=\{])/$1 $2/;
4353 if ($line =~ /^.\s*($Declare)\((\s*)\*(\s*)($Ident)(\s*)\)(\s*)\(/) {
4365 if ($declare =~ /(\s+)$/) {
4381 # elsif ($declare =~ /\s{2,}$/) {
4388 $pre_pointer_space =~ /^\s/) {
4395 $post_pointer_space =~ /^\s/) {
4402 $post_funcname_space =~ /^\s/) {
4409 $pre_args_space =~ /^\s/) {
4416 …s/^(.\s*)$Declare\s*\(\s*\*\s*$Ident\s*\)\s*\(/$1 . $declare . $post_declare_space . '(*' . $funcn…
4421 # 1. with a type on the left -- int [] a;
4422 # 2. at the beginning of a line for slice initialisers -- [0...10] = 5,
4423 # 3. inside a curly brace -- = { [0...10] = 5 }
4424 while ($line =~ /(.*?\s)\[/g) {
4425 my ($where, $prefix) = ($-[1], $1);
4426 if ($prefix !~ /$Type\s+$/ &&
4427 ($where != 0 || $prefix !~ /^.\s+$/) &&
4428 $prefix !~ /[{,:]\s+$/ &&
4429 $prefix !~ /:\s+$/) {
4434 s/^(\+.*?)\s+\[/$1\[/;
4440 while ($line =~ /($Ident)\s+\(/g) {
4442 my $ctx_before = substr($line, 0, $-[1]);
4452 # cpp #define statements have non-optional spaces, ie
4455 } elsif ($ctx_before =~ /^.\s*\#\s*define\s*$/) {
4458 } elsif ($ctx =~ /^.\s*\#\s*elif\s*$/) {
4469 s/\b$name\s+\(/$name\(/;
4475 if (!($line=~/\#\s*include/)) {
4481 \+=|-=|\*=|\/=|%=|\^=|\|=|&=|
4482 =>|->|<<|>>|<|>|=|!|~|
4483 &&|\|\||,|\^|\+\+|--|&|\||\+|-|\*|\/|%|
4504 my $last_after = -1;
4524 $a = 'W' if ($elements[$n] =~ /\s$/);
4528 $a = 'E' if ($ca =~ /^\s*$/);
4535 $c = 'W' if ($elements[$n + 2] =~ /^\s/);
4539 $c = 'E' if ($elements[$n + 2] =~ /^\s*\\$/);
4559 $ca =~ /\s$/ && $cc =~ /^\s*[,\)]/) {
4583 # ->
4584 } elsif ($op eq '->') {
4590 $fix_elements[$n + 2] =~ s/^\s+//;
4626 # '*' as part of a type definition -- reported already.
4634 $opv eq '*U' || $opv eq '-U' ||
4636 if ($ctx !~ /[WEBC]x./ && $ca !~ /(?:\)|!|~|\*|-|\&|\||\+\+|\-\-|\{)$/) {
4645 if ($op eq '*' && $cc =~/\s*$Modifier\b/) {
4653 $fix_elements[$n + 2] =~ s/^\s+//;
4659 # unary ++ and unary -- are allowed no space on one side.
4660 } elsif ($op eq '++' or $op eq '--') {
4681 $fix_elements[$n + 2] =~ s/^\s+//;
4690 $op eq '+' or $op eq '-' or
4699 $fix_elements[$n + 2] =~ s/^\s+//;
4714 $fix_elements[$n + 2] =~ s/^\s+//;
4737 $cc =~ /^\S+\@\S+>/) ||
4739 $ca =~ /<\S+\@\S+$/))
4768 $fix_elements[$n + 2] =~ s/^\s+//;
4792 # check for whitespace before a non-naked semicolon
4793 if ($line =~ /^\+.*\S\s+;\s*$/) {
4798 s/^(\+.*\S)\s+;/$1;/;
4803 if ($line =~ /^.\s*$Lval\s*=\s*$Lval\s*=(?!=)/) {
4810 ## if ($line =~ /^.\s*$Type\s+$Ident(?:\s*=[^,{]*)?\s*,\s*$Ident.*/ &&
4811 ## $line !~ /^.\s*$Type\s+$Ident(?:\s*=[^,{]*)?\s*,\s*$Type\s*$Ident.*/) {
4816 ## while ($ln =~ s/\([^\(\)]*\)//g) {
4830 $fixed[$fixlinenr] =~ s/^(\+.*(?:do|else|\)))\{/$1 {/;
4835 ## if ($line =~ /^.\t+$Type\s+$Ident(?:\s*=.*)?;/ &&
4836 ## $prevrawline =~ /^.\s*$/) {
4844 if ($line =~ /}(?!(?:,|;|\)|\}))\S/) {
4849 s/}((?!(?:,|;|\)))\S)/} $1/;
4854 if ($line =~ /\[\s/ && $line !~ /\[\s*$/) {
4859 s/\[\s+/\[/;
4862 if ($line =~ /\s\]/) {
4867 s/\s+\]/\]/;
4872 if ($line =~ /\(\s/ && $line !~ /\(\s*(?:\\)?$/ &&
4873 $line !~ /for\s*\(\s+;/) {
4878 s/\(\s+/\(/;
4881 if ($line =~ /(\s+)\)/ && $line !~ /^.\s*\)/ &&
4882 $line !~ /for\s*\(.*;\s+\)/ &&
4883 $line !~ /:\s+\)/) {
4888 s/\s+\)/\)/;
4893 # ie: &(foo->bar) should be &foo->bar and *(foo->bar) should be *foo->bar
4895 while ($line =~ /(?:[^&]&\s*|\*)\(\s*($Ident\s*(?:$Member\s*)+)\s*\)/g) {
4900 $fixed[$fixlinenr] =~ s/\(\s*\Q$var\E\s*\)/$var/;
4905 # ie: (foo->bar)(); should be foo->bar();
4906 # but not "if (foo->bar) (" to avoid some false positives
4907 if ($line =~ /(\bif\s*|)(\(\s*$Ident\s*(?:$Member\s*)+\))[ \t]*\(/ && $1 !~ /^if/) {
4913 $var2 =~ s/\s//g;
4914 $fixed[$fixlinenr] =~ s/\Q$var\E/$var2/;
4919 # when !drivers/staging or command-line uses --strict
4922 $stat =~ /(^.\s*if\s*($balanced_parens))/) {
4924 my $test = substr($2, 1, -1);
4926 …while ($test =~ /(?:^|[^\w\&\!\~])+\s*\(\s*([\&\!\~]?\s*$Lval\s*(?:$Compare\s*$FuncArg)?)\s*\)/g) {
4929 next if ($match =~ /^\s*\w+\s*$/);
4948 if ($sline =~ /^.\s+[A-Za-z_][A-Za-z\d_]*:(?!\s*\d+)/ &&
4949 $sline !~ /^. [A-Za-z\d_][A-Za-z\d_]*:/ &&
4950 $sline !~ /^.\s+default:/) {
4955 s/^(.)\s+/$1/;
4960 if (defined($stat) && $stat =~ /^.\s*return(\s*)\(/s) {
4963 $stat =~ /^.\s*return\s*($balanced_parens)\s*;\s*$/) {
4966 if ($value =~ m/^\s*$FuncArg\s*(?:\?|$)/) {
4970 } elsif ($spacing !~ /\s+/) {
4977 # at end-of-function, with the previous line a single leading tab, then return;
4979 if ($sline =~ /^[ \+]}\s*$/ &&
4980 $prevline =~ /^\+\treturn\s*;\s*$/ &&
4982 $lines[$linenr - 3] =~ /^[ +]/ &&
4983 $lines[$linenr - 3] !~ /^[ +]\s*$Ident\s*:/) {
4988 # if statements using unnecessary parentheses - ie: if ((foo == bar))
4990 $line =~ /\bif\s*((?:\(\s*){2,})/) {
4994 …if ($line =~ /\bif\s*(?:\(\s*){$count,$count}$LvalOrFunc\s*($Compare)\s*$LvalOrFunc(?:\s*\)){$coun…
4996 $msg = " - maybe == should be = ?" if ($comp eq "==");
5007 …!($line =~ /^\+(.*)($Constant|[A-Z_][A-Z0-9_]*)\s*($Compare)\s*(.*)($Constant|[A-Z_][A-Z0-9_]*)(.*…
5008 $line =~ /^\+(.*)\b($Constant|[A-Z_][A-Z0-9_]*)\s*($Compare)\s*($LvalOrFunc)/) {
5014 if ($lead !~ /(?:$Operators|\.)\s*$/ &&
5015 $to !~ /^(?:Constant|[A-Z_][A-Z0-9_]*)$/ &&
5028 $fixed[$fixlinenr] =~ s/\(\s*\Q$const\E\s*$Compare\s*\Q$to\E\s*\)/($to $newcomp $const)/;
5033 if ($sline =~ /\breturn(?:\s*\(+\s*|\s+)(E[A-Z]+)(?:\s*\)+\s*|\s*)[;:,]/) {
5039 "return of an errno should typically be negative (ie: return -$1)\n" . $herecurr);
5050 s/\b(if|while|for|switch)\(/$1 \(/;
5054 # Check for illegal assignment in if conditional -- and check for trailing
5056 if ($line =~ /do\s*(?!{)/) {
5062 $stat_next =~ s/\n./\n /g;
5065 if ($stat_next =~ /^\s*while\b/) {
5069 ($stat_next =~ /^((?:\s*\n[+-])*\s*)/s);
5071 statement_rawlines($whitespace) - 1;
5079 $line =~ /\b(?:if|while|for)\s*\(/ && $line !~ /^.\s*#/) {
5080 my ($s, $c) = ($stat, $cond);
5082 if ($c =~ /\bif\s*\(.*[^<>!=]=[^=].*/s) {
5086 …if ($rawline =~ /^\+(\s+)if\s*\(\s*(\!)?\s*\(\s*(($Lval)\s*=\s*$LvalOrFunc)\s*\)\s*(?:($Compare)\s…
5111 substr($s, 0, length($c), '');
5112 $s =~ s/\n.*//g;
5113 $s =~ s/$;//g; # Remove any comments
5114 if (length($c) && $s !~ /^\s*{?\s*\\*\s*$/ &&
5115 $c !~ /}\s*while\s*/)
5137 \s*0[xX][0-9]+\s*
5141 \s*0[xX][0-9]+\s*
5150 if ($line =~ /^.\s*(?:}\s*)?else\b(.*)/) {
5151 my $s = $1;
5152 $s =~ s/$;//g; # Remove any comments
5153 if ($s !~ /^\s*(?:\sif|(?:{|)\s*\\?\s*$)/) {
5159 if ($line =~ /}\s*if\b/) {
5165 if ($line =~ /^.\s*(?:case\s*.*|default\s*):/g &&
5167 (?:\s*$;*)(?:\s*{)?(?:\s*$;*)(?:\s*\\)?\s*$|
5168 \s*return\s+
5177 if ($prevline=~/}\s*$/ and $line=~/^.\s*else\s*/ &&
5182 fix_delete_line($fixlinenr - 1, $prevrawline);
5185 $fixedline =~ s/}\s*$//;
5186 if ($fixedline !~ /^\+\s*$/) {
5190 $fixedline =~ s/^(.\s*)else/$1} else/;
5195 if ($prevline=~/}\s*$/ and $line=~/^.\s*while\s*/ &&
5197 my ($s, $c) = ctx_statement_block($linenr, $realcnt, 0);
5201 substr($s, 0, length($c), '');
5202 $s =~ s/\n.*//g;
5204 if ($s =~ /^\s*;/) {
5208 fix_delete_line($fixlinenr - 1, $prevrawline);
5212 $trailing =~ s/^\+//;
5214 $fixedline =~ s/}\s*$/} $trailing/;
5226 $var =~ /[A-Z][a-z]|[a-z][A-Z]/ &&
5228 $var !~ /^(?:Clear|Set|TestClear|TestSet|)Page[A-Z]/ &&
5231 $var !~ /^(?:[a-z0-9_]*|[A-Z0-9_]*)?_?[a-z][A-Z](?:_[a-z0-9_]+|_[A-Z0-9_]+)?$/ &&
5233 $var !~ /^(?:[a-z_]*?)_?(?:[KMGT]iB|[KMGT]?Hz)(?:_[a-z_]+)?$/) {
5236 next if ($word !~ /[A-Z][a-z]|[a-z][A-Z]/);
5254 if ($line =~ /\#\s*define.*\\\s+$/) {
5258 $fixed[$fixlinenr] =~ s/\s+$//;
5264 if ($tree && $rawline =~ m{^.\s*\#\s*include\s*\<asm\/(.*)\.h\>}) {
5267 if (-f "$root/$checkfile" &&
5271 my $asminclude = `grep -Ec "#include\\s+<asm/$file>" $root/$checkfile`;
5284 # multi-statement macros should be enclosed in a do while loop, grab the
5288 $line =~ /^.\s*\#\s*define\s*$Ident(\()?/) {
5299 #print "LINE<$lines[$ln-1]> len<" . length($lines[$ln-1]) . "\n";
5302 …$has_arg_concat = 1 if (($ctx =~ /\#\#/ || $ctx =~ /UTIL_CAT/) && $ctx !~ /\#\#\s*(?:__VA_ARGS__|a…
5304 $dstat =~ s/^.\s*\#\s*define\s+$Ident(\([^\)]*\))?\s*//;
5310 $define_args = substr($define_args, 1, length($define_args) - 2);
5311 $define_args =~ s/\s*//g;
5312 $define_args =~ s/\\\+?//g;
5316 $dstat =~ s/$;//g;
5317 $dstat =~ s/\\\n.//g;
5318 $dstat =~ s/^\s*//s;
5319 $dstat =~ s/\s*$//s;
5322 while ($dstat =~ s/\([^\(\)]*\)/1/ ||
5323 $dstat =~ s/\{[^\{\}]*\}/1/ ||
5324 $dstat =~ s/.\[[^\[\]]*\]/1/)
5329 while ($dstat =~ s/($String)\s*$Ident/$1/ ||
5330 $dstat =~ s/$Ident\s*($String)/$1/)
5335 $dstat =~ s/\b_*asm_*\s+_*volatile_*\b/asm_volatile/g;
5346 \.$Ident\s*=\s*|
5352 $ctx =~ s/\n*$//;
5357 $dstat !~ /^(?:$Ident|-?$Constant),$/ && # 10, // foo(),
5358 $dstat !~ /^(?:$Ident|-?$Constant);$/ && # foo();
5359 …$dstat !~ /^[!~-]?(?:$Lval|$Constant)$/ && # 10 // foo() // !foo // ~foo // -foo // foo->bar // f…
5362 $dstat !~ /^\.$Ident\s*=/ && # .foo =
5363 $dstat !~ /^(?:\#\s*$Ident|\#\s*$Constant)\s*$/ && # stringification #foo
5364 …$dstat !~ /^do\s*$Constant\s*while\s*$Constant;?$/ && # do {...} while (...); // do {...} while (.…
5365 $dstat !~ /^for\s*$Constant$/ && # for (...)
5366 $dstat !~ /^for\s*$Constant\s+(?:$Ident|-?$Constant)$/ && # for (...) bar()
5367 $dstat !~ /^do\s*{/ && # do {...
5369 $ctx !~ /^.\s*#\s*define\s+TRACE_(?:SYSTEM|INCLUDE_FILE|INCLUDE_PATH)\b/)
5371 if ($dstat =~ /^\s*if\b/) {
5373 …"Macros starting with if should be enclosed by a do - while loop to avoid possible if/else logic d…
5376 … "Macros with multiple statements should be enclosed in a do - while loop\n" . "$herectx");
5384 # Make $define_stmt single line, comment-free, etc
5389 $l =~ s/\\$//;
5397 $define_stmt =~ s/$;//g;
5398 $define_stmt =~ s/\s+/ /g;
5406 …$tmp_stmt =~ s/\b(sizeof|typeof|__typeof__|__builtin\w+|typecheck\s*\(\s*$Type\s*,|\#+)\s*\(*\s*$a…
5407 $tmp_stmt =~ s/\#+\s*$arg\b//g;
5408 $tmp_stmt =~ s/\b$arg\s*\#\#//g;
5412 "Macro argument reuse '$arg' - possible side-effects?\n" . "$herectx");
5415 if ($tmp_stmt =~ m/($Operators)?\s*\b$arg\b\s*($Operators)?/m &&
5437 $line !~ /^\+\s*\#.*\\$/ && # preprocessor
5446 # single-statement macros do not need to be enclosed in do while (0) loop,
5450 $line =~ /^.\s*\#\s*define\s+$Ident(\()?/) {
5459 $dstat =~ s/\\\n.//g;
5460 $dstat =~ s/$;/ /g;
5462 …if ($dstat =~ /^\+\s*#\s*define\s+$Ident\s*${balanced_parens}\s*do\s*{(.*)\s*}\s*while\s*\(\s*0\s*…
5466 $ctx =~ s/\n*$//;
5471 $stmts !~ /^\s*(if|while|for|switch)\b/) {
5479 } elsif ($dstat =~ /^\+\s*#\s*define\s+$Ident.*;\s*$/) {
5480 $ctx =~ s/\n*$//;
5490 if ($line =~ /(^.*)\bif\b/ && $1 !~ /else\s*$/) {
5500 my $ln = $linenr - 1;
5505 my ($whitespace) = ($cond =~ /^((?:\s*\n[+-])*\s*)/s);
5506 my $offset = statement_rawlines($whitespace) - 1;
5515 $ln += statement_rawlines($block) - 1;
5519 $seen++ if ($block =~ /^\s*{/);
5552 if (!defined $suppress_ifbraces{$linenr - 1} &&
5556 # Check the pre-context.
5557 if (substr($line, 0, $-[0]) =~ /(\}\s*)$/) {
5563 ctx_statement_full($linenr, $realcnt, $-[0]);
5583 # Check the post-context.
5589 if ($block =~ /^\s*\{/) {
5590 #print "APW: ALLOWED: chunk-1 block<$block>\n";
5594 if ($level == 0 && $block =~ /^\s*\{/ && !$allowed) {
5604 if ($sline =~ /^.\s*\}\s*else\s*$/ ||
5605 $sline =~ /^.\s*else\s*\{\s*$/) {
5610 if (($line =~ /^.\s*}\s*$/ && $prevrawline =~ /^.\s*$/)) {
5614 fix_delete_line($fixlinenr - 1, $prevrawline);
5617 if (($rawline =~ /^.\s*$/ && $prevline =~ /^..*{\s*$/)) {
5626 my $asm_volatile = qr{\b(__asm__|asm)\s+(__volatile__|volatile)\b};
5629 …"Use of volatile is usually wrong: see Documentation/process/volatile-considered-harmful.rst\n" . …
5632 # Check for user-visible strings broken across lines, which breaks the ability
5636 if ($line =~ /^\+\s*$String/ &&
5637 $prevline =~ /"\s*$/ &&
5638 $prevrawline !~ /(?:\\(?:[ntr]|[0-7]{1,3}|x[0-9a-fA-F]{1,2})|;\s*|\{\s*)"\s*$/) {
5642 $prevrawline =~ /^\+.*"\s*$/ &&
5643 $last_coalesced_string_linenr != $linenr - 1) {
5646 if ($rawline =~ /\Q$extracted_string\E(\s*\)\s*;\s*$|\s*,\s*)/) {
5650 fix_delete_line($fixlinenr - 1, $prevrawline);
5653 $fixedline =~ s/"\s*$//;
5655 fix_insert_line($fixlinenr - 1, $fixedline);
5657 $fixedline =~ s/\Q$extracted_string\E\Q$comma_close\E//;
5658 if ($fixedline !~ /\+\s*$/) {
5672 # This does not work very well for -f --file checking as it depends on patch
5673 # context providing the function name or a single line form for in-file
5680 …"Prefer using '\"%s...\", __func__' to using '$context_function', this function's name, in a strin…
5684 if ($rawline =~ /^.*\".*\s\\n/) {
5688 $fixed[$fixlinenr] =~ s/^(\+.*\".*)\s+\\n/$1\\n/;
5694 if ($line =~ /$String[A-Za-z0-9_]/ || $line =~ /[A-Za-z0-9_]$String/) {
5699 my $extracted_string = substr($rawline, $-[0], $+[0] - $-[0]);
5700 $fixed[$fixlinenr] =~ s/\Q$extracted_string\E([A-Za-z0-9_])/$extracted_string $1/;
5701 $fixed[$fixlinenr] =~ s/([A-Za-z0-9_])\Q$extracted_string\E/$1 $extracted_string/;
5707 if ($line =~ /$String\s*"/) {
5711 while ($line =~ /($String)(?=\s*")/g) {
5712 my $extracted_string = substr($rawline, $-[0], $+[0] - $-[0]);
5713 $fixed[$fixlinenr] =~ s/\Q$extracted_string\E\s*"/substr($extracted_string, 0, -1)/e;
5718 # check for non-standard and hex prefixed decimal printf formats
5722 my $string = substr($rawline, $-[1], $+[1] - $-[1]);
5723 $string =~ s/%%/__/g;
5727 "\%L$1 is non-standard C, use %ll$1\n" . $herecurr);
5733 "%Z$1 is non-standard C, use %z$1\n" . $herecurr);
5750 if ($line =~ /^.\s*\#\s*if\s+0\b/) {
5756 if ($line =~ /^.\s*\#\s*if\s+1\b/) {
5762 if ($prevline =~ /\bif\s*\(\s*($Lval)\s*\)/) {
5764 my $expr = '\s*\(\s*' . $tested . '\s*\)\s*;';
5773 if ($lines[$linenr - 2] =~ /^\+(\t*)if\s*\(\s*$tested\s*\)\s*$/) {
5778 if ($lines[$linenr - 1] =~ /^\+(\t+)$func\s*\(\s*$tested\s*\)\s*;\s*$/) {
5787 fix_delete_line($fixlinenr - 1, $prevrawline);
5788 $fixed[$fixlinenr] =~ s/^\+$new_leading_tabs/\+$leading_tabs/;
5795 if ($line =~ /^\+.*\b$logFunctions\s*\(/ &&
5796 $prevline =~ /^[ \+]\s*if\s*\(\s*(\!\s*|NULL\s*==\s*)?($Lval)(\s*==\s*NULL\s*)?\s*\)/ &&
5800 my $testline = $lines[$linenr - 3];
5802 my ($s, $c) = ctx_statement_block($linenr - 3, $realcnt, 0);
5803 # print("line: <$line>\nprevline: <$prevline>\ns: <$s>\nc: <$c>\n\n\n");
5805 …if ($s =~ /(?:^|\n)[ \+]\s*(?:$Type\s*)?\Q$testval\E\s*=\s*(?:\([^\)]*\)\s*)?\s*$allocFunctions\s*…
5806 $s !~ /\b__GFP_NOWARN\b/ ) {
5813 if ($line !~ /printk(?:_ratelimited|_once)?\s*\(/ &&
5814 $line =~ /\b$logFunctions\s*\(.*\b(KERN_[A-Z]+)\b/) {
5819 $fixed[$fixlinenr] =~ s/\s*$level\s*//;
5824 if ($line =~ /\bprintk\s*\(\s*KERN_CONT\b|\bpr_cont\s*\(/) {
5831 $line =~ /$LvalOrFunc\s*\&\s*($LvalOrFunc)\s*>>/ &&
5834 … "Possible precedence defect with mask then right shift - may need parentheses\n" . $herecurr);
5839 while ($line =~ /\b$LvalOrFunc\s*(==|\!=)\s*NULL\b/g) {
5846 $fixed[$fixlinenr] =~ s/\b\Q$val\E\s*(?:==|\!=)\s*NULL\b/$equal$val/;
5854 …if ($line =~ /^\+\s*static\s+(?:const\s+)?(?:$attr\s+)?($NonptrTypeWithAttr)\s+(?:$attr\s+)?($Iden…
5857 if ((($ptr =~ /\b(union|struct)\s+$attr\b/ &&
5860 ($ptr !~ /\b(union|struct)\s+$attr\b/ &&
5864 …s/(\bstatic\s+(?:const\s+)?)(?:$attr\s+)?($NonptrTypeWithAttr)\s+(?:$attr\s+)?($Ident(?:\[[^]]*\])…
5879 s/$InitAttributeData/${attr_prefix}initconst/;
5890 /(^\+\s*(?:static\s+))/;
5894 $fixed[$fixlinenr] =~ s/(^\+\s*(?:static\s+))/$lead/;
5898 # check for __read_mostly with const non-pointer (should just be const)
5900 $line =~ /($Type)\s*$Ident/ && $1 !~ /\*\s*$/ && $1 =~ /\bconst\b/) {
5904 $fixed[$fixlinenr] =~ s/\s+__read_mostly\b//;
5910 … $line =~ /(__constant_(?:htons|ntohs|[bl]e(?:16|32|64)_to_cpu|cpu_to_[bl]e(?:16|32|64)))\s*\(/) {
5913 $func =~ s/^__constant_//;
5917 $fixed[$fixlinenr] =~ s/\b$constant_func\b/$func/g;
5922 if ($line =~ /\budelay\s*\(\s*(\d+)\s*\)/) {
5924 # ignore udelay's < 10, however
5927 … "usleep_range is preferred over udelay; see Documentation/timers/timers-howto.rst\n" . $herecurr);
5931 "long udelay - prefer mdelay; see arch/arm/include/asm/delay.h\n" . $herecurr);
5935 # warn about unexpectedly long msleep's
5936 if ($line =~ /\bmsleep\s*\((\d+)\);/) {
5939 …"msleep < 20ms can sleep for up to 20ms; see Documentation/timers/timers-howto.rst\n" . $herecurr);
5944 if ($line =~ /\bjiffies\s*$Compare|$Compare\s*jiffies\b/) {
5950 if ($line =~ /\bget_jiffies_64\s*\(\s*\)\s*$Compare|$Compare\s*get_jiffies_64\s*\(\s*\)/) {
5956 # if ($line =~ /^.\s*\#\s*if(|n)def/ && ($realfile =~ /\.c$/)) {
5963 if ($line =~ /^.\s*\#\s*(ifdef|ifndef|elif)\s\s+/) {
5968 s/^(.\s*\#\s*(ifdef|ifndef|elif))\s{2,}/$1 /;
5974 if ($line =~ /^.\s*(struct\s+mutex|spinlock_t)\s+\S+;/ ||
5975 $line =~ /^.\s*(DEFINE_MUTEX)\s*\(/) {
6003 if ($line =~ /\b(?:$all_barriers)\s*\(/) {
6012 if ($realfile !~ m@^include/asm-generic/@ &&
6014 $line =~ m/\b(?:$underscore_smp_barriers)\s*\(/ &&
6015 $line !~ m/^.\s*\#\s*define\s+(?:$underscore_smp_barriers)\s*\(/) {
6017 "__smp memory barriers shouldn't be used outside barrier.h and asm-generic\n" . $herecurr);
6021 if ($line =~ /\bwaitqueue_active\s*\(/) {
6029 if ($line =~ /\bdata_race\s*\(/) {
6037 …if ($line =~ m@^.\s*\#\s*if.*\b(__i386__|__powerpc64__|__sun__|__s390x__)\b@ && $realfile !~ m@inc…
6043 if ($line =~ /\b($Type)\s+($Storage)\b/) {
6049 $line !~ /^.\s*$Storage/ &&
6050 $line =~ /^.\s*(.+?)\$Storage\s/ &&
6051 $1 !~ /[\,\)]\s*$/) {
6058 if ($line =~ /\b$Type\s+$Inline\b/ ||
6059 $line =~ /\b$Inline\s+$Storage\b/) {
6070 $fixed[$fixlinenr] =~ s/\b(__inline__|__inline)\b/inline/;
6077 $line =~ /\b__attribute__\s*\(\s*\(.*\bpacked\b/) {
6084 $line =~ /\b__attribute__\s*\(\s*\(.*aligned/) {
6091 $line =~ /\b__attribute__\s*\(\s*\(.*_*section_*\s*\(\s*("[^"]*")/) {
6092 my $old = substr($rawline, $-[1], $+[1] - $-[1]);
6093 my $new = substr($old, 1, -1);
6097 …$fixed[$fixlinenr] =~ s/\b__attribute__\s*\(\s*\(\s*_*section_*\s*\(\s*\Q$old\E\s*\)\s*\)\s*\)/__s…
6103 $line =~ /\b__attribute__\s*\(\s*\(\s*format\s*\(\s*printf/) {
6105 …"__printf(string-index, first-to-check) is preferred over __attribute__((format(printf, string-ind…
6107 …$fixed[$fixlinenr] =~ s/\b__attribute__\s*\(\s*\(\s*format\s*\(\s*printf\s*,\s*(.*)\)\s*\)\s*\)/"_…
6114 $line =~ /\b__attribute__\s*\(\s*\(\s*format\s*\(\s*scanf\b/) {
6116 …"__scanf(string-index, first-to-check) is preferred over __attribute__((format(scanf, string-index…
6118 …$fixed[$fixlinenr] =~ s/\b__attribute__\s*\(\s*\(\s*format\s*\(\s*scanf\s*,\s*(.*)\)\s*\)\s*\)/"__…
6124 … $line =~ /(?:$Declare|$DeclareMisordered)\s*$Ident\s*$balanced_parens\s*(?:$Attribute)?\s*;/ &&
6125 ($line =~ /\b__attribute__\s*\(\s*\(.*\bweak\b/ ||
6133 $line =~ /\b($Declare)\s*$Ident\s*[=;,\[]/) {
6138 $kernel_type = 's' if ($type =~ /^_*[si]/);
6144 $fixed[$fixlinenr] =~ s/\b$type\b/$kernel_type/;
6150 if ($line =~ /(\(\s*$C90_int_types\s*\)\s*)($Constant)\b/) {
6158 $newconst =~ s/${Int_type}$//;
6160 if ($cast =~ /\blong\s+long\b/) {
6165 $fixed[$fixlinenr] =~ s/\Q$cast\E$const\b/$newconst$suffix/;
6170 if ($line =~ /\bsizeof\s*\(\s*\&/) {
6176 if ($line =~ /\bsizeof\s+((?:\*\s*|)$Lval|$Type(?:\s+$Lval|))/) {
6180 …$fixed[$fixlinenr] =~ s/\bsizeof\s+((?:\*\s*|)$Lval|$Type(?:\s+$Lval|))/"sizeof(" . trim($1) . ")"…
6185 if ($line =~ /^.\s*\bstruct\s+spinlock\s+\w+\s*;/) {
6191 if ($sline =~ /\bseq_printf\s*\(.*"\s*\)\s*;\s*$/) {
6193 $fmt =~ s/%%//g;
6198 $fixed[$fixlinenr] =~ s/\bseq_printf\b/seq_puts/;
6206 $stat =~ /^\+(?![^\{]*\{\s*).*\b(\w+)\s*\(.*$String\s*,/s &&
6217 my $fmt = get_quoted_string($lines[$count - 1], raw_line($count, 0));
6218 $fmt =~ s/%%//g;
6243 $use = " - use %pS instead";
6244 $use =~ s/pS/ps/ if ($bad_specifier =~ /pf/);
6256 $stat =~ /^\+(?:.*?)\bmemset\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\,\s*$FuncArg\s*\)/) {
6264 "memset to 0's uses 0 as the 2nd argument, not the 3rd\n" . "$here\n$stat\n");
6274 # $stat =~ /^\+(?:.*?)\bmemcpy\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\,\s*ETH_ALEN\s*\)/) {
6278 # $fixed[$fixlinenr] =~ s/\bmemcpy\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\,\s*ETH_ALEN\s*\)/ether_add…
6285 # $stat =~ /^\+(?:.*?)\bmemcmp\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\,\s*ETH_ALEN\s*\)/) {
6294 # $stat =~ /^\+(?:.*?)\bmemset\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\,\s*ETH_ALEN\s*\)/) {
6302 # $fixed[$fixlinenr] =~ s/\bmemset\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*,\s*ETH_ALEN\s*\)/eth_zero_…
6308 # $fixed[$fixlinenr] =~ s/\bmemset\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*,\s*ETH_ALEN\s*\)/eth_broad…
6316 $stat =~ /^\+(?:.*?)\b(min|max)\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\)/) {
6340 $stat =~ /^\+(?:.*?)\busleep_range\s*\(\s*($FuncArg)\s*,\s*($FuncArg)\s*\)/) {
6345 …"usleep_range should not use min == max args; see Documentation/timers/timers-howto.rst\n" . "$her…
6349 …"usleep_range args reversed, use min then max; see Documentation/timers/timers-howto.rst\n" . "$he…
6357 ($stat !~ /$Ident\s*=\s*sscanf\s*$balanced_parens/ &&
6358 $stat !~ /\bsscanf\s*$balanced_parens\s*(?:$Compare)/ &&
6359 $stat !~ /(?:$Compare)\s*\bsscanf\s*$balanced_parens/)) {
6374 if ($stat_real =~ /\bsscanf\b\s*\(\s*$FuncArg\s*,\s*("[^"]+")/) {
6387 $line =~ /^\+\s*(extern\s+)$Type\s*$Ident\s*\(/s) {
6391 $fixed[$fixlinenr] =~ s/(.*)\bextern\b\s*(.*)/$1$2/;
6397 $stat =~ /^.\s*(?:extern\s+)?$Type\s+($Ident)(\s*)\(/s)
6402 my $s = $stat;
6404 substr($s, 0, length($cond), '');
6406 if ($s =~ /^\s*;/)
6418 $stat =~ /^.\s*extern\s+/)
6426 … $stat =~ /^.\s*(?:extern\s+)?$Type\s*(?:$Ident|\(\s*\*\s*$Ident\s*\))\s*\(\s*([^{]+)\s*\)\s*;/s &&
6429 while ($args =~ m/\s*($Type\s*(?:$Ident|\(\s*\*\s*$Ident?\s*\)\s*$balanced_parens)?)/g) {
6431 if ($arg =~ /^$Type$/ && $arg !~ /enum\s+$Ident$/) {
6441 $stat =~ /^.\s*(?:$Storage\s+)?$Type\s*($Ident)\s*$balanced_parens\s*{/s) {
6461 # checks for new __setup's
6467 …"__setup appears un-documented -- check Documentation/admin-guide/kernel-parameters.txt\n" . $here…
6472 if ($line =~ /\*\s*\)\s*$allocFunctions\b/) {
6474 … "unnecessary cast may hide bugs, see http://c-faq.com/malloc/mallocnocast.html\n" . $herecurr);
6480 …$line =~ /\b($Lval)\s*\=\s*(?:$balanced_parens)?\s*((?:kv|k|v)[mz]alloc(?:_node)?)\s*\(\s*(sizeof\…
6488 …$stat =~ /^\+\s*($Lval)\s*\=\s*(?:$balanced_parens)?\s*(k[mz]alloc)\s*\(\s*($FuncArg)\s*\*\s*($Fun…
6496 if ($a1 =~ /^sizeof\s*\S/) {
6500 if ($r1 !~ /^sizeof\b/ && $r2 =~ /^sizeof\s*\S/ &&
6501 !($r1 =~ /^$Constant$/ || $r1 =~ /^[A-Z_][A-Z0-9_]*$/)) {
6509 …$fixed[$fixlinenr] =~ s/\b($Lval)\s*\=\s*(?:$balanced_parens)?\s*(k[mz]alloc)\s*\(\s*($FuncArg)\s*…
6516 $line =~ /\b($Lval)\s*\=\s*(?:$balanced_parens)?\s*krealloc\s*\(\s*($Lval)\s*,/ &&
6523 if ($line =~ /\b(kcalloc|kmalloc_array)\s*\(\s*sizeof\b/) {
6529 if ($line =~ /;\s*;\s*$/) {
6533 $fixed[$fixlinenr] =~ s/(\s*;\s*){2,}$/;/g;
6539 $line =~ /#\s*define\s+\w+\s+\(?\s*1\s*([ulUL]*)\s*\<\<\s*(?:\d+|$Ident)\s*\)?/) {
6545 $fixed[$fixlinenr] =~ s/\(?\s*1\s*[ulUL]*\s*<<\s*(\d+|$Ident)\s*\)?/BIT${ull}($1)/;
6551 if ($line =~ /#\s*define\s+$api_defines/) {
6553 "do not specify a non-Zephyr API for libc\n" . "$here$rawline\n");
6557 if ($rawline =~ /\bIS_ENABLED\s*\(\s*(\w+)\s*\)/ && $1 !~ /^CONFIG_/) {
6563 …if ($line =~ /^\+\s*#\s*if\s+defined(?:\s*\(?\s*|\s+)(CONFIG_[A-Z_]+)\s*\)?\s*\|\|\s*defined(?:\s*…
6575 $stat =~ /^\+[$;\s]*(?:case[$;\s]+\w+[$;\s]*:[$;\s]*|)*[$;\s]*\bdefault[$;\s]*:[$;\s]*;/g) {
6588 $fixed[$fixlinenr] =~ s/\b__FUNCTION__\b/__func__/g;
6595 "Use of the '$1' macro makes the build non-deterministic\n" . $herecurr);
6605 if ($line =~ /\byield\s*\(\s*\)/) {
6607 "Using yield() is generally wrong. See yield() kernel-doc (sched/core.c)\n" . $herecurr);
6611 if ($line =~ /\+\s*(.*?)\b(true|false|$Lval)\s*(==|\!=)\s*(true|false|$Lval)\b(.*)$/i) {
6638 if ($line =~ /^.\s*sema_init.+,\W?0\W?\)/) {
6644 if ($line =~ /\b((simple|strict)_(strto(l|ll|ul|ull)))\s*\(/) {
6650 if ($line =~ /^.\s*__initcall\s*\(/) {
6662 if ($line =~ /\b($deprecated_apis_search)\b\s*\(/) {
6673 $line =~ /\bstruct\s+($const_structs)\b(?!\s*\{)/) {
6681 $line !~ /^.\s*\s*#\s*if\b.*\bNR_CPUS\b/ &&
6682 $line !~ /^.\s*\s*#\s*define\b.*\bNR_CPUS\b/ &&
6683 $line !~ /^.\s*$Declare\s.*\[[^\]]*NR_CPUS[^\]]*\]/ &&
6688 …"usage of NR_CPUS is often wrong - consider using cpu_possible(), num_possible_cpus(), for_each_po…
6692 if ($line =~ /\+\s*#\s*define\s+((?:__)?ARCH_(?:HAS|HAVE)\w*)\b/) {
6694 … "#define of '$1' is wrong - use Kconfig variables or standard guards instead\n" . $herecurr);
6699 $line =~ /\b((?:un)?likely)\s*\(\s*$FuncArg\s*\)\s*$Compare/) {
6705 if ($line =~ /\b(?:(?:un)?likely)\s*\(\s*!?\s*(IS_ERR(?:_OR_NULL|_VALUE)?|WARN)/) {
6711 if ($line =~ /\bin_atomic\s*\(/) {
6728 if ($line =~ /^.\s*lockdep_set_novalidate_class\s*\(/ ||
6729 $line =~ /__lockdep_no_validate__\s*\)/ ) {
6734 "lockdep_no_validate class is reserved for device->mutex.\n" . $herecurr);
6749 … =~ /\bDEVICE_ATTR\s*\(\s*(\w+)\s*,\s*\(?\s*(\s*(?:${multi_mode_perms_string_search}|0[0-7]{3,3})\…
6761 …$fixed[$fixlinenr] =~ s/\bDEVICE_ATTR\s*\(\s*$var\s*,\s*\Q$perms\E\s*,\s*$show\s*,\s*$store\s*\)/D…
6769 …$fixed[$fixlinenr] =~ s/\bDEVICE_ATTR\s*\(\s*$var\s*,\s*\Q$perms\E\s*,\s*$show\s*,\s*NULL\s*\)/DEV…
6777 …$fixed[$fixlinenr] =~ s/\bDEVICE_ATTR\s*\(\s*$var\s*,\s*\Q$perms\E\s*,\s*NULL\s*,\s*$store\s*\)/DE…
6794 "Consider renaming function(s)$rename\n" . $herecurr);
6811 my $func = $entry->[0];
6812 my $arg_pos = $entry->[1];
6820 $arg_pos--;
6821 $skip_args = "(?:\\s*$FuncArg\\s*,\\s*){$arg_pos,$arg_pos}";
6823 my $test = "\\b$func\\s*\\(${skip_args}($FuncArg(?:\\|\\s*$FuncArg)*)\\s*[,\\)]";
6848 $fixed[$fixlinenr] =~ s/\Q$oval\E/$octal/;
6853 if ($line =~ /\bMODULE_LICENSE\s*\(\s*($String)\s*\)/) {
6871 if ($line =~ /\.extra[12]\s*=\s*&(zero|one|int_max)\b/) {
6879 if ($#rawlines == -1) {
6889 # This is not a patch, and we are are in 'no-patch' mode so
6895 if (!$is_patch && $filename !~ /cover-letter\.patch$/) {
6897 "Does not appear to be a unified-diff format patch\n");
6902 "Missing Signed-off-by: line(s)\n");
6905 "Missing Signed-off-by: line by nominal patch author '$author'\n");
6923 mechanically convert to the typical style using --fix or --fix-inplace.
6942 $newfile .= ".EXPERIMENTAL-checkpatch-fixes" if (!$fix_inplace);
6954 $fixed_line =~ s/^\+//;
6966 Wrote EXPERIMENTAL --fix correction(s) to '$newfile'