Lines Matching +full:pull +full:- +full:comment

5 # (c) 2008-2010 Andy Whitcroft <apw@canonical.com>
71 -q, --quiet quiet
72 --no-tree run without a kernel tree
73 --no-signoff do not check for 'Signed-off-by' line
74 --patch treat FILE as patchfile (default)
75 --emacs emacs compile window format
76 --terse one line per report
77 --showfile emit diffed file position, not input file position
78 -g, --git treat FILE as a single commit or git revision range
86 <rev>-<count>
88 -f, --file treat FILE as regular source file
89 --subjective, --strict enable more subjective tests
90 --list-types list the possible message types
91 --types TYPE(,TYPE2...) show only these comma separated message types
92 --ignore TYPE(,TYPE2...) ignore various comma separated message types
93 --show-types show the specific message type in the output
94 --max-line-length=n set the maximum line length, if exceeded, warn
95 --min-conf-desc-length=n set the min description length, if shorter, warn
96 --root=PATH PATH to the kernel tree root
97 --no-summary suppress the per-file summary
98 --mailback only produce a report in case of warnings/errors
99 --summary-file include the filename in summary
100 --debug KEY=[0|1] turn on/off debugging of KEY, where KEY is one of
103 --test-only=WORD report only warnings/errors containing WORD
105 --fix EXPERIMENTAL - may create horrible results
106 If correctable single-line errors exist, create
107 "<inputfile>.EXPERIMENTAL-checkpatch-fixes"
110 --fix-inplace EXPERIMENTAL - may create horrible results
111 Is the same as --fix, but overwrites the input
113 --ignore-perl-version override checking of perl version. expect
115 --codespell Use the codespell dictionary for spelling/typos
117 --codespellfile Use this codespell dictionary
118 --typedefsfile Read additional types from this file
119 --color[=WHEN] Use colors 'always', 'never', or only when output
121 -h, --help, --version display this help and exit
123 When FILE is - read standard input.
162 if (-f $conf) {
188 # Prevent --color by itself from consuming other arguments
190 if ($_ eq "--color" || $_ eq "-color") {
191 $_ = "--color=$color";
209 'show-types!' => \$show_types,
210 'list-types!' => \$list_types,
211 'max-line-length=i' => \$max_line_length,
212 'min-conf-desc-length=i' => \$min_conf_desc_length,
216 'summary-file!' => \$summary_file,
218 'fix-inplace!' => \$fix_inplace,
219 'ignore-perl-version!' => \$ignore_perl_version,
221 'test-only=s' => \$tst_only,
226 'no-color' => \$color, #keep old behaviors of -nocolor
227 'nocolor' => \$color, #keep old behaviors of -nocolor
248 #if no filenames are given, push '-' to read patch from stdin
250 push(@ARGV, '-');
260 $color = (-t STDOUT);
273 $word =~ tr/[a-z]/[A-Z]/;
278 $hashRef->{$word}++;
317 die "$P: $root: --root does not point at a valid tree\n";
329 print "Must be run from the top-level dir. of a kernel tree\n";
337 [A-Za-z_][A-Za-z\d_]*
338 (?:\s*\#\#\s*[A-Za-z_][A-Za-z\d_]*)*
388 our $Member = qr{->$Ident|\.$Ident|\[[^]]*\]};
393 our $Hex = qr{(?i)0x[0-9a-f]+$Int_type?};
394 our $Int = qr{[0-9]+$Int_type?};
395 our $Octal = qr{0[0-7]+$Int_type?};
397 our $Float_hex = qr{(?i)0x[0-9a-f]+p-?[0-9]+[fl]?};
398 our $Float_dec = qr{(?i)(?:[0-9]+\.[0-9]*|[0-9]*\.[0-9]+)(?:e-?[0-9]+)?[fl]?};
399 our $Float_int = qr{(?i)[0-9]+e-?[0-9]+[fl]?};
402 our $Assignment = qr{\*\=|/=|%=|\+=|-=|<<=|>>=|&=|\^=|\|=|=};
403 our $Compare = qr{<=|>=|==|!=|<|(?<!-)>};
404 our $Arithmetic = qr{\+|-|\*|\/|%};
407 =>|->|<<|>>|<|>|!|~|
408 &&|\|\||,|\^|\+\+|--|&|\||$Arithmetic
423 [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte
424 | \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs
425 | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte
426 | \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates
427 | \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3
428 | [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15
429 | \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16
433 [\x09\x0A\x0D\x20-\x7E] # ASCII
456 …(?:[a-z0-9]+_){1,2}(?:printk|emerg|alert|crit|err|warning|warn|notice|info|debug|dbg|vdbg|devel|co…
460 MODULE_[A-Z_]+|
465 Signed-off-by:|
466 Acked-by:|
467 Tested-by:|
468 Reviewed-by:|
469 Reported-by:|
470 Suggested-by:|
557 ["IIO_DEV_ATTR_[A-Z_]+", 1],
567 $mode_perms_search .= $entry->[0];
576 0[0-7][0-7][2367]
613 return trim($string) if ($string =~ /^\s*0[0-7]{3,3}\s*$/);
624 last if ($lastpos > 0 && ($curpos - length($omatch) != $lastpos));
664 warn "No typos will be found - file '$spelling_file': $!\n";
681 my ($suspect, $fix) = split(/->/, $line);
687 warn "No codespell typos will be found - file '$codespellfile': $!\n";
706 print("$file: '$line' invalid - ignored\n");
722 or warn "No structs that should be const will be found - file '$conststructsfile': $!\n";
727 or warn "No additional types will be considered - file '$typedefsfile': $!\n";
787 our $balanced_parens = qr/(\((?:[^\(\)]++|(?-1))*\))/;
792 (?:$Storage\s+)?(?:[A-Z_][A-Z0-9]*_){0,2}(?:DEFINE|DECLARE)(?:_[A-Z0-9]+){1,6}\s*\(|
815 return if (!(-f $file));
827 next if ($line !~ /(?:[A-Z][a-z]|[a-z][A-Z])/);
828 if ($line =~ /^[ \t]*(?:#[ \t]*define|typedef\s+$Type)\s+(\w*(?:[A-Z][a-z]|[a-z][A-Z])\w*)/) {
830 } elsif ($line =~ /^\s*$Declare\s+(\w*(?:[A-Z][a-z]|[a-z][A-Z])\w*)\s*[\(\[,;]/) {
832 } elsif ($line =~ /^\s*(?:union|struct|enum)\s+(\w*(?:[A-Z][a-z]|[a-z][A-Z])\w*)\s*[;\{]/) {
841 return 0 if (!$tree || !(-e "$root/scripts/get_maintainer.pl"));
843 …my $status = `perl $root/scripts/get_maintainer.pl --status --nom --nol --nogit --nogit-fallback -
858 if (-e ".git") {
859 my $git_last_include_commit = `git log --no-merges --pretty=format:"%h%n" -1 -- include`;
861 $camelcase_cache = ".checkpatch-camelcase.git.$git_last_include_commit";
864 $files = `find $root/include -name "*.h"`;
871 $camelcase_cache = ".checkpatch-camelcase.date.$last_mod_date";
874 if ($camelcase_cache ne "" && -f $camelcase_cache) {
886 if (-e ".git") {
887 $files = `git ls-files "include/*.h"`;
896 unlink glob ".checkpatch-camelcase.*";
909 return ($id, $desc) if ((which("git") eq "") || !(-e ".git"));
911 my $output = `git log --no-color --format='%H %s' -1 $commit 2>&1`;
922 # git rev-list --remotes | grep -i "^$1" |
924 # git log --format='%H %s' -1 $line |
925 # echo "commit $(cut -c 1-12,41-)"
944 my $fixlinenr = -1;
947 # For example, HEAD-3 means we need check 'HEAD, HEAD~1, HEAD~2'.
948 die "$P: No git repository found\n" if ($git && !-e ".git");
954 if ($commit_expr =~ m/^(.*)-(\d+)$/) {
955 $git_range = "-$2 $1";
959 $git_range = "-1 $commit_expr";
961 my $lines = `git log --no-color --no-merges --pretty=format:'%H %s' $git_range`;
963 $line =~ /^([0-9a-fA-F]{40,40}) (.*)$/;
979 open($FILE, '-|', "git format-patch -M --stdout -1 $filename") ||
980 die "$P: $filename: git format-patch failed - $!\n";
982 open($FILE, '-|', "diff -u /dev/null $filename") ||
983 die "$P: $filename: diff failed - $!\n";
984 } elsif ($filename eq '-') {
988 die "$P: $filename: open failed - $!\n";
990 if ($filename eq '-') {
1004 print '-' x length($vname) . "\n";
1006 print '-' x length($vname) . "\n";
1017 $fixlinenr = -1;
1055 if (! -e $root . '/' . $check) {
1067 my $comment = "";
1072 $comment = $3 if defined $3;
1075 $comment = $2 if defined $2;
1078 $comment = $2 if defined $2;
1092 $comment = "";
1101 if ($name =~ /[^\w \-]/i) { ##has "must quote" chars
1106 return ($name, $address, $comment);
1118 if ($name =~ /[^\w \-]/i) { ##has "must quote" chars
1136 if (-e "$path/$bin") {
1148 if (-e "$path/$conf") {
1303 return substr($rawline, $-[0], $+[0] - $-[0]);
1308 my $line = $linenr - 1;
1311 my $coff = $off - 1;
1325 @stack = (['', 0]) if ($#stack == -1);
1328 # If we are about to drop off the end, pull in more
1333 next if ($lines[$line] =~ /^-/);
1334 $remain--;
1361 ($type, $level) = @{$stack[$#stack - 1]};
1377 $coff = $off + length($1) - 1;
1380 #warn "[" . substr($blk, $soff, $coff - $soff + 1) . "]\n";
1388 $level--;
1402 $level--;
1414 $level--;
1425 $remain--;
1428 my $statement = substr($blk, $soff, $off - $soff + 1);
1429 my $condition = substr($blk, $soff, $coff - $soff + 1);
1437 $line, $remain + 1, $off - $loff + 1, $level);
1494 if (!($remain > 0 && $condition =~ /^\s*(?:\n[+-])?\s*(?:if|else|do)\b/s)) {
1498 # Pull in the following conditional/block pairs and see if they
1504 last if (!($remain > 0 && $condition =~ /^(?:\s*\n[+-])*\s*(?:else|do)\b/s));
1515 my $start = $linenr - 1;
1524 next if ($rawlines[$line] =~ /^-/);
1525 $remain--;
1533 $level = $stack[$#stack - 1];
1541 $off--;
1546 $level--;
1594 # Catch a comment on the end of the line itself.
1595 my ($current_comment) = ($rawlines[$end_line - 1] =~ m@.*(/\*.*\*/)\s*(?:\\\s*)?$@);
1599 # comment.
1603 my $line = $rawlines[$linenr - 1];
1627 ##print "LINE: $rawlines[$end_line - 1 ]\n";
1636 my $offset = $linenr - 1;
1642 next if (defined($line) && $line =~ /^-/);
1643 $cnt--;
1813 print "PAREN('$1') -> $type\n"
1869 } elsif ($cur =~ /^(-(?![->])|\+(?!\+)|\*|\&\&|\&)/o) {
1884 if ($1 ne '++' && $1 ne '--') {
1952 $type =~ tr/[a-z]/[A-Z]/;
1985 my @lines = split("\n", $output, -1);
2003 if ($$lineRef =~ /^\@\@ -\d+,\d+ \+(\d+),(\d+) \@\@/) {
2032 if ($line =~ /^(?:\+\+\+|\-\-\-)\s+\S+/) { #new filename
2034 } elsif ($line =~ /^\@\@ -\d+,\d+ \+\d+,\d+ \@\@/) { #new hunk
2042 fixup_current_range(\$lines[$range_last_linenr], $delta_offset--, -1);
2123 if (-f "$root/$file") {
2128 if (! -f _) {
2134 substr($prefix, -length($file)) = '';
2179 my $max_spaces_before_tab = $source_indent - 1;
2201 return -1;
2209 $pos += length($1) - 1;
2212 } elsif (index($string, '(') == -1) {
2247 my $last_coalesced_string_linenr = -1;
2276 # Pre-scan the patch sanitizing the lines.
2277 # Pre-scan the patch looking for any __setup documentation.
2296 if ($1 =~ m@Documentation/admin-guide/kernel-parameters.rst$@) {
2301 if ($rawline =~ /^\@\@ -\d+(?:,\d+)? \+(\d+)(,(\d+))? \@\@/) {
2302 $realline=$1-1;
2310 # Guestimate if this is a continuing comment. Run
2311 # the context looking for a comment "edge". If this
2312 # edge is a close comment then we must be in a comment
2317 next if (defined $rawlines[$ln - 1] &&
2318 $rawlines[$ln - 1] =~ /^-/);
2319 $cnt--;
2320 #print "RAW<$rawlines[$ln - 1]>\n";
2321 last if (!defined $rawlines[$ln - 1]);
2322 if ($rawlines[$ln - 1] =~ m@(/\*|\*/)@ &&
2323 $rawlines[$ln - 1] !~ m@"[^"]*(?:/\*|\*/)[^"]*"@) {
2332 # Guestimate if this is a continuing comment. If this
2334 # ' *' then it is very likely a comment.
2341 ##print "COMMENT:$in_comment edge<$edge> $rawline\n";
2346 # simplify matching -- only bother with positive lines.
2352 $realcnt-- if ($line =~ /^(?:\+| |$)/);
2358 #print "-->$line\n";
2369 $fixlinenr = -1;
2376 my $rawline = $rawlines[$linenr - 1];
2380 $line =~ /^\@\@ -\d+(?:,\d+)? \+(\d+)(,(\d+))? \@\@(.*)/) {
2384 $realline=$1-1;
2409 $realcnt-- if ($realcnt != 0);
2422 $realcnt--;
2432 if ($line =~ /^diff --git.*?(\S+)$/) {
2444 -e "$root/$p1_prefix") {
2446 "patch prefix '$p1_prefix' exists, appears to be a -p0 patch\n");
2451 …"do not modify files in include/asm, change architecture specific files in include/asm-<architectu…
2493 $line =~ m@^\s*(?:\-\-\-\s+a/|\+\+\+\s+b/)@ ||
2494 $line =~ m/^\s*\@\@ \-\d+,\d+ \+\d+,\d+ \@\@/)) {
2496 "Avoid using diff content in the commit message - patch(1) might not work\n" . $herecurr);
2511 if ($line =~ /^\s*signed-off-by:/i) {
2524 $line =~ /^(\s*)([a-z0-9_-]+by:|$signature_tags)(\s*)(.*)/i) {
2533 "Non-standard signature: $sign_off\n" . $herecurr);
2543 if ($sign_off =~ /-by:$/i && $sign_off ne $ucfirst_sign_off) {
2561 my ($email_name, $email_address, $comment) = parse_email($email);
2572 if ("$dequoted$comment" ne $email &&
2573 "<$email_address>$comment" ne $email &&
2574 "$suggested_email$comment" ne $email) {
2576 "email address '$email' might be better as '$suggested_email$comment'\n" . $herecurr);
2606 if ($in_commit_log && $line =~ /^\s*change-id:/i) {
2608 "Remove Gerrit Change-Id's before submitting upstream.\n" . $herecurr);
2616 $line =~ /^\s*\[\<[0-9a-fA-F]{8,}\>\]/)) {
2624 !($line =~ /^\s*[a-zA-Z0-9_\/\.]+\s+\|\s+\d+/ ||
2626 $line =~ /^\s*(?:[\w\.\-]+\/)++[\w\.\-]+:/ ||
2645 $line !~ /^This reverts commit [0-9a-f]{7,40}/ &&
2646 ($line =~ /\bcommit\s+[0-9a-f]{5,}\b/i ||
2647 ($line =~ /(?:\s|^)[0-9a-f]{12,40}(?:[\s"'\(\[]|$)/i &&
2648 $line !~ /[\<\[][0-9a-f]{12,40}[\>\]]/i &&
2649 $line !~ /\bfixes:\s*[0-9a-f]{12,40}/i))) {
2662 if ($line =~ /\b(c)ommit\s+([0-9a-f]{5,})\b/i) {
2665 } elsif ($line =~ /\b([0-9a-f]{12,40})\b/i) {
2669 $short = 0 if ($line =~ /\bcommit\s+[0-9a-f]{12,40}/i);
2670 $long = 1 if ($line =~ /\bcommit\s+[0-9a-f]{41,}/i);
2671 $space = 0 if ($line =~ /\bcommit [0-9a-f]/i);
2672 $case = 0 if ($line =~ /\b[Cc]ommit\s+[0-9a-f]{5,40}[^A-F]/);
2673 if ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("([^"]+)"\)/i) {
2676 } elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s*$/i &&
2681 } elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("[^"]+$/i &&
2684 $line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("([^"]+)$/i;
2697 …it commit description style 'commit <12+ chars of sha1> (\"<title line>\")' - ie: '${init_char}omm…
2704 $line =~ /^rename (?:from|to) [\w\/\.\-]+\s*$/ ||
2705 ($line =~ /\{\s*([\w\/\.\-]*)\s*\=\>\s*([\w\/\.\-]*)\s*\}/ &&
2714 if ($realcnt != 0 && $line !~ m{^(?:\+|-| |\\ No newline|$)}) {
2720 # UTF-8 regex found at http://www.w3.org/International/questions/qa-forms-utf-8.en.php
2730 "Invalid UTF-8, patch and commit message should be encoded in UTF-8\n" . $hereptr);
2737 $rawline =~ /^(?:commit\b|from\b|[\w-]+:)/i)) {
2743 # Check if there is UTF-8 in a commit log when a mail header has explicitly
2746 $rawline =~ /^Content-Type:.+charset="(.+)".*$/ &&
2747 $1 !~ /utf-8/i) {
2754 "8-bit UTF-8 used in possible commit log\n" . $herecurr);
2774 while ($rawline =~ /(?:^|[^a-z@])($misspellings)(?:\b|$|[^a-z@])/gi) {
2777 $typo_fix = ucfirst($typo_fix) if ($typo =~ /^[A-Z]/);
2778 $typo_fix = uc($typo_fix) if ($typo =~ /^[A-Z]+$/);
2782 "'$typo' may be misspelled - perhaps '$typo_fix'?\n" . $herecurr) &&
2784 $fixed[$fixlinenr] =~ s/(^|[^A-Za-z@])($typo)($|[^A-Za-z@])/$1$typo_fix$3/;
2789 # ignore non-hunk lines and lines being removed
2790 next if (!$hunk_line || $line =~ /^-/);
2837 for (; $cnt > 0 && defined $lines[$ln - 1]; $ln++) {
2838 $f = $lines[$ln - 1];
2839 $cnt-- if ($lines[$ln - 1] !~ /^-/);
2840 $is_end = $lines[$ln - 1] =~ /^\+/;
2842 next if ($f =~ /^-/);
2845 if ($lines[$ln - 1] =~ /^\+\s*(?:bool|tristate|prompt)\s*["']/) {
2847 } elsif ($lines[$ln - 1] =~ /^\+\s*(?:help|---help---)\s*$/) {
2848 if ($lines[$ln - 1] =~ "---help---") {
2850 "prefer 'help' over '---help---' for new help texts\n" . $herecurr);
2852 $length = -1;
2880 $rawline =~ /^\+[A-Z]:/ &&
2881 $rawline !~ /^\+[A-Z]:\t\S/) {
2885 $fixed[$fixlinenr] =~ s/^(\+[A-Z]):\s*/$1:\t/;
2897 ($line =~ /\+(EXTRA_[A-Z]+FLAGS).*/)) {
2900 'EXTRA_AFLAGS' => 'asflags-y',
2901 'EXTRA_CFLAGS' => 'ccflags-y',
2902 'EXTRA_CPPFLAGS' => 'cppflags-y',
2903 'EXTRA_LDFLAGS' => 'ldflags-y',
2907 … of $flag is deprecated, please use \`$replacement->{$flag} instead.\n" . $herecurr) if ($replacem…
2915 my @compats = $rawline =~ /\"([a-zA-Z0-9\-\,\.\+_]+)\"/g;
2918 my $vp_file = $dt_path . "vendor-prefixes.txt";
2922 $compat2 =~ s/\,[a-zA-Z0-9]*\-/\,<\.\*>\-/;
2924 $compat3 =~ s/\,([a-z]*)[0-9]*\-/\,$1<\.\*>\-/;
2925 `grep -Erq "$compat|$compat2|$compat3" $dt_path`;
2928 "DT compatible string \"$compat\" appears un-documented -- check $dt_path\n" . $herecurr);
2931 next if $compat !~ /^([a-zA-Z0-9\-]+)\,/;
2933 `grep -Eq "^$vendor\\b" $vp_file`;
2936 … "DT compatible string vendor \"$vendor\" appears un-documented -- check $vp_file\n" . $herecurr);
2946 my $comment = "";
2948 $comment = '/*';
2950 $comment = '//';
2952 $comment = '#';
2954 $comment = '..';
2957 if ($comment !~ /^$/ &&
2958 $rawline !~ /^\+\Q$comment\E SPDX-License-Identifier: /) {
2960 … "Missing or malformed SPDX-License-Identifier tag in line $checklicenseline\n" . $herecurr);
2977 # LONG_LINE_COMMENT a comment starts before but extends beyond $max_line_length
2992 length(expand_tabs(substr($line, 1, length($line) - length($1) - 1))) <= $max_line_length) {
3006 # URL ($rawline is used in case the URL is in a comment)
3007 } elsif ($rawline =~ /^\+.*\b[a-z][\w\.\+\-]*:\/\/\S+/i) {
3012 # a comment starts before $max_line_length
3014 length(expand_tabs(substr($line, 1, length($line) - length($1) - 1))) <= $max_line_length) {
3019 length(expand_tabs(substr($line, 1, length($line) - length($1) - 1))) <= $max_line_length) {
3084 # check multi-line statement indentation matches previous line
3131 # Block comment styles
3138 "networking block comments don't use an empty /* line, use /* Comment...\n" . $hereprev);
3142 if ($prevline =~ /$;[ \t]*$/ && #ends in comment
3160 # Block comment * alignment
3161 if ($prevline =~ /$;[ \t]*$/ && #ends in comment
3162 $line =~ /^\+[ \t]*$;/ && #leading comment
3192 $line =~ /^\+[a-z_]*init/ ||
3193 $line =~ /^\+\s*(?:static\s+)?[A-Z_]*ATTR/ ||
3207 $last_blank_line != ($linenr - 1)) {
3352 (!defined $lines[$realline_next - 1] ||
3353 substr($lines[$realline_next - 1], $off_next) =~ /^\s*$/)) {
3433 …if ($line =~ /(.*)\b((?:if|while|for|switch|(?:[a-z_]+|)for_each[a-z_]+)\s*\(|do\b|else\b)/ && $li…
3440 "Too many leading tabs - consider code refactoring\n" . $herecurr);
3443 my $ctx_cnt = $realcnt - $#ctx - 1;
3450 defined $lines[$ctx_ln - 1] &&
3451 $lines[$ctx_ln - 1] =~ /^-/)) {
3453 $ctx_skip-- if (!defined $lines[$ctx_ln - 1] || $lines[$ctx_ln - 1] !~ /^-/);
3458 #print "pre<$pre_ctx>\nline<$line>\nctx<$ctx>\nnext<$lines[$ctx_ln - 1]>\n";
3460 if ($ctx !~ /{\s*/ && defined($lines[$ctx_ln - 1]) && $lines[$ctx_ln - 1] =~ /^\+\s*{/) {
3463 "$here\n$ctx\n$rawlines[$ctx_ln - 1]\n");
3467 defined $lines[$ctx_ln - 1])
3469 my ($nlength, $nindent) = line_stats($lines[$ctx_ln - 1]);
3473 "$here\n$ctx\n$rawlines[$ctx_ln - 1]\n");
3479 …if ($line =~ /\b(?:(?:if|while|for|(?:[a-z_]+|)for_each[a-z_]+)\s*\(|(?:do|else)\b)/ && $line !~ /…
3527 my $cond_ptr = -1;
3590 $prev_values = substr($curr_values, -1);
3596 if ($prevline =~ /^\+.*$Lval\s*(?:\.|->)\s*$/ &&
3598 $prevline =~ /($Lval\s*(?:\.|->))\s*$/;
3604 "Avoid multiple line dereference - prefer '$ref'\n" . $hereprev);
3660 fix_delete_line($fixlinenr - 1, $prevrawline);
3695 my $comment = trim($1);
3696 $fixed[$fixlinenr] =~ s@\/\/(.*)$@/\* $comment \*/@;
3706 #print "APW <$lines[$realline_next - 1]>\n";
3708 exists $lines[$realline_next - 1] &&
3710 ($lines[$realline_next - 1] =~ /EXPORT_SYMBOL.*\((.*)\)/ ||
3711 $lines[$realline_next - 1] =~ /EXPORT_UNUSED_SYMBOL.*\((.*)\)/)) {
3717 if ($stat =~ /^(?:.\s*}\s*\n)?.([A-Z_]+)\s*\(\s*($Ident)/ &&
3730 #print "FOO A<$lines[$realline_next - 1]> stat<$stat> name<$name>\n";
3740 #print "FOO B <$lines[$linenr - 1]>\n";
3800 # check for non-global char *foo[] = {"bar", ...} declarations.
3823 "Bad function definition - $1() should probably be $1(void)\n" . $herecurr) &&
3901 …"Avoid crashing the kernel - try using WARN_ON & recovery code rather than BUG() or BUG_ON()\n" . …
3917 if ($line =~ /\bprintk\s*\(\s*(?!KERN_[A-Z]+\b)/) {
3922 if ($line =~ /\bprintk\s*\(\s*KERN_([A-Z]+)/) {
3941 if ($line =~ /\bdev_printk\s*\(\s*KERN_([A-Z]+)/) {
3986 fix_delete_line($fixlinenr - 1, $prevrawline);
4079 # 1. with a type on the left -- int [] a;
4080 # 2. at the beginning of a line for slice initialisers -- [0...10] = 5,
4081 # 3. inside a curly brace -- = { [0...10] = 5 }
4083 my ($where, $prefix) = ($-[1], $1);
4099 my $ctx_before = substr($line, 0, $-[1]);
4109 # cpp #define statements have non-optional spaces, ie
4138 \+=|-=|\*=|\/=|%=|\^=|\|=|&=|
4139 =>|->|<<|>>|<|>|=|!|~|
4140 &&|\|\||,|\^|\+\+|--|&|\||\+|-|\*|\/|%|
4161 my $last_after = -1;
4208 # Pull out the value of this operator.
4232 # // is a comment
4240 # ->
4241 } elsif ($op eq '->') {
4283 # '*' as part of a type definition -- reported already.
4291 $opv eq '*U' || $opv eq '-U' ||
4293 if ($ctx !~ /[WEBC]x./ && $ca !~ /(?:\)|!|~|\*|-|\&|\||\+\+|\-\-|\{)$/) {
4316 # unary ++ and unary -- are allowed no space on one side.
4317 } elsif ($op eq '++' or $op eq '--') {
4347 $op eq '+' or $op eq '-' or
4442 # check for whitespace before a non-naked semicolon
4543 # ie: &(foo->bar) should be &foo->bar and *(foo->bar) should be *foo->bar
4555 # ie: (foo->bar)(); should be foo->bar();
4556 # but not "if (foo->bar) (" to avoid some false positives
4569 # when !drivers/staging or command-line uses --strict
4574 my $test = substr($2, 1, -1);
4595 if ($line=~/^.\s+[A-Za-z\d_]+:(?![0-9]+)/ and
4596 !($line=~/^. [A-Za-z\d_]+:/) and !($line=~/^.\s+default:/)) {
4623 # at end-of-function, with the previous line a single leading tab, then return;
4628 $lines[$linenr - 3] =~ /^[ +]/ &&
4629 $lines[$linenr - 3] !~ /^[ +]\s*$Ident\s*:/) {
4634 # if statements using unnecessary parentheses - ie: if ((foo == bar))
4642 $msg = " - maybe == should be = ?" if ($comp eq "==");
4653 $line =~ /^\+(.*)\b($Constant|[A-Z_][A-Z0-9_]*)\s*($Compare)\s*($LvalOrFunc)/) {
4660 $to !~ /^(?:Constant|[A-Z_][A-Z0-9_]*)$/ &&
4678 if ($sline =~ /\breturn(?:\s*\(+\s*|\s+)(E[A-Z]+)(?:\s*\)+\s*|\s*)[;:,]/) {
4682 "return of an errno should typically be negative (ie: return -$1)\n" . $herecurr);
4696 # Check for illegal assignment in if conditional -- and check for trailing
4711 ($stat_next =~ /^((?:\s*\n[+-])*\s*)/s);
4713 statement_rawlines($whitespace) - 1;
4757 \s*0[xX][0-9]+\s*
4761 \s*0[xX][0-9]+\s*
4802 fix_delete_line($fixlinenr - 1, $prevrawline);
4828 fix_delete_line($fixlinenr - 1, $prevrawline);
4857 $var =~ /[A-Z][a-z]|[a-z][A-Z]/ &&
4859 $var !~ /^(?:Clear|Set|TestClear|TestSet|)Page[A-Z]/ &&
4861 $var !~ /^(?:[a-z_]*?)_?[a-z][A-Z](?:_[a-z_]+)?$/ &&
4863 $var !~ /^(?:[a-z_]*?)_?(?:[KMGT]iB|[KMGT]?Hz)(?:_[a-z_]+)?$/) {
4866 next if ($word !~ /[A-Z][a-z]|[a-z][A-Z]/);
4897 if (-f "$root/$checkfile" &&
4901 my $asminclude = `grep -Ec "#include\\s+<asm/$file>" $root/$checkfile`;
4914 # multi-statement macros should be enclosed in a do while loop, grab the
4929 #print "LINE<$lines[$ln-1]> len<" . length($lines[$ln-1]) . "\n";
4940 $define_args = substr($define_args, 1, length($define_args) - 2);
4986 $dstat !~ /^(?:$Ident|-?$Constant),$/ && # 10, // foo(),
4987 $dstat !~ /^(?:$Ident|-?$Constant);$/ && # foo();
4988 …$dstat !~ /^[!~-]?(?:$Lval|$Constant)$/ && # 10 // foo() // !foo // ~foo // -foo // foo->bar // f…
4995 $dstat !~ /^for\s*$Constant\s+(?:$Ident|-?$Constant)$/ && # for (...) bar()
5002 …"Macros starting with if should be enclosed by a do - while loop to avoid possible if/else logic d…
5005 … "Macros with multiple statements should be enclosed in a do - while loop\n" . "$herectx");
5013 # Make $define_stmt single line, comment-free, etc
5041 "Macro argument reuse '$arg' - possible side-effects?\n" . "$herectx");
5075 # single-statement macros do not need to be enclosed in do while (0) loop,
5125 "vmlinux.lds.h needs VMLINUX_SYMBOL() around C-visible symbols\n" . $herecurr);
5139 my $ln = $linenr - 1;
5144 my ($whitespace) = ($cond =~ /^((?:\s*\n[+-])*\s*)/s);
5145 my $offset = statement_rawlines($whitespace) - 1;
5154 $ln += statement_rawlines($block) - 1;
5191 if (!defined $suppress_ifbraces{$linenr - 1} &&
5195 # Check the pre-context.
5196 if (substr($line, 0, $-[0]) =~ /(\}\s*)$/) {
5202 ctx_statement_full($linenr, $realcnt, $-[0]);
5222 # Check the post-context.
5229 #print "APW: ALLOWED: chunk-1 block<$block>\n";
5253 fix_delete_line($fixlinenr - 1, $prevrawline);
5268 …"Use of volatile is usually wrong: see Documentation/process/volatile-considered-harmful.rst\n" . …
5271 # Check for user-visible strings broken across lines, which breaks the ability
5277 $prevrawline !~ /(?:\\(?:[ntr]|[0-7]{1,3}|x[0-9a-fA-F]{1,2})|;\s*|\{\s*)"\s*$/) {
5282 $last_coalesced_string_linenr != $linenr - 1) {
5289 fix_delete_line($fixlinenr - 1, $prevrawline);
5294 fix_insert_line($fixlinenr - 1, $fixedline);
5311 # This does not work very well for -f --file checking as it depends on patch
5312 # context providing the function name or a single line form for in-file
5333 if ($line =~ /$String[A-Z_]/ || $line =~ /[A-Za-z0-9_]$String/) {
5344 # check for non-standard and hex prefixed decimal printf formats
5348 my $string = substr($rawline, $-[1], $+[1] - $-[1]);
5353 "\%L$1 is non-standard C, use %ll$1\n" . $herecurr);
5359 "%Z$1 is non-standard C, use %z$1\n" . $herecurr);
5394 if ($lines[$linenr - 2] =~ /^\+(\t*)if\s*\(\s*$tested\s*\)\s*$/) {
5399 if ($lines[$linenr - 1] =~ /^\+(\t+)$func\s*\(\s*$tested\s*\)\s*;\s*$/) {
5408 fix_delete_line($fixlinenr - 1, $prevrawline);
5421 my $testline = $lines[$linenr - 3];
5423 my ($s, $c) = ctx_statement_block($linenr - 3, $realcnt, 0);
5434 $line =~ /\b$logFunctions\s*\(.*\b(KERN_[A-Z]+)\b/) {
5454 … "Possible precedence defect with mask then right shift - may need parentheses\n" . $herecurr);
5518 # check for __read_mostly with const non-pointer (should just be const)
5547 … "usleep_range is preferred over udelay; see Documentation/timers/timers-howto.txt\n" . $herecurr);
5551 "long udelay - prefer mdelay; see arch/arm/include/asm/delay.h\n" . $herecurr);
5559 …"msleep < 20ms can sleep for up to 20ms; see Documentation/timers/timers-howto.txt\n" . $herecurr);
5593 # check for spinlock_t definitions without a comment.
5599 "$1 definition without comment\n" . $herecurr);
5602 # check for memory barriers without a comment.
5627 "memory barrier without comment\n" . $herecurr);
5633 if ($realfile !~ m@^include/asm-generic/@ &&
5638 "__smp memory barriers shouldn't be used outside barrier.h and asm-generic\n" . $herecurr);
5641 # check for waitqueue_active without a comment.
5645 "waitqueue_active without comment\n" . $herecurr);
5656 … m@^.\s*\#\s*if.*\b(__i386__|__powerpc64__|__sun__|__s390x__)\b@ && $realfile !~ m@include/asm-@) {
5719 …"__printf(string-index, first-to-check) is preferred over __attribute__((format(printf, string-ind…
5730 …"__scanf(string-index, first-to-check) is preferred over __attribute__((format(scanf, string-index…
5831 my $fmt = get_quoted_string($lines[$count - 1], raw_line($count, 0));
5855 $use = " - use %pS instead";
5957 …"usleep_range should not use min == max args; see Documentation/timers/timers-howto.txt\n" . "$her…
5961 …"usleep_range args reversed, use min then max; see Documentation/timers/timers-howto.txt\n" . "$he…
6080 …"__setup appears un-documented -- check Documentation/admin-guide/kernel-parameters.rst\n" . $here…
6087 … "unnecessary cast may hide bugs, see http://c-faq.com/malloc/mallocnocast.html\n" . $herecurr);
6114 !($r1 =~ /^$Constant$/ || $r1 =~ /^[A-Z_][A-Z0-9_]*$/)) {
6162 …if ($line =~ /^\+\s*#\s*if\s+defined(?:\s*\(?\s*|\s+)(CONFIG_[A-Z_]+)\s*\)?\s*\|\|\s*defined(?:\s*…
6178 $prevline--;
6179 my $rline = $rawlines[$prevline - 1];
6180 my $fline = $lines[$prevline - 1];
6182 next if ($fline =~ /^\-/);
6184 $has_break = 1 if ($rline =~ /fall[\s_-]*(through|thru)/i);
6192 "Possible switch case/default not preceded by break or fallthrough comment\n" . $herecurr);
6219 "Use of the '$1' macro makes the build non-deterministic\n" . $herecurr);
6225 "Using yield() is generally wrong. See yield() kernel-doc (sched/core.c)\n" . $herecurr);
6291 …"usage of NR_CPUS is often wrong - consider using cpu_possible(), num_possible_cpus(), for_each_po…
6297 … "#define of '$1' is wrong - use Kconfig variables or standard guards instead\n" . $herecurr);
6331 "lockdep_no_validate class is reserved for device->mutex.\n" . $herecurr);
6346 …E_ATTR\s*\(\s*(\w+)\s*,\s*\(?\s*(\s*(?:${multi_mode_perms_string_search}|0[0-7]{3,3})\s*)\s*\)?\s*…
6408 my $func = $entry->[0];
6409 my $arg_pos = $entry->[1];
6417 $arg_pos--;
6470 if ($#rawlines == -1) {
6480 # This is not a patch, and we are are in 'no-patch' mode so
6486 if (!$is_patch && $filename !~ /cover-letter\.patch$/) {
6488 "Does not appear to be a unified-diff format patch\n");
6492 "Missing Signed-off-by: line(s)\n");
6509 mechanically convert to the typical style using --fix or --fix-inplace.
6528 $newfile .= ".EXPERIMENTAL-checkpatch-fixes" if (!$fix_inplace);
6552 Wrote EXPERIMENTAL --fix correction(s) to '$newfile'