Lines Matching +full:a +full:- +full:za +full:- +full:z

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>
66 my $allow_c99_comments = 1; # Can be overridden by --ignore C99_COMMENT_TOLERANCE
68 my $git_command ='export LANGUAGE=en_US.UTF-8; git';
80 -q, --quiet quiet
81 --no-tree run without a kernel tree
82 --no-signoff do not check for 'Signed-off-by' line
83 --patch treat FILE as patchfile (default)
84 --emacs emacs compile window format
85 --terse one line per report
86 --showfile emit diffed file position, not input file position
87 -g, --git treat FILE as a single commit or git revision range
95 <rev>-<count>
97 -f, --file treat FILE as regular source file
98 --subjective, --strict enable more subjective tests
99 --list-types list the possible message types
100 --types TYPE(,TYPE2...) show only these comma separated message types
101 --ignore TYPE(,TYPE2...) ignore various comma separated message types
102 --show-types show the specific message type in the output
103 --max-line-length=n set the maximum line length, (default $max_line_length)
105 requires --strict for use with --file
106 --min-conf-desc-length=n set the min description length, if shorter, warn
107 --tab-size=n set the number of spaces for tab (default $tabsize)
108 --root=PATH PATH to the kernel tree root
109 --no-summary suppress the per-file summary
110 --mailback only produce a report in case of warnings/errors
111 --summary-file include the filename in summary
112 --debug KEY=[0|1] turn on/off debugging of KEY, where KEY is one of
115 --test-only=WORD report only warnings/errors containing WORD
117 --fix EXPERIMENTAL - may create horrible results
118 If correctable single-line errors exist, create
119 "<inputfile>.EXPERIMENTAL-checkpatch-fixes"
122 --fix-inplace EXPERIMENTAL - may create horrible results
123 Is the same as --fix, but overwrites the input
125 --ignore-perl-version override checking of perl version. expect
127 --codespell Use the codespell dictionary for spelling/typos
129 --codespellfile Use this codespell dictionary
130 --typedefsfile Read additional types from this file
131 --color[=WHEN] Use colors 'always', 'never', or only when output
132 is a terminal ('auto'). Default is 'auto'.
133 --kconfig-prefix=WORD use WORD as a prefix for Kconfig symbols (default
135 -h, --help, --version display this help and exit
137 When FILE is - read standard input.
162 # Also catch when type or level is passed through a variable
176 if (-f $conf) {
179 or warn "$P: Can't find a readable $configuration_file file $!\n";
201 # Perl's Getopt::Long allows options to take optional arguments after a space.
202 # Prevent --color by itself from consuming other arguments
204 if ($_ eq "--color" || $_ eq "-color") {
205 $_ = "--color=$color";
223 'show-types!' => \$show_types,
224 'list-types!' => \$list_types,
225 'max-line-length=i' => \$max_line_length,
226 'min-conf-desc-length=i' => \$min_conf_desc_length,
227 'tab-size=i' => \$tabsize,
231 'summary-file!' => \$summary_file,
233 'fix-inplace!' => \$fix_inplace,
234 'ignore-perl-version!' => \$ignore_perl_version,
236 'test-only=s' => \$tst_only,
241 'no-color' => \$color, #keep old behaviors of -nocolor
242 'nocolor' => \$color, #keep old behaviors of -nocolor
243 'kconfig-prefix=s' => \${CONFIG_},
255 die "$P: --git cannot be used with --file or --fix\n" if ($git && ($file || $fix));
266 #if no filenames are given, push '-' to read patch from stdin
268 push(@ARGV, '-');
278 $color = (-t STDOUT);
283 # skip TAB size 1 to avoid additional checks on $tabsize - 1
294 $word =~ tr/[a-z]/[A-Z]/;
299 $hashRef->{$word}++;
338 die "$P: $root: --root does not point at a valid tree\n";
350 print "Must be run from the top-level dir. of a kernel tree\n";
358 [A-Za-z_][A-Za-z\d_]*
359 (?:\s*\#\#\s*[A-Za-z_][A-Za-z\d_]*)*
382 # We need \b after 'init' otherwise 'initconst' will cause a false positive in a check
411 our $Member = qr{->$Ident|\.$Ident|\[[^]]*\]};
416 our $Hex = qr{(?i)0x[0-9a-f]+$Int_type?};
417 our $Int = qr{[0-9]+$Int_type?};
418 our $Octal = qr{0[0-7]+$Int_type?};
420 our $Float_hex = qr{(?i)0x[0-9a-f]+p-?[0-9]+[fl]?};
421 our $Float_dec = qr{(?i)(?:[0-9]+\.[0-9]*|[0-9]*\.[0-9]+)(?:e-?[0-9]+)?[fl]?};
422 our $Float_int = qr{(?i)[0-9]+e-?[0-9]+[fl]?};
425 our $Assignment = qr{\*\=|/=|%=|\+=|-=|<<=|>>=|&=|\^=|\|=|=};
426 our $Compare = qr{<=|>=|==|!=|<|(?<!-)>};
427 our $Arithmetic = qr{\+|-|\*|\/|%};
430 =>|->|<<|>>|<|>|!|~|
431 &&|\|\||,|\^|\+\+|--|&|\||$Arithmetic
446 [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte
447 | \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs
448 | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte
449 | \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates
450 | \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3
451 | [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15
452 | \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16
456 [\x09\x0A\x0D\x20-\x7E] # ASCII
479 …(?:[a-z0-9]+_){1,2}(?:printk|emerg|alert|crit|err|warning|warn|notice|info|debug|dbg|vdbg|devel|co…
483 MODULE_[A-Z_]+|
498 Signed-off-by:|
499 Co-developed-by:|
500 Acked-by:|
501 Tested-by:|
502 Reviewed-by:|
503 Reported-by:|
504 Suggested-by:|
591 ["IIO_DEV_ATTR_[A-Z_]+", 1],
597 my $word_pattern = '\b[A-Z]?[a-z]{2,}\b';
599 #Create a search pattern for all these functions to speed up a loop below
603 $mode_perms_search .= $entry->[0];
620 #Create a search pattern for all these strings to speed up a loop below
633 0[0-7][0-7][2367]
655 #Create a search pattern for all these strings to speed up a loop below
670 return trim($string) if ($string =~ /^\s*0[0-7]{3,3}\s*$/);
681 last if ($lastpos > 0 && ($curpos - length($omatch) != $lastpos));
699 # memory.h: ARM has a custom one
721 warn "No typos will be found - file '$spelling_file': $!\n";
738 my ($suspect, $fix) = split(/->/, $line);
744 warn "No codespell typos will be found - file '$codespellfile': $!\n";
763 print("$file: '$line' invalid - ignored\n");
780 or warn "No structs that should be const will be found - file '$conststructsfile': $!\n";
786 or warn "No additional types will be considered - file '$typedefsfile': $!\n";
846 our $balanced_parens = qr/(\((?:[^\(\)]++|(?-1))*\))/;
851 (?:$Storage\s+)?(?:[A-Z_][A-Z0-9]*_){0,2}(?:DEFINE|DECLARE)(?:_[A-Z0-9]+){1,6}\s*\(|
873 return if (!(-f $file));
885 next if ($line !~ /(?:[A-Z][a-z]|[a-z][A-Z])/);
886 if ($line =~ /^[ \t]*(?:#[ \t]*define|typedef\s+$Type)\s+(\w*(?:[A-Z][a-z]|[a-z][A-Z])\w*)/) {
888 } elsif ($line =~ /^\s*$Declare\s+(\w*(?:[A-Z][a-z]|[a-z][A-Z])\w*)\s*[\(\[,;]/) {
890 } elsif ($line =~ /^\s*(?:union|struct|enum)\s+(\w*(?:[A-Z][a-z]|[a-z][A-Z])\w*)\s*[;\{]/) {
901 return 0 if (!$tree || !(-e "$root/scripts/get_maintainer.pl"));
904 …s{$filename} = `perl $root/scripts/get_maintainer.pl --status --nom --nol --nogit --nogit-fallback…
913 …return 1 if (!$tree || which("python") eq "" || !(-e "$root/scripts/spdxcheck.py") || !(-e "$gitro…
916 my $status = `cd "$root_path"; echo "$license" | python scripts/spdxcheck.py -`;
931 if (-e "$gitroot") {
932 …my $git_last_include_commit = `${git_command} log --no-merges --pretty=format:"%h%n" -1 -- include…
934 $camelcase_cache = ".checkpatch-camelcase.git.$git_last_include_commit";
937 $files = `find $root/include -name "*.h"`;
944 $camelcase_cache = ".checkpatch-camelcase.date.$last_mod_date";
947 if ($camelcase_cache ne "" && -f $camelcase_cache) {
959 if (-e "$gitroot") {
960 $files = `${git_command} ls-files "include/*.h"`;
969 unlink glob ".checkpatch-camelcase.*";
972 foreach (sort { lc($a) cmp lc($b) } keys(%camelcase)) {
982 return 0 if ((which("git") eq "") || !(-e "$gitroot"));
984 my $output = `${git_command} ls-files -- $filename 2>/dev/null`;
992 return ($id, $desc) if ((which("git") eq "") || !(-e "$gitroot"));
994 my $output = `${git_command} log --no-color --format='%H %s' -1 $commit 2>&1`;
1005 # git rev-list --remotes | grep -i "^$1" |
1007 # git log --format='%H %s' -1 $line |
1008 # echo "commit $(cut -c 1-12,41-)"
1027 my $fixlinenr = -1;
1030 # For example, HEAD-3 means we need check 'HEAD, HEAD~1, HEAD~2'.
1031 die "$P: No git repository found\n" if ($git && !-e "$gitroot");
1037 if ($commit_expr =~ m/^(.*)-(\d+)$/) {
1038 $git_range = "-$2 $1";
1042 $git_range = "-1 $commit_expr";
1044 my $lines = `${git_command} log --no-color --no-merges --pretty=format:'%H %s' $git_range`;
1046 $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;
1144 if (! -e $root . '/' . $check) {
1173 # If there's a name left after stripping spaces and
1195 if ($name =~ /[^\w \-]/i) { ##has "must quote" chars
1214 if ($name =~ /[^\w \-]/i) { ##has "must quote" chars
1255 if (-e "$path/$bin") {
1267 if (-e "$path/$conf") {
1363 # A \ in a string means ignore the next character.
1398 # The pathname on a #include may be surrounded by '<' and '>'.
1403 # The whole of a #error is a string.
1422 return substr($rawline, $-[0], $+[0] - $-[0]);
1427 my $line = $linenr - 1;
1430 my $coff = $off - 1;
1444 @stack = (['', 0]) if ($#stack == -1);
1452 next if ($lines[$line] =~ /^-/);
1453 $remain--;
1480 ($type, $level) = @{$stack[$#stack - 1]};
1485 # Statement ends at the ';' or a close '}' at the
1491 # An else is really a conditional as long as its not else if
1496 $coff = $off + length($1) - 1;
1499 #warn "[" . substr($blk, $soff, $coff - $soff + 1) . "]\n";
1507 $level--;
1521 $level--;
1533 $level--;
1544 $remain--;
1547 my $statement = substr($blk, $soff, $off - $soff + 1);
1548 my $condition = substr($blk, $soff, $coff - $soff + 1);
1556 $line, $remain + 1, $off - $loff + 1, $level);
1613 if (!($remain > 0 && $condition =~ /^\s*(?:\n[+-])?\s*(?:if|else|do)\b/s)) {
1623 last if (!($remain > 0 && $condition =~ /^(?:\s*\n[+-])*\s*(?:else|do)\b/s));
1634 my $start = $linenr - 1;
1643 next if ($rawlines[$line] =~ /^-/);
1644 $remain--;
1652 $level = $stack[$#stack - 1];
1660 $off--;
1665 $level--;
1714 my ($current_comment) = ($rawlines[$end_line - 1] =~ m@^\+.*(//.*$)@);
1716 ($current_comment) = ($rawlines[$end_line - 2] =~ m@^[\+ ].*(//.*$)@);
1721 # Catch a comment on the end of the line itself.
1722 ($current_comment) = ($rawlines[$end_line - 1] =~ m@.*(/\*.*\*/)\s*(?:\\\s*)?$@);
1725 # Look through the context and try and figure out if there is a
1730 my $line = $rawlines[$linenr - 1];
1754 ##print "LINE: $rawlines[$end_line - 1 ]\n";
1763 my $offset = $linenr - 1;
1769 next if (defined($line) && $line =~ /^-/);
1770 $cnt--;
1940 print "PAREN('$1') -> $type\n"
1996 } elsif ($cur =~ /^(-(?![->])|\+(?!\+)|\*|\&\&|\&)/o) {
2011 if ($1 ne '++' && $1 ne '--') {
2079 $type =~ tr/[a-z]/[A-Z]/;
2112 my @lines = split("\n", $output, -1);
2130 if ($$lineRef =~ /^\@\@ -\d+,\d+ \+(\d+),(\d+) \@\@/) {
2159 if ($line =~ /^(?:\+\+\+|\-\-\-)\s+\S+/) { #new filename
2161 } elsif ($line =~ /^\@\@ -\d+,\d+ \+\d+,\d+ \@\@/) { #new hunk
2169 fixup_current_range(\$lines[$range_last_linenr], $delta_offset--, -1);
2248 # See if any suffix of this path is a path within the tree.
2250 if (-f "$root/$file") {
2255 if (! -f _) {
2261 substr($prefix, -length($file)) = '';
2306 my $max_spaces_before_tab = $source_indent - 1;
2311 #Remove spaces before a tab
2328 return -1;
2336 $pos += length($1) - 1;
2339 } elsif (index($string, '(') == -1) {
2351 for my $i (0 .. (length($line) - 1)) {
2380 my $is_binding_patch = -1;
2383 my $has_patch_separator = 0; #Found a --- line
2393 my $last_coalesced_string_linenr = -1;
2406 my $context_function; #undef'd unless there's a known function
2422 # Pre-scan the patch sanitizing the lines.
2423 # Pre-scan the patch looking for any __setup documentation.
2442 if ($1 =~ m@Documentation/admin-guide/kernel-parameters.txt$@) {
2447 if ($rawline =~ /^\@\@ -\d+(?:,\d+)? \+(\d+)(,(\d+))? \@\@/) {
2448 $realline=$1-1;
2456 # Guestimate if this is a continuing comment. Run
2457 # the context looking for a comment "edge". If this
2458 # edge is a close comment then we must be in a comment
2463 next if (defined $rawlines[$ln - 1] &&
2464 $rawlines[$ln - 1] =~ /^-/);
2465 $cnt--;
2466 #print "RAW<$rawlines[$ln - 1]>\n";
2467 last if (!defined $rawlines[$ln - 1]);
2468 if ($rawlines[$ln - 1] =~ m@(/\*|\*/)@ &&
2469 $rawlines[$ln - 1] !~ m@"[^"]*(?:/\*|\*/)[^"]*"@) {
2478 # Guestimate if this is a continuing comment. If this
2479 # is the start of a diff block and this line starts
2480 # ' *' then it is very likely a comment.
2492 # simplify matching -- only bother with positive lines.
2498 $realcnt-- if ($line =~ /^(?:\+| |$)/);
2504 #print "-->$line\n";
2515 $fixlinenr = -1;
2522 my $rawline = $rawlines[$linenr - 1];
2525 # check if it's a mode change, rename or start of a patch
2527 ($line =~ /^ mode change [0-7]+ => [0-7]+ \S+\s*$/ ||
2529 $line =~ /^diff --git a\/[\w\/\.\_\-]+ b\/\S+\s*$/))) {
2535 $line =~ /^\@\@ -\d+(?:,\d+)? \+(\d+)(,(\d+))? \@\@(.*)/) {
2539 $realline=$1-1;
2564 $realcnt-- if ($realcnt != 0);
2577 $realcnt--;
2587 if ($line =~ /^diff --git.*?(\S+)$/) {
2599 -e "$root/$p1_prefix") {
2601 "patch prefix '$p1_prefix' exists, appears to be a -p0 patch\n");
2606 …"do not modify files in include/asm, change architecture specific files in include/asm-<architectu…
2637 $is_binding_patch = () = $realfile =~ m@^(?:Documentation/devicetree/|include/dt-bindings/)@;
2639 if (($last_binding_patch != -1) &&
2642 …"DT binding docs and includes should be a separate patch. See: Documentation/devicetree/bindings/s…
2657 # Verify the existence of a commit log if appropriate
2658 # 2 is used because a $signature is counted in $commit_log_lines
2661 $commit_log_lines++; #could be a $signature
2665 "Missing commit description - Add an appropriate one\n");
2669 # Check if the commit log has what seems like a diff which can confuse patch
2671 (($line =~ m@^\s+diff\b.*a/([\w/]+)@ &&
2672 $line =~ m@^\s+diff\b.*a/[\w/]+\s+b/$1\b@) ||
2673 $line =~ m@^\s*(?:\-\-\-\s+a/|\+\+\+\s+b/)@ ||
2674 $line =~ m/^\s*\@\@ \-\d+,\d+ \+\d+,\d+ \@\@/)) {
2676 "Avoid using diff content in the commit message - patch(1) might not work\n" . $herecurr);
2690 # Check the patch for a From:
2691 if (decode("MIME-Header", $line) =~ /^From:\s*(.*)/) {
2697 $author = encode("utf8", $author) if ($line =~ /=\?utf-8\?/i);
2702 # Check the patch for a signoff:
2703 if ($line =~ /^\s*signed-off-by:\s*(.*)/i) {
2742 if ($line =~ /^---$/) {
2755 $line =~ /^(\s*)([a-z0-9_-]+by:|$signature_tags)(\s*)(.*)/i) {
2764 "Non-standard signature: $sign_off\n" . $herecurr);
2774 if ($sign_off =~ /-by:$/i && $sign_off ne $ucfirst_sign_off) {
2785 "Use a single space after $ucfirst_sign_off\n" . $herecurr) &&
2820 # Check Co-developed-by: immediately followed by Signed-off-by: with same name and email
2821 if ($sign_off =~ /^co-developed-by:$/i) {
2824 …"Co-developed-by: should not be used to attribute nominal patch author '$author'\n" . "$here\n" . …
2828 … "Co-developed-by: must be immediately followed by Signed-off-by:\n" . "$here\n" . $rawline);
2829 } elsif ($rawlines[$linenr] !~ /^\s*signed-off-by:\s*(.*)/i) {
2831 …"Co-developed-by: must be immediately followed by Signed-off-by:\n" . "$here\n" . $rawline . "\n" …
2834 …"Co-developed-by and Signed-off-by: name/email do not match \n" . "$here\n" . $rawline . "\n" .$ra…
2843 "A patch subject line should describe the change not the tool that found it\n" . $herecurr);
2846 # Check for Gerrit Change-Ids not in any patch context
2847 if ($realfile eq '' && !$has_patch_separator && $line =~ /^\s*change-id:/i) {
2849 "Remove Gerrit Change-Id's before submitting upstream\n" . $herecurr);
2852 # Check if the commit log is in a possible stack dump
2857 $line =~ /^\s*\[\<[0-9a-fA-F]{8,}\>\]/) ||
2858 $line =~ /^(?:\s+\w+:\s+[0-9a-fA-F]+){3,3}/ ||
2859 $line =~ /^\s*\#\d+\s*\[[0-9a-fA-F]+\]\s*\w+ at [0-9a-fA-F]+/) {
2867 !($line =~ /^\s*[a-zA-Z0-9_\/\.]+\s+\|\s+\d+/ ||
2869 $line =~ /^\s*(?:[\w\.\-]+\/)++[\w\.\-]+:/ ||
2872 # A Fixes: or Link: line
2875 "Possible unwrapped commit description (prefer a maximum 75 chars per line)\n" . $herecurr);
2879 # Reset possible stack dump if a blank line is found
2887 $line !~ /^\s*(?:Link|Patchwork|http|https|BugLink|base-commit):/i &&
2888 $line !~ /^This reverts commit [0-9a-f]{7,40}/ &&
2889 ($line =~ /\bcommit\s+[0-9a-f]{5,}\b/i ||
2890 ($line =~ /(?:\s|^)[0-9a-f]{12,40}(?:[\s"'\(\[]|$)/i &&
2891 $line !~ /[\<\[][0-9a-f]{12,40}[\>\]]/i &&
2892 $line !~ /\bfixes:\s*[0-9a-f]{12,40}/i))) {
2905 if ($line =~ /\b(c)ommit\s+([0-9a-f]{5,})\b/i) {
2908 } elsif ($line =~ /\b([0-9a-f]{12,40})\b/i) {
2912 $short = 0 if ($line =~ /\bcommit\s+[0-9a-f]{12,40}/i);
2913 $long = 1 if ($line =~ /\bcommit\s+[0-9a-f]{41,}/i);
2914 $space = 0 if ($line =~ /\bcommit [0-9a-f]/i);
2915 $case = 0 if ($line =~ /\b[Cc]ommit\s+[0-9a-f]{5,40}[^A-F]/);
2916 if ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("([^"]+)"\)/i) {
2919 } elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s*$/i &&
2924 } elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("[^"]+$/i &&
2927 $line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("([^"]+)$/i;
2940 …it commit description style 'commit <12+ chars of sha1> (\"<title line>\")' - ie: '${init_char}omm…
2947 $line =~ /^rename (?:from|to) [\w\/\.\-]+\s*$/ ||
2948 ($line =~ /\{\s*([\w\/\.\-]*)\s*\=\>\s*([\w\/\.\-]*)\s*\}/ &&
2961 … "DT bindings should be in DT schema format. See: Documentation/devicetree/writing-schema.rst\n");
2964 # Check for wrappage within a valid hunk of the file
2965 if ($realcnt != 0 && $line !~ m{^(?:\+|-| |\\ No newline|$)}) {
2971 # UTF-8 regex found at http://www.w3.org/International/questions/qa-forms-utf-8.en.php
2981 "Invalid UTF-8, patch and commit message should be encoded in UTF-8\n" . $hereptr);
2984 # Check if it's the start of a commit log
2985 # (not a header line and we haven't seen the patch filename)
2988 $rawline =~ /^(?:commit\b|from\b|[\w-]+:)/i)) {
2994 # Check if there is UTF-8 in a commit log when a mail header has explicitly
2997 $rawline =~ /^Content-Type:.+charset="(.+)".*$/ &&
2998 $1 !~ /utf-8/i) {
3005 "8-bit UTF-8 used in possible commit log\n" . $herecurr);
3025 while ($rawline =~ /(?:^|[^a-z@])($misspellings)(?:\b|$|[^a-z@])/gi) {
3028 $typo_fix = ucfirst($typo_fix) if ($typo =~ /^[A-Z]/);
3029 $typo_fix = uc($typo_fix) if ($typo =~ /^[A-Z]+$/);
3033 "'$typo' may be misspelled - perhaps '$typo_fix'?\n" . $herecurr) &&
3035 $fixed[$fixlinenr] =~ s/(^|[^A-Za-z@])($typo)($|[^A-Za-z@])/$1$typo_fix$3/;
3041 if ($in_commit_log && $line =~ /(^fixes:|\bcommit)\s+([0-9a-f]{6,40})\b/i) {
3051 # check for repeated words separated by a single space
3073 # if it's a repeated word on consecutive lines in a comment block
3087 # ignore non-hunk lines and lines being removed
3088 next if (!$hunk_line || $line =~ /^-/);
3118 … changed addresses in the past, and may do so again. Linux already includes a copy of the GPL.\n" …
3121 # check for Kconfig help text having a real description
3126 # Kconfig supports named choices), so use a word boundary
3127 # (\b) rather than a whitespace character (\s)
3135 for (; $cnt > 0 && defined $lines[$ln - 1]; $ln++) {
3136 $f = $lines[$ln - 1];
3137 $cnt-- if ($lines[$ln - 1] !~ /^-/);
3138 $is_end = $lines[$ln - 1] =~ /^\+/;
3140 next if ($f =~ /^-/);
3143 if ($lines[$ln - 1] =~ /^\+\s*(?:bool|tristate|prompt)\s*["']/) {
3145 } elsif ($lines[$ln - 1] =~ /^\+\s*(?:---)?help(?:---)?$/) {
3146 $length = -1;
3167 "please write a paragraph that describes the config symbol fully\n" . $herecurr);
3175 if ($rawline =~ /^\+[A-Z]:/ &&
3176 $rawline !~ /^\+[A-Z]:\t\S/) {
3180 $fixed[$fixlinenr] =~ s/^(\+[A-Z]):\s*/$1:\t/;
3185 if ($rawline =~ /^\+[A-Z]:/ &&
3186 $prevrawline =~ /^[\+ ][A-Z]:/) {
3187 $rawline =~ /^\+([A-Z]):\s*(.*)/;
3190 $prevrawline =~ /^[\+ ]([A-Z]):\s*(.*)/;
3201 "Misordered MAINTAINERS entry - list '$cur:' before '$prev:'\n" . $hereprev);
3206 "Misordered MAINTAINERS entry - list file patterns in alphabetic order\n" . $hereprev);
3220 ($line =~ /\+(EXTRA_[A-Z]+FLAGS).*/)) {
3223 'EXTRA_AFLAGS' => 'asflags-y',
3224 'EXTRA_CFLAGS' => 'ccflags-y',
3225 'EXTRA_CPPFLAGS' => 'cppflags-y',
3226 'EXTRA_LDFLAGS' => 'ldflags-y',
3230 … of $flag is deprecated, please use \`$replacement->{$flag} instead.\n" . $herecurr) if ($replacem…
3238 my @compats = $rawline =~ /\"([a-zA-Z0-9\-\,\.\+_]+)\"/g;
3241 my $vp_file = $dt_path . "vendor-prefixes.yaml";
3245 $compat2 =~ s/\,[a-zA-Z0-9]*\-/\,<\.\*>\-/;
3247 $compat3 =~ s/\,([a-z]*)[0-9]*\-/\,$1<\.\*>\-/;
3248 `grep -Erq "$compat|$compat2|$compat3" $dt_path`;
3251 "DT compatible string \"$compat\" appears un-documented -- check $dt_path\n" . $herecurr);
3254 next if $compat !~ /^([a-zA-Z0-9\-]+)\,/;
3256 `grep -Eq "\\"\\^\Q$vendor\E,\\.\\*\\":" $vp_file`;
3259 … "DT compatible string vendor \"$vendor\" appears un-documented -- check $vp_file\n" . $herecurr);
3282 $rawline =~ /SPDX-License-Identifier:/ &&
3289 $rawline !~ m@^\+\Q$comment\E SPDX-License-Identifier: @) {
3291 … "Missing or malformed SPDX-License-Identifier tag in line $checklicenseline\n" . $herecurr);
3292 } elsif ($rawline =~ /(SPDX-License-Identifier: .*)/) {
3299 not $spdx_license =~ /GPL-2\.0.*BSD-2-Clause/) {
3304 "DT binding documents should be licensed (GPL-2.0-only OR BSD-2-Clause)\n" . $herecurr) &&
3306 …$fixed[$fixlinenr] =~ s/SPDX-License-Identifier: .*/SPDX-License-Identifier: (GPL-2.0-only OR BSD-
3319 # check we are in a valid source file if not then ignore this hunk
3322 # check for using SPDX-License-Identifier on the wrong line number
3324 $rawline =~ /\bSPDX-License-Identifier:/ &&
3325 substr($line, @-, @+ - @-) eq "$;" x (@+ - @-)) {
3327 "Misplaced SPDX-License-Identifier tag - use line $checklicenseline instead\n" . $herecurr);
3332 # There are a few types of lines that may extend beyond $max_line_length:
3333 # logging functions like pr_info that end in a string
3334 # lines with a single string
3335 # #defines that are a single string
3339 # LONG_LINE_COMMENT a comment starts before but extends beyond $max_line_length
3340 # LONG_LINE_STRING a string starts before but extends beyond $max_line_length
3351 # logging functions that end in a string that starts
3354 length(expand_tabs(substr($line, 1, length($line) - length($1) - 1))) <= $max_line_length) {
3368 # URL ($rawline is used in case the URL is in a comment)
3369 } elsif ($rawline =~ /^\+.*\b[a-z][\w\.\+\-]*:\/\/\S+/i) {
3374 # a comment starts before $max_line_length
3376 length(expand_tabs(substr($line, 1, length($line) - length($1) - 1))) <= $max_line_length) {
3379 # a quoted string starts before $max_line_length
3381 length(expand_tabs(substr($line, 1, length($line) - length($1) - 1))) <= $max_line_length) {
3394 # check for adding lines without a newline.
3397 "adding a line without newline at end of file\n" . $herecurr);
3400 # check we are in a valid source file C or perl if not then ignore this hunk
3403 # at the beginning of a line any tabs must come first and anything
3429 # check for assignments on the start of a line
3435 # check for && or || at the start of a line
3441 # check indentation starts on a tab stop
3447 "Statements should start on a tabstop\n" . $herecurr) &&
3454 # check multi-line statement indentation matches previous line
3485 # avoid checking a few false positives:
3494 "No space is necessary after a cast\n" . $herecurr) &&
3506 …$realline > 3) { # Do not warn about the initial copyright comment block after SPDX-License-Identi…
3527 "Block comments use a trailing */ on a separate line\n" . $herecurr);
3562 $line =~ /^\+[a-z_]*init/ ||
3563 $line =~ /^\+\s*(?:static\s+)?[A-Z_]*ATTR/ ||
3568 "Please use a blank line after function/struct/union/enum declarations\n" . $hereprev) &&
3577 $last_blank_line != ($linenr - 1)) {
3601 # not starting a section or a macro "\" extended line
3603 # looks like a declaration
3622 "Missing a blank line after declarations\n" . $hereprev) &&
3628 # check for spaces at the beginning of a line.
3636 "please, no spaces at the start of a line\n" . $herevet) &&
3642 # check we are in a valid C source file if not then ignore this hunk
3648 "Lines should not end with a '$1'\n" . $herecurr);
3662 # check indentation of any line with a bare else
3663 # (but not if it is a multiple line "if (foo) return bar; else return baz;")
3664 # if the previous line is a break or return and is indented 1 tab more...
3672 "else is not generally useful after a break or return\n" . $hereprev);
3676 # check indentation of a line with a break;
3677 # if the previous line is a goto or return and is indented the same # of tabs
3682 "break is not useful after a goto or return\n" . $hereprev);
3711 # it there is no point in retrying a statement scan
3722 (!defined $lines[$realline_next - 1] ||
3723 substr($lines[$realline_next - 1], $off_next) =~ /^\s*$/)) {
3742 possible($type, "A:" . $s);
3749 # any (foo ... *) is a pointer cast, and foo is a type
3801 # if/while/etc brace do not go on next line, unless defining a do while loop,
3803 …if ($line =~ /(.*)\b((?:if|while|for|switch|(?:[a-z_]+|)for_each[a-z_]+)\s*\(|do\b|else\b)/ && $li…
3810 "Too many leading tabs - consider code refactoring\n" . $herecurr);
3813 my $ctx_cnt = $realcnt - $#ctx - 1;
3820 defined $lines[$ctx_ln - 1] &&
3821 $lines[$ctx_ln - 1] =~ /^-/)) {
3823 $ctx_skip-- if (!defined $lines[$ctx_ln - 1] || $lines[$ctx_ln - 1] !~ /^-/);
3828 #print "pre<$pre_ctx>\nline<$line>\nctx<$ctx>\nnext<$lines[$ctx_ln - 1]>\n";
3830 if ($ctx !~ /{\s*/ && defined($lines[$ctx_ln - 1]) && $lines[$ctx_ln - 1] =~ /^\+\s*{/) {
3833 "$here\n$ctx\n$rawlines[$ctx_ln - 1]\n");
3837 defined $lines[$ctx_ln - 1])
3839 my ($nlength, $nindent) = line_stats($lines[$ctx_ln - 1]);
3843 "$here\n$ctx\n$rawlines[$ctx_ln - 1]\n");
3849 …if ($line =~ /\b(?:(?:if|while|for|(?:[a-z_]+|)for_each[a-z_]+)\s*\(|(?:do|else)\b)/ && $line !~ /…
3890 # Also ignore a loop construct at the end of a
3897 my $cond_ptr = -1;
3960 $prev_values = substr($curr_values, -1);
3968 if ($line =~ /^\+\s*(?:$Declare)?([A-Za-z_][A-Za-z\d_]*)\s*=/) {
3972 "Do not use self-assignments to avoid compiler warnings\n" . $herecurr);
3977 if ($prevline =~ /^\+.*$Lval\s*(?:\.|->)\s*$/ &&
3979 $prevline =~ /($Lval\s*(?:\.|->))\s*$/;
3985 "Avoid multiple line dereference - prefer '$ref'\n" . $hereprev);
4041 fix_delete_line($fixlinenr - 1, $prevrawline);
4065 "No #include in ...include/uapi/... should use a uapi/ path prefix\n" . $herecurr);
4087 #print "APW <$lines[$realline_next - 1]>\n";
4089 exists $lines[$realline_next - 1] &&
4091 ($lines[$realline_next - 1] =~ /EXPORT_SYMBOL.*\((.*)\)/ ||
4092 $lines[$realline_next - 1] =~ /EXPORT_UNUSED_SYMBOL.*\((.*)\)/)) {
4094 # a prefix:
4098 if ($stat =~ /^(?:.\s*}\s*\n)?.([A-Z_]+)\s*\(\s*($Ident)/ &&
4111 #print "FOO A<$lines[$realline_next - 1]> stat<$stat> name<$name>\n";
4121 #print "FOO B <$lines[$linenr - 1]>\n";
4198 # check for const <foo> const where <foo> is not a pointer or array type
4210 # check for non-global char *foo[] = {"bar", ...} declarations.
4233 "Bad function definition - $1() should probably be $1(void)\n" . $herecurr) &&
4256 # Should start with a space.
4258 # Should not end with a space.
4281 # Should start with a space.
4283 # Should not end with a space.
4311 …"Avoid crashing the kernel - try using WARN_ON & recovery code rather than BUG() or BUG_ON()\n" . …
4327 if ($line =~ /\bprintk\s*\(\s*(?!KERN_[A-Z]+\b)/) {
4332 if ($line =~ /\bprintk\s*\(\s*KERN_([A-Z]+)/) {
4342 if ($line =~ /\bdev_printk\s*\(\s*KERN_([A-Z]+)/) {
4354 …"Do not use $1() in production code (this can be ignored if built only with a debug config option)…
4357 # ENOSYS means "bad syscall nr" and nothing else. This will have a small
4365 # ENOTSUPP is not a standard error code and should be avoided in new patches.
4367 # Similarly to ENOSYS warning a small number of false positives is expected.
4370 "ENOTSUPP is not a SUSV4 error code, prefer EOPNOTSUPP\n" . $herecurr) &&
4404 fix_delete_line($fixlinenr - 1, $prevrawline);
4438 # so check it for a missing trailing missing space but pointer return types
4439 # don't need a space so don't warn for those.
4455 # and this is form shouldn't/doesn't generate a checkpatch warning.
4497 # 1. with a type on the left -- int [] a;
4498 # 2. at the beginning of a line for slice initialisers -- [0...10] = 5,
4499 # 3. inside a curly brace -- = { [0...10] = 5 }
4501 my ($where, $prefix) = ($-[1], $1);
4517 my $ctx_before = substr($line, 0, $-[1]);
4527 # cpp #define statements have non-optional spaces, ie
4528 # if there is a space between the name and the open
4529 # parenthesis it is simply not a parameter group.
4532 # cpp #elif statement condition may start with a (
4535 # If this whole things ends with a type its most
4536 # likely a typedef for a function.
4556 \+=|-=|\*=|\/=|%=|\^=|\|=|&=|
4557 =>|->|<<|>>|<|>|=|!|~|
4558 &&|\|\||,|\^|\+\+|--|&|\||\+|-|\*|\/|%|
4579 my $last_after = -1;
4597 my $a = '';
4598 $a = 'V' if ($elements[$n] ne '');
4599 $a = 'W' if ($elements[$n] =~ /\s$/);
4600 $a = 'C' if ($elements[$n] =~ /$;$/);
4601 $a = 'B' if ($elements[$n] =~ /(\[|\()$/);
4602 $a = 'O' if ($elements[$n] eq '');
4603 $a = 'E' if ($ca =~ /^\s*$/);
4619 my $ctx = "${a}x${c}";
4639 # ; should have either the end of line or a space or \ after it
4650 # // is a comment
4653 # : when part of a bitfield
4658 # ->
4659 } elsif ($op eq '->') {
4671 # , must not have a space before and must have a space on the right.
4701 # '*' as part of a type definition -- reported already.
4705 # unary operators should have a space before and
4707 # unary operator, or a cast
4709 $opv eq '*U' || $opv eq '-U' ||
4711 if ($ctx !~ /[WEBC]x./ && $ca !~ /(?:\)|!|~|\*|-|\&|\||\+\+|\-\-|\{)$/) {
4721 # A unary '*' may be const
4734 # unary ++ and unary -- are allowed no space on one side.
4735 } elsif ($op eq '++' or $op eq '--') {
4765 $op eq '+' or $op eq '-' or
4795 # A colon needs no spaces before when it is
4796 # terminating a case value or a label.
4820 # ignore a colon with another
4860 # check for whitespace before a non-naked semicolon
4876 ## # check for multiple declarations, allowing for a function declaration
4910 # closing brace should have a space following it when it has anything
4961 # ie: &(foo->bar) should be &foo->bar and *(foo->bar) should be *foo->bar
4973 # ie: (foo->bar)(); should be foo->bar();
4974 # but not "if (foo->bar) (" to avoid some false positives
4987 # when !drivers/staging or command-line uses --strict
4992 my $test = substr($2, 1, -1);
5012 #goto labels aren't indented, allow a single space however
5013 if ($line=~/^.\s+[A-Za-z\d_]+:(?![0-9]+)/ and
5014 !($line=~/^. [A-Za-z\d_]+:/) and !($line=~/^.\s+default:/)) {
5023 # check if a statement with a comma should be two statements like:
5034 # return is not a function
5043 "return is not a function, parentheses are not required\n" . $herecurr);
5051 # unnecessary return in a void function
5052 # at end-of-function, with the previous line a single leading tab, then return;
5053 # and the line before that not a goto label target like "out:"
5057 $lines[$linenr - 3] =~ /^[ +]/ &&
5058 $lines[$linenr - 3] !~ /^[ +]\s*$Ident\s*:/) {
5063 # if statements using unnecessary parentheses - ie: if ((foo == bar))
5071 $msg = " - maybe == should be = ?" if ($comp eq "==");
5077 # comparisons with a constant or upper case identifier on the left
5082 $line =~ /^\+(.*)\b($Constant|[A-Z_][A-Z0-9_]*)\s*($Compare)\s*($LvalOrFunc)/) {
5089 $to !~ /^(?:Constant|[A-Z_][A-Z0-9_]*)$/ &&
5107 if ($sline =~ /\breturn(?:\s*\(+\s*|\s+)(E[A-Z]+)(?:\s*\)+\s*|\s*)[;:,]/) {
5111 "return of an errno should typically be negative (ie: return -$1)\n" . $herecurr);
5115 # Need a space before open parenthesis after if, while etc
5125 # Check for illegal assignment in if conditional -- and check for trailing
5140 ($stat_next =~ /^((?:\s*\n[+-])*\s*)/s);
5142 statement_rawlines($whitespace) - 1;
5208 \s*0[xX][0-9]+\s*
5212 \s*0[xX][0-9]+\s*
5229 # if should not continue a brace
5253 fix_delete_line($fixlinenr - 1, $prevrawline);
5279 fix_delete_line($fixlinenr - 1, $prevrawline);
5297 $var =~ /[A-Z][a-z]|[a-z][A-Z]/ &&
5299 $var !~ /^(?:Clear|Set|TestClear|TestSet|)Page[A-Z]/ &&
5302 $var !~ /^(?:[a-z0-9_]*|[A-Z0-9_]*)?_?[a-z][A-Z](?:_[a-z0-9_]+|_[A-Z0-9_]+)?$/ &&
5304 $var !~ /^(?:[a-z_]*?)_?(?:[KMGT]iB|[KMGT]?Hz)(?:_[a-z_]+)?$/) {
5307 next if ($word !~ /[A-Z][a-z]|[a-z][A-Z]/);
5338 if (-f "$root/$checkfile" &&
5342 my $asminclude = `grep -Ec "#include\\s+<asm/$file>" $root/$checkfile`;
5355 # multi-statement macros should be enclosed in a do while loop, grab the
5357 # in a known good container
5370 #print "LINE<$lines[$ln-1]> len<" . length($lines[$ln-1]) . "\n";
5381 $define_args = substr($define_args, 1, length($define_args) - 2);
5405 # Make asm volatile uses seem like a generic function
5428 $dstat !~ /^(?:$Ident|-?$Constant),$/ && # 10, // foo(),
5429 $dstat !~ /^(?:$Ident|-?$Constant);$/ && # foo();
5430 …$dstat !~ /^[!~-]?(?:$Lval|$Constant)$/ && # 10 // foo() // !foo // ~foo // -foo // foo->bar // f…
5438 $dstat !~ /^for\s*$Constant\s+(?:$Ident|-?$Constant)$/ && # for (...) bar()
5445 …"Macros starting with if should be enclosed by a do - while loop to avoid possible if/else logic d…
5448 … "Macros with multiple statements should be enclosed in a do - while loop\n" . "$herectx");
5456 # Make $define_stmt single line, comment-free, etc
5484 "Macro argument reuse '$arg' - possible side-effects?\n" . "$herectx");
5496 # ## concatenation is commonly a macro that defines a function so ignore those
5518 # single-statement macros do not need to be enclosed in do while (0) loop,
5519 # macro should not end with a semicolon
5545 "Single statement macros should not use a do {} while (0) loop\n" . "$herectx");
5557 "macros should not use a trailing semicolon\n" . "$herectx");
5572 my $ln = $linenr - 1;
5577 my ($whitespace) = ($cond =~ /^((?:\s*\n[+-])*\s*)/s);
5578 my $offset = statement_rawlines($whitespace) - 1;
5587 $ln += statement_rawlines($block) - 1;
5624 if (!defined $suppress_ifbraces{$linenr - 1} &&
5628 # Check the pre-context.
5629 if (substr($line, 0, $-[0]) =~ /(\}\s*)$/) {
5635 ctx_statement_full($linenr, $realcnt, $-[0]);
5655 # Check the post-context.
5662 #print "APW: ALLOWED: chunk-1 block<$block>\n";
5684 "Blank lines aren't necessary before a close brace '}'\n" . $hereprev) &&
5686 fix_delete_line($fixlinenr - 1, $prevrawline);
5701 …"Use of volatile is usually wrong: see Documentation/process/volatile-considered-harmful.rst\n" . …
5704 # Check for user-visible strings broken across lines, which breaks the ability
5705 # to grep for the string. Make exceptions when the previous string ends in a
5707 # (common in inline assembly) or is a octal \123 or hexadecimal \xaf value
5710 $prevrawline !~ /(?:\\(?:[ntr]|[0-7]{1,3}|x[0-9a-fA-F]{1,2})|;\s*|\{\s*)"\s*$/) {
5715 $last_coalesced_string_linenr != $linenr - 1) {
5722 fix_delete_line($fixlinenr - 1, $prevrawline);
5727 fix_insert_line($fixlinenr - 1, $fixedline);
5737 # check for missing a space in a string concatenation
5740 "break quoted strings at a space character\n" . $hereprev);
5743 # check for an embedded function name in a string when the function is known
5744 # This does not work very well for -f --file checking as it depends on patch
5745 # context providing the function name or a single line form for in-file
5752 …\"%s...\", __func__' to using '$context_function', this function's name, in a string\n" . $herecur…
5755 # check for spaces before a quoted newline
5758 "unnecessary whitespace before a quoted newline\n" . $herecurr) &&
5766 if ($line =~ /$String[A-Za-z0-9_]/ || $line =~ /[A-Za-z0-9_]$String/) {
5771 my $extracted_string = substr($rawline, $-[0], $+[0] - $-[0]);
5772 $fixed[$fixlinenr] =~ s/\Q$extracted_string\E([A-Za-z0-9_])/$extracted_string $1/;
5773 $fixed[$fixlinenr] =~ s/([A-Za-z0-9_])\Q$extracted_string\E/$1 $extracted_string/;
5781 "Consecutive strings are generally better as a single string\n" . $herecurr) &&
5784 my $extracted_string = substr($rawline, $-[0], $+[0] - $-[0]);
5785 $fixed[$fixlinenr] =~ s/\Q$extracted_string\E\s*"/substr($extracted_string, 0, -1)/e;
5790 # check for non-standard and hex prefixed decimal printf formats
5794 my $string = substr($rawline, $-[1], $+[1] - $-[1]);
5799 "\%L$1 is non-standard C, use %ll$1\n" . $herecurr);
5802 # check for %Z
5803 if ($show_Z && $string =~ /%[\*\d\.\$]*Z([diouxX])/) {
5805 "%Z$1 is non-standard C, use %z$1\n" . $herecurr);
5845 if ($lines[$linenr - 2] =~ /^\+(\t*)if\s*\(\s*$tested\s*\)\s*$/) {
5850 if ($lines[$linenr - 1] =~ /^\+(\t+)$func\s*\(\s*$tested\s*\)\s*;\s*$/) {
5859 fix_delete_line($fixlinenr - 1, $prevrawline);
5872 my $testline = $lines[$linenr - 3];
5874 my ($s, $c) = ctx_statement_block($linenr - 3, $realcnt, 0);
5886 $line =~ /\b$logFunctions\s*\(.*\b(KERN_[A-Z]+)\b/) {
5901 # check for mask then right shift without a parentheses
5906 … "Possible precedence defect with mask then right shift - may need parentheses\n" . $herecurr);
5959 "Use of $attr requires a separate use of const\n" . $herecurr) &&
5970 # check for __read_mostly with const non-pointer (should just be const)
5999 … "usleep_range is preferred over udelay; see Documentation/timers/timers-howto.rst\n" . $herecurr);
6003 "long udelay - prefer mdelay; see arch/arm/include/asm/delay.h\n" . $herecurr);
6011 …"msleep < 20ms can sleep for up to 20ms; see Documentation/timers/timers-howto.rst\n" . $herecurr);
6045 # check for spinlock_t definitions without a comment.
6054 # check for memory barriers without a comment.
6084 if ($realfile !~ m@^include/asm-generic/@ &&
6089 "__smp memory barriers shouldn't be used outside barrier.h and asm-generic\n" . $herecurr);
6092 # check for waitqueue_active without a comment.
6100 # check for data_race without a comment.
6109 … m@^.\s*\#\s*if.*\b(__i386__|__powerpc64__|__sun__|__s390x__)\b@ && $realfile !~ m@include/asm-@) {
6114 # check that the storage class is not after a type
6119 # Check that the storage class is at the beginning of a declaration
6164 my $old = substr($rawline, $-[1], $+[1] - $-[1]);
6165 my $new = substr($old, 1, -1);
6177 …"__printf(string-index, first-to-check) is preferred over __attribute__((format(printf, string-ind…
6188 …"__scanf(string-index, first-to-check) is preferred over __attribute__((format(scanf, string-index…
6290 my $fmt = get_quoted_string($lines[$count - 1], raw_line($count, 0));
6316 $use = " - use %pS instead";
6418 …"usleep_range should not use min == max args; see Documentation/timers/timers-howto.rst\n" . "$her…
6422 …"usleep_range args reversed, use min then max; see Documentation/timers/timers-howto.rst\n" . "$he…
6540 …"__setup appears un-documented -- check Documentation/admin-guide/kernel-parameters.txt\n" . $here…
6547 … "unnecessary cast may hide bugs, see http://c-faq.com/malloc/mallocnocast.html\n" . $herecurr);
6574 !($r1 =~ /^$Constant$/ || $r1 =~ /^[A-Z_][A-Z0-9_]*$/)) {
6592 "Reusing the krealloc arg is almost always a bug\n" . $herecurr);
6629 …if ($line =~ /^\+\s*#\s*if\s+defined(?:\s*\(?\s*|\s+)(${CONFIG_}[A-Z_]+)\s*\)?\s*\|\|\s*defined(?:…
6642 'lint -fallthrough[ \t]*',
6643 'intentional(?:ly)?[ \t]*fall(?:(?:s | |-)[Tt]|t)hr(?:ough|u|ew)',
6644 '(?:else,?\s*)?FALL(?:S | |-)?THR(?:OUGH|U|EW)[ \t.!]*(?:-[^\n\r]*)?',
6645 'Fall(?:(?:s | |-)[Tt]|t)hr(?:ough|u|ew)[ \t.!]*(?:-[^\n\r]*)?',
6646 'fall(?:s | |-)?thr(?:ough|u|ew)[ \t.!]*(?:-[^\n\r]*)?',
6660 # check for switch/default statements without a break;
6683 "Use of the '$1' macro makes the build non-deterministic\n" . $herecurr);
6689 "Using yield() is generally wrong. See yield() kernel-doc (sched/core.c)\n" . $herecurr);
6713 ## maybe suggesting a correct construct would better
6722 "consider using a completion\n" . $herecurr);
6770 …"usage of NR_CPUS is often wrong - consider using cpu_possible(), num_possible_cpus(), for_each_po…
6776 … "#define of '$1' is wrong - use Kconfig variables or standard guards instead\n" . $herecurr);
6816 "lockdep_no_validate class is reserved for device->mutex.\n" . $herecurr);
6831 …E_ATTR\s*\(\s*(\w+)\s*,\s*\(?\s*(\s*(?:${multi_mode_perms_string_search}|0[0-7]{3,3})\s*)\s*\)?\s*…
6884 # This uses a shortcut match to avoid unnecessary uses of a slow foreach loop
6885 # o Ignore module_param*(...) uses with a decimal 0 permission as that has a
6887 # o Ignore proc_create*(...) uses with a decimal 0 permission as that means
6893 my $func = $entry->[0];
6894 my $arg_pos = $entry->[1];
6902 $arg_pos--;
6961 if ($#rawlines == -1) {
6965 # In mailback mode only produce a report in the negative, for
6971 # This is not a patch, and we are are in 'no-patch' mode so
6977 if (!$is_patch && $filename !~ /cover-letter\.patch$/) {
6979 "Does not appear to be a unified-diff format patch\n");
6984 "Missing Signed-off-by: line(s)\n");
6987 # 0 -> missing sign off
6988 # 1 -> sign off identical
6989 # 2 -> names and addresses match, comments mismatch
6990 # 3 -> addresses match, names different
6991 # 4 -> names match, addresses different
6992 # 5 -> names match, addresses excluding subaddress details (refer RFC 5233) match
6994 my $sob_msg = "'From: $author' != 'Signed-off-by: $author_sob'";
6998 "Missing Signed-off-by: line by nominal patch author '$author'\n");
7001 "From:/Signed-off-by: email comments mismatch: $sob_msg\n");
7004 "From:/Signed-off-by: email name mismatch: $sob_msg\n");
7007 "From:/Signed-off-by: email address mismatch: $sob_msg\n");
7010 "From:/Signed-off-by: email subaddress mismatch: $sob_msg\n");
7029 mechanically convert to the typical style using --fix or --fix-inplace.
7048 $newfile .= ".EXPERIMENTAL-checkpatch-fixes" if (!$fix_inplace);
7072 Wrote EXPERIMENTAL --fix correction(s) to '$newfile'
7077 This EXPERIMENTAL file is simply a convenience to help rewrite patches.