Lines Matching refs:line

87   --no-signoff               do not check for 'Signed-off-by' line
90 --terse one line per report
108 --max-line-length=n set the maximum line length, (default $max_line_length)
123 If correctable single-line errors exist, create
223 my $line = $_;
225 $line =~ s/\s*\n?$//g;
226 $line =~ s/^\s*//g;
227 $line =~ s/\s+/ /g;
229 next if ($line =~ m/^\s*#/);
230 next if ($line =~ m/^\s*$/);
232 my @words = split(" ", $line);
252 my $line = $_;
253 $line =~ s/\s+$//;
255 if ($line =~ /^\s*\*\*(.+)\*\*$/) {
263 if ($line =~ /^(?:\s{4,}|$)/) {
264 $line =~ s/^\s{4}//;
265 $desc .= $line;
307 'max-line-length=i' => \$max_line_length,
875 my $line = $_;
877 $line =~ s/\s*\n?$//g;
878 $line =~ s/^\s*//g;
880 next if ($line =~ m/^\s*#/);
881 next if ($line =~ m/^\s*$/);
883 my ($suspect, $fix) = split(/\|\|/, $line);
895 my $line = $_;
897 $line =~ s/\s*\n?$//g;
898 $line =~ s/^\s*//g;
900 next if ($line =~ m/^\s*#/);
901 next if ($line =~ m/^\s*$/);
902 next if ($line =~ m/, disabled/i);
904 $line =~ s/,.*$//;
906 my ($suspect, $fix) = split(/->/, $line);
923 my $line = $_;
925 $line =~ s/\s*\n?$//g;
926 $line =~ s/^\s*//g;
928 next if ($line =~ m/^\s*#/);
929 next if ($line =~ m/^\s*$/);
930 if ($line =~ /\s/) {
931 print("$file: '$line' invalid - ignored\n");
936 $$wordsRef .= $line;
1059 foreach my $line (@lines) {
1060 next if ($line !~ /(?:[A-Z][a-z]|[a-z][A-Z])/);
1061 if ($line =~ /^[ \t]*(?:#[ \t]*define|typedef\s+$Type)\s+(\w*(?:[A-Z][a-z]|[a-z][A-Z])\w*)/) {
1063 } elsif ($line =~ /^\s*$Declare\s+(\w*(?:[A-Z][a-z]|[a-z][A-Z])\w*)\s*[\(\[,;]/) {
1065 } elsif ($line =~ /^\s*(?:union|struct|enum)\s+(\w*(?:[A-Z][a-z]|[a-z][A-Z])\w*)\s*[;\{]/) {
1181 # while read line ; do
1182 # git log --format='%H %s' -1 $line |
1221 foreach my $line (split(/\n/, $lines)) {
1222 $line =~ /^([0-9a-fA-F]{40,40}) (.*)$/;
1483 my ($line) = @_;
1485 # Drop the diff line leader and expand tabs
1486 $line =~ s/^.//;
1487 $line = expand_tabs($line);
1489 # Pick the indent from the front of the line.
1490 my ($white) = ($line =~ /^(\s*)/);
1492 return (length($line), length($white));
1507 my ($line) = @_;
1517 $res = substr($line, 0, 1);
1519 for ($off = 1; $off < length($line); $off++) {
1520 $c = substr($line, $off, 1);
1524 if ($sanitise_quote eq '' && substr($line, $off, 2) eq '/*') {
1531 if ($sanitise_quote eq '*/' && substr($line, $off, 2) eq '*/') {
1537 if ($sanitise_quote eq '' && substr($line, $off, 2) eq '//') {
1600 my ($line, $rawline) = @_;
1602 return "" if (!defined($line) || !defined($rawline));
1603 return "" if ($line !~ m/($String)/g);
1609 my $line = $linenr - 1;
1632 for (; $remain > 0; $line++) {
1633 last if (!defined $lines[$line]);
1634 next if ($lines[$line] =~ /^-/);
1637 $blk .= $lines[$line] . "\n";
1639 $line++;
1722 # We are truly at the end, so shuffle to the next line.
1725 $line++;
1738 $line, $remain + 1, $off - $loff + 1, $level);
1744 # Strip the diff line prefixes and rip blank lines at start and end.
1815 my $line;
1824 for ($line = $start; $remain > 0; $line++) {
1825 next if ($rawlines[$line] =~ /^-/);
1828 $blk .= $rawlines[$line];
1831 if ($lines[$line] =~ /^.\s*#\s*(?:ifndef|ifdef|if)\s/) {
1833 } elsif ($lines[$line] =~ /^.\s*#\s*(?:else|elif)\b/) {
1835 } elsif ($lines[$line] =~ /^.\s*#\s*endif\b/) {
1839 foreach my $c (split(//, $lines[$line])) {
1855 push(@res, $rawlines[$line]);
1895 # If c99 comment on the current line, or the line before or after
1903 # Catch a comment on the end of the line itself.
1912 my $line = $rawlines[$linenr - 1];
1913 #warn " $line\n";
1914 if ($linenr == $first_line and $line =~ m@^.\s*\*@) {
1917 if ($line =~ m@/\*@) {
1923 $current_comment .= $line . "\n" if ($in_comment);
1924 if ($line =~ m@\*/@) {
1948 my $line;
1950 $line = $rawlines[$offset++];
1951 next if (defined($line) && $line =~ /^-/);
1955 return $line;
2210 my ($possible, $line) = @_;
2230 warn "CHECK<$possible> ($line)\n" if ($dbg_possible > 2);
2241 warn "MODIFIER: $modifier ($possible) ($line)\n" if ($dbg_possible);
2247 warn "POSSIBLE: $possible ($line)\n" if ($dbg_possible);
2252 warn "NOTPOSS: $possible ($line)\n" if ($dbg_possible > 1);
2349 my $line = $old_line; #don't modify the array
2350 if ($line =~ /^(?:\+\+\+|\-\-\-)\s+\S+/) { #new filename
2352 } elsif ($line =~ /^\@\@ -\d+,\d+ \+\d+,\d+ \@\@/) { #new hunk
2354 fixup_current_range(\$line, $delta_offset, 0);
2371 push(@lines, $line);
2382 my ($linenr, $line) = @_;
2386 LINE => $line,
2392 my ($linenr, $line) = @_;
2396 LINE => $line,
2509 my ($line) = @_;
2513 my $opens = $line =~ tr/\(/\(/;
2514 my $closes = $line =~ tr/\)/\)/;
2522 my $len = length($line);
2525 my $string = substr($line, $pos);
2528 } elsif (substr($line, $pos, 1) eq '(') {
2535 return length(expand_tabs(substr($line, 0, $last_openparen))) + 1;
2539 my ($line, $rawline) = @_;
2542 for my $i (0 .. (length($line) - 1)) {
2543 if (substr($line, $i, 1) eq "$;") {
2583 my $has_patch_separator = 0; #Found a --- line
2603 # Trace the real file/line as we go.
2635 my $line;
2638 $line = $rawline;
2681 # is the start of a diff block and this line starts
2695 $line = sanitise_line($rawline);
2697 push(@lines, $line);
2700 $realcnt-- if ($line =~ /^(?:\+| |$)/);
2706 #print "-->$line\n";
2708 if ($setup_docs && $line =~ /^\+/) {
2709 push(@setup_docs, $line);
2718 foreach my $line (@lines) {
2721 my $sline = $line; #copy of $line
2725 my $raw_comment = get_raw_comment($line, $rawline);
2729 ($line =~ /^ mode change [0-7]+ => [0-7]+ \S+\s*$/ ||
2730 ($line =~ /^rename (?:from|to) \S+\s*$/ ||
2731 $line =~ /^diff --git a\/[\w\/\.\_\-]+ b\/\S+\s*$/))) {
2735 #extract the line range in the file after the patch is applied
2737 $line =~ /^\@\@ -\d+(?:,\d+)? \+(\d+)(,(\d+))? \@\@(.*)/) {
2761 # track the line number as we move through the hunk, note that
2764 } elsif ($line =~ /^( |\+|$)/) {
2768 # Measure the line length and indent.
2771 # Track the previous line.
2772 ($prevline, $stashline) = ($stashline, $line);
2776 #warn "line<$line>\n";
2789 if ($line =~ /^diff --git.*?(\S+)$/) {
2794 } elsif ($line =~ /^\+\+\+\s+(\S+)/) {
2813 #make up the handle for any error we report on this line
2862 if ($line !~ /^\s*$/) {
2873 (($line =~ m@^\s+diff\b.*a/([\w/]+)@ &&
2874 $line =~ m@^\s+diff\b.*a/[\w/]+\s+b/$1\b@) ||
2875 $line =~ m@^\s*(?:\-\-\-\s+a/|\+\+\+\s+b/)@ ||
2876 $line =~ m/^\s*\@\@ \-\d+,\d+ \+\d+,\d+ \@\@/)) {
2883 if ($line =~ /^new (file )?mode.*[7531]\d{0,2}$/) {
2893 if (decode("MIME-Header", $line) =~ /^From:\s*(.*)/) {
2899 $author = encode("utf8", $author) if ($line =~ /=\?utf-8\?/i);
2905 if ($line =~ /^\s*signed-off-by:\s*(.*)/i) {
2944 if ($line =~ /^---$/) {
2951 if ($line =~ /^\s*MAINTAINERS\s*\|/) {
2957 $line =~ /^(\s*)([a-z0-9_-]+by:|$signature_tags)(\s*)(.*)/i) {
3089 my $sig_nospace = $line;
3120 $line =~ /^Subject:.*\b(?:checkpatch|sparse|smatch)\b[^:]/i) {
3122 "A patch subject line should describe the change not the tool that found it\n" . $herecurr);
3126 if ($realfile eq '' && !$has_patch_separator && $line =~ /^\s*change-id:/i) {
3136 ($line =~ /^\s*(?:WARNING:|BUG:)/ ||
3137 $line =~ /^\s*\[\s*\d+\.\d{6,6}\s*\]/ ||
3139 $line =~ /^\s*\[\<[0-9a-fA-F]{8,}\>\]/) ||
3140 $line =~ /^(?:\s+\w+:\s+[0-9a-fA-F]+){3,3}/ ||
3141 $line =~ /^\s*\#\d+\s*\[[0-9a-fA-F]+\]\s*\w+ at [0-9a-fA-F]+/) {
3146 # Check for line lengths > 75 in commit log, warn once
3148 length($line) > 75 &&
3149 !($line =~ /^\s*[a-zA-Z0-9_\/\.]+\s+\|\s+\d+/ ||
3151 $line =~ /^\s*(?:[\w\.\-]+\/)++[\w\.\-]+:/ ||
3153 $line =~ /^\s*(?:Fixes:|Link:|$signature_tags)/i ||
3154 # A Fixes: or Link: line or signature tag line
3157 "Possible unwrapped commit description (prefer a maximum 75 chars per line)\n" . $herecurr);
3161 # Reset possible stack dump if a blank line is found
3163 $line =~ /^\s*$/) {
3168 if ($in_commit_log && $line =~ /^#/) {
3187 $line !~ /^\s*(?:Link|Patchwork|http|https|BugLink|base-commit):/i &&
3188 $line !~ /^This reverts commit [0-9a-f]{7,40}/ &&
3189 (($line =~ /\bcommit\s+[0-9a-f]{5,}\b/i ||
3190 ($line =~ /\bcommit\s*$/i && defined($rawlines[$linenr]) && $rawlines[$linenr] =~ /^\s*[0-9a-f]{5,}\b/i)) ||
3191 ($line =~ /(?:\s|^)[0-9a-f]{12,40}(?:[\s"'\(\[]|$)/i &&
3192 $line !~ /[\<\[][0-9a-f]{12,40}[\>\]]/i &&
3193 $line !~ /\bfixes:\s*[0-9a-f]{12,40}/i))) {
3207 my $input = $line;
3208 if ($line =~ /(?:\bcommit\s+[0-9a-f]{5,}|\bcommit\s*$)/i) {
3246 "Please use git commit description style 'commit <12+ chars of sha1> (\"<title line>\")' - ie: '${init_char}ommit $id (\"$description\")'\n" . $herectx);
3248 #don't report the next line if this line ends in commit and the sha1 hash is the next line
3249 $last_git_commit_id_linenr = $linenr if ($line =~ /\bcommit\s*$/i);
3254 ($line =~ /^(?:new|deleted) file mode\s*\d+\s*$/ ||
3255 $line =~ /^rename (?:from|to) [\w\/\.\-]+\s*$/ ||
3256 ($line =~ /\{\s*([\w\/\.\-]*)\s*\=\>\s*([\w\/\.\-]*)\s*\}/ &&
3266 ($line =~ /^new file mode\s*\d+\s*$/) &&
3273 if ($realcnt != 0 && $line !~ m{^(?:\+|-| |\\ No newline|$)}) {
3275 "patch seems to be corrupt (line wrapped?)\n" .
3280 if (($realfile =~ /^$/ || $line =~ /^\+/) &&
3293 # (not a header line and we haven't seen the patch filename)
3318 while ($line =~ m{(?:^|\s)(/\S*)}g) {
3332 ($in_commit_log || $line =~ /^(?:\+|Subject:)/i)) {
3352 if ($in_commit_log && $line =~ /(^fixes:|\bcommit)\s+([0-9a-f]{6,40})\b/i) {
3417 next if (!$hunk_line || $line =~ /^-/);
3420 if ($line =~ /^\+.*\015/) {
3423 "DOS line endings\n" . $herevet) &&
3454 # 'choice' is usually the last thing on the line (though
3457 $line =~ /^\+\s*(?:config|menuconfig|choice)\b/) {
3542 ($line =~ /\+(EXTRA_[A-Z]+FLAGS).*/)) {
3557 (($realfile =~ /\.dtsi?$/ && $line =~ /^\+\s*compatible\s*=\s*\"/) ||
3558 ($realfile =~ /\.[ch]$/ && $line =~ /^\+.*\.compatible\s*=\s*\"/))) {
3613 "Missing or malformed SPDX-License-Identifier tag in line $checklicenseline\n" . $herecurr);
3644 # check for using SPDX-License-Identifier on the wrong line number
3647 substr($line, @-, @+ - @-) eq "$;" x (@+ - @-)) {
3649 "Misplaced SPDX-License-Identifier tag - use line $checklicenseline instead\n" . $herecurr);
3652 # line length limit (with some exclusions)
3660 # There are 3 different line length message types:
3668 if ($line =~ /^\+/ && $length > $max_line_length) {
3671 # Check the allowed long line types first
3675 if ($line =~ /^\+\s*$logFunctions\s*\(\s*(?:(?:KERN_\S+\s*|[^"]*))?($String\s*(?:|,|\)\s*;)\s*)$/ &&
3676 length(expand_tabs(substr($line, 1, length($line) - length($1) - 1))) <= $max_line_length) {
3681 } elsif ($line =~ /^\+\s*$String\s*(?:\s*|,|\)\s*;)\s*$/ ||
3682 $line =~ /^\+\s*#\s*define\s+\w+\s+$String$/) {
3686 } elsif ($line =~ /^\+.*\bEFI_GUID\s*\(/ ||
3687 $line =~ /^\+\s*(?:\w+)?\s*DEFINE_PER_CPU/) {
3697 } elsif ($line =~ /($;[\s$;]*)$/ &&
3698 length(expand_tabs(substr($line, 1, length($line) - length($1) - 1))) <= $max_line_length) {
3703 length(expand_tabs(substr($line, 1, length($line) - length($1) - 1))) <= $max_line_length) {
3712 "line length of $length exceeds $max_line_length columns\n" . $herecurr);
3717 if ($line =~ /^\+/ && defined $lines[$linenr] && $lines[$linenr] =~ /^\\ No newline at end of file/) {
3719 "adding a line without newline at end of file\n" . $herecurr) &&
3727 $line =~ /^\+\s*(?:[A-Z]+_)?SYM_[A-Z]+_(?:START|END)(?:_[A-Z_]+)?\s*\(\s*\.L/) {
3735 # at the beginning of a line any tabs must come first and anything
3761 # check for assignments on the start of a line
3765 "Assignment operator '$1' should be on the previous line\n" . $hereprev) &&
3767 # add assignment operator to the previous line, remove from current line
3773 # check for && or || at the start of a line
3777 "Logical continuations should be on the previous line\n" . $hereprev) &&
3779 # insert logical operator at last non-comment, non-whitepsace char on previous line
3800 # check multi-line statement indentation matches previous line
3809 $line =~ /^(\+| )([ \t]*)/;
3822 $fix && $line =~ /^\+/) {
3837 if ($line =~ /^\+(.*)\(\s*$Type\s*\)([ \t]++)((?![={]|\\$|$Attribute|__attribute__))/ &&
3854 "networking block comments don't use an empty /* line, use /* Comment...\n" . $hereprev);
3861 $rawline =~ /^\+/ && #line is new
3873 "Block comments use a trailing */ on a separate line\n" . $herecurr);
3878 $line =~ /^\+[ \t]*$;/ && #leading comment
3896 "Block comments should align the * on each line\n" . $hereprev);
3903 $line =~ /^\+/ &&
3904 !($line =~ /^\+\s*$/ ||
3905 $line =~ /^\+\s*EXPORT_SYMBOL/ ||
3906 $line =~ /^\+\s*MODULE_/i ||
3907 $line =~ /^\+\s*\#\s*(?:end|elif|else)/ ||
3908 $line =~ /^\+[a-z_]*init/ ||
3909 $line =~ /^\+\s*(?:static\s+)?[A-Z_]*ATTR/ ||
3910 $line =~ /^\+\s*DECLARE/ ||
3911 $line =~ /^\+\s*builtin_[\w_]*driver/ ||
3912 $line =~ /^\+\s*__setup/)) {
3914 "Please use a blank line after function/struct/union/enum declarations\n" . $hereprev) &&
3922 $line =~ /^\+\s*$/ &&
3934 # (declarations must have the same indentation and not be at the start of line)
3953 # not starting a section or a macro "\" extended line
3972 "Missing a blank line after declarations\n" . $hereprev) &&
3979 # check for spaces at the beginning of a line.
3984 if ($rawline =~ /^\+ / && $line !~ /^\+ *(?:$;|#|$Ident:)/) {
3987 "please, no spaces at the start of a line\n" . $herevet) &&
3996 # check for unusual line ending [ or (
3997 if ($line =~ /^\+.*([\[\(])\s*$/) {
4013 # check indentation of any line with a bare else
4014 # (but not if it is a multiple line "if (foo) return bar; else return baz;")
4015 # if the previous line is a break or return and is indented 1 tab more...
4027 # check indentation of a line with a break;
4028 # if the previous line is a goto, return or break
4048 if ($line =~ /\b(__dev(init|exit)(data|const|))\b/) {
4056 #print "LINE<$line>\n";
4074 # Find the real next line.
4135 if ($line=~/\bswitch\s*\(.*\)/) {
4156 # if/while/etc brace do not go on next line, unless defining a do while loop,
4157 # or if that brace on the next line is for something else
4158 if ($line =~ /(.*)\b((?:if|while|for|switch|(?:[a-z_]+|)for_each[a-z_]+)\s*\(|do\b|else\b)/ && $line !~ /^.\s*\#/) {
4163 if ($line =~ /^\+\t{6,}/) {
4183 #print "pre<$pre_ctx>\nline<$line>\nctx<$ctx>\nnext<$lines[$ctx_ln - 1]>\n";
4187 "that open brace { should be on the previous line\n" .
4204 if ($line =~ /\b(?:(?:if|while|for|(?:[a-z_]+|)for_each[a-z_]+)\s*\(|(?:do|else)\b)/ && $line !~ /^.\s*#/ && $line !~ /\}\s*while\s*/) {
4220 # Make sure we remove the line prefixes as we have
4221 # none on the first line, and are going to readd them
4228 # We want to check the first line inside the block
4230 # 1) any blank line termination
4231 # 2) any opening brace { on end of the line
4291 #print "line<$line> prevline<$prevline> indent<$indent> sindent<$sindent> check<$check> continuation<$continuation> s<$s> cond_lines<$cond_lines> stat_real<$stat_real> stat<$stat>\n";
4305 my $opline = $line; $opline =~ s/^./ /;
4318 next if ($line =~ /^[^\+]/);
4323 if ($line =~ /^\+\s*(?:$Declare)?([A-Za-z_][A-Za-z\d_]*)\s*=/) {
4325 if ($line =~ /^\+\s*(?:$Declare)?$var\s*=\s*(?:$var|\*\s*\(?\s*&\s*\(?\s*$var\s*\)?\s*\)?)\s*[;,]/) {
4333 $line =~ /^\+\s*(?!\#\s*(?!define\s+|if))\s*$Lval/) {
4336 $line =~ /^.\s*($Lval)/;
4340 "Avoid multiple line dereference - prefer '$ref'\n" . $hereprev);
4344 while ($line =~ m{\b($Declare)\s*(?!char\b|short\b|int\b|long\b)\s*($Ident)?\s*[=,;\[\)\(]}g) {
4369 if ($line =~ /^.\s*$Declare\s*$/) {
4372 } elsif ($dbg_type > 1 && $line =~ /^.+($Declare)/) {
4380 if ($line =~ /^.\s*$Modifier\s*$/) {
4383 } elsif ($dbg_attr > 1 && $line =~ /^.+($Modifier)/) {
4390 # check for initialisation to aggregates open brace on the next line
4391 if ($line =~ /^.\s*{/ &&
4394 "that open brace { should be on the previous line\n" . $hereprev) &&
4395 $fix && $prevline =~ /^\+/ && $line =~ /^\+/) {
4401 $fixedline = $line;
4408 # Checks which are anchored on the added line.
4411 # check for malformed paths in #include statements (uses RAW line)
4425 if ($line =~ m{//}) {
4429 my $line = $fixed[$fixlinenr];
4430 if ($line =~ /\/\/(.*)$/) {
4437 $line =~ s@//.*@@;
4473 ($line =~ /EXPORT_SYMBOL.*\((.*)\)/)) {
4484 if ($line =~ /^\+$Type\s*$Ident(?:\s+$Modifier)*\s*=\s*($zero_initializer)\s*;/ &&
4493 if ($line =~ /^\+.*\bstatic\s.*=\s*($zero_initializer)\s*;/) {
4530 if ($line =~ /\bstatic\s+const\s+char\s*\*\s*(\w+)\s*\[\s*\]\s*=\s*/) {
4537 if ($line =~ /^\+\s*const\s+(char|unsigned\s+char|_*u8|(?:[us]_)?int8_t)\s+\w+\s*\[\s*(?:\w+\s*)?\]\s*=\s*"/) {
4546 if ($line =~ /\bstatic\s+char\s+(\w+)\s*\[\s*\]\s*=\s*"/) {
4577 if ($line =~ /^.\s+(?:static\s+|const\s+)?char\s+\*\s*\w+\s*\[\s*\]\s*=\s*\{/) {
4584 if ($line =~ m@\bsizeof\s*\(\s*($Lval)\s*\)@) {
4586 if ($line =~ m@\b(sizeof\s*\(\s*\Q$array\E\s*\)\s*/\s*sizeof\s*\(\s*\Q$array\E\s*\[\s*0\s*\]\s*\))@) {
4597 if ($line =~ /(\b$Type\s*$Ident)\s*\(\s*\)/) {
4607 if ($line =~ /\btypedef\s/ &&
4608 $line !~ /\btypedef\s+$Type\s*\(\s*\*?$Ident\s*\)\s*\(/ &&
4609 $line !~ /\btypedef\s+$Type\s+$Ident\s*\(/ &&
4610 $line !~ /\b$typeTypedefs\b/ &&
4611 $line !~ /\b__bitwise\b/) {
4618 while ($line =~ m{(\($NonptrType(\s*(?:$Modifier\b\s*|\*\s*)+)\))}g) {
4643 while ($line =~ m{(\b$NonptrType(\s*(?:$Modifier\b\s*|\*\s*)+)($Ident))}g) {
4673 if ($line =~ /\b(?:BUG|BUG_ON)\b/) {
4681 if ($line =~ /\bLINUX_VERSION_CODE\b/) {
4687 if ($line =~ /\bprintk_ratelimit\s*\(/) {
4693 if ($line =~ /\bprintk\s*\(\s*(?!KERN_[A-Z]+\b)/) {
4699 if ($line =~ /\b(printk(_once|_ratelimited)?)\s*\(\s*KERN_([A-Z]+)/) {
4715 if ($line =~ /\bdev_printk\s*\(\s*KERN_([A-Z]+)/) {
4725 if ($line =~ /\b(trace_printk|trace_puts|ftrace_vprintk)\s*\(/) {
4733 if ($line =~ /\bENOSYS\b/) {
4741 if (!$file && $line =~ /\bENOTSUPP\b/) {
4749 # function brace can't be on same line, except for #defines of do while,
4750 # or if closed on same line
4756 "open brace '{' following function definitions go on the next line\n" . $herecurr) &&
4771 # open braces for enum, union and struct go on the same line.
4772 if ($line =~ /^.\s*{/ &&
4775 "open brace '{' following $1 go on the same line\n" . $hereprev) &&
4776 $fix && $prevline =~ /^\+/ && $line =~ /^\+/) {
4790 if ($line =~ /^.\s*(?:typedef\s+)?(enum|union|struct)(?:\s+$Ident){1,2}[=\{]/) {
4802 if ($line =~ /^.\s*($Declare)\((\s*)\*(\s*)($Ident)(\s*)\)(\s*)\(/) {
4871 # 2. at the beginning of a line for slice initialisers -- [0...10] = 5,
4873 while ($line =~ /(.*?\s)\[/g) {
4888 while ($line =~ /($Ident)\s+\(/g) {
4890 my $ctx_before = substr($line, 0, $-[1]);
4923 if (!($line=~/\#\s*include/)) {
5012 # ; should have either the end of line or a space or \ after it
5234 if ($line =~ /^\+.*\S\s+;\s*$/) {
5244 if ($line =~ /^.\s*$Lval\s*=\s*$Lval\s*=(?!=)/) {
5251 ## if ($line =~ /^.\s*$Type\s+$Ident(?:\s*=[^,{]*)?\s*,\s*$Ident.*/ &&
5252 ## $line !~ /^.\s*$Type\s+$Ident(?:\s*=[^,{]*)?\s*,\s*$Type\s*$Ident.*/) {
5256 ## my $ln = $line;
5266 if (($line =~ /\(.*\)\{/ && $line !~ /\($Type\)\{/) ||
5267 $line =~ /\b(?:else|do)\{/) {
5276 ## if ($line =~ /^.\t+$Type\s+$Ident(?:\s*=.*)?;/ &&
5284 # on the line
5285 if ($line =~ /}(?!(?:,|;|\)|\}))\S/) {
5295 if ($line =~ /\[\s/ && $line !~ /\[\s*$/) {
5303 if ($line =~ /\s\]/) {
5313 if ($line =~ /\(\s/ && $line !~ /\(\s*(?:\\)?$/ &&
5314 $line !~ /for\s*\(\s+;/) {
5322 if ($line =~ /(\s+)\)/ && $line !~ /^.\s*\)/ &&
5323 $line !~ /for\s*\(.*;\s+\)/ &&
5324 $line !~ /:\s+\)/) {
5336 while ($line =~ /(?:[^&]&\s*|\*)\(\s*($Ident\s*(?:$Member\s*)+)\s*\)/g) {
5348 if ($line =~ /(\bif\s*|)(\(\s*$Ident\s*(?:$Member\s*)+\))[ \t]*\(/ && $1 !~ /^if/) {
5360 # when !drivers/staging or command-line uses --strict
5429 # at end-of-function, with the previous line a single leading tab, then return;
5430 # and the line before that not a goto label target like "out:"
5442 $line =~ /\bif\s*((?:\(\s*){2,})/) {
5446 if ($line =~ /\bif\s*(?:\(\s*){$count,$count}$LvalOrFunc\s*($Compare)\s*$LvalOrFunc(?:\s*\)){$count,$count}/) {
5459 $line =~ /^\+(.*)\b($Constant|[A-Z_][A-Z0-9_]*)\s*($Compare)\s*($LvalOrFunc)/) {
5495 if ($line =~ /\b(if|while|for|switch)\(/) {
5506 if ($line =~ /do\s*(?!{)/) {
5529 $line =~ /\b(?:if|while|for)\s*\(/ && $line !~ /^.\s*#/) {
5559 # Find out what is on the end of the line after the
5579 "trailing statements should be on next line\n" . $herecurr . $stat_real);
5584 if ($line =~ /
5600 if ($line =~ /^.\s*(?:}\s*)?else\b(.*)/) {
5605 "trailing statements should be on next line\n" . $herecurr);
5609 if ($line =~ /}\s*if\b/) {
5611 "trailing statements should be on next line (or did you mean 'else if'?)\n" .
5615 if ($line =~ /^.\s*(?:case\s*.*|default\s*):/g &&
5616 $line !~ /\G(?:
5622 "trailing statements should be on next line\n" . $herecurr);
5627 if ($prevline=~/}\s*$/ and $line=~/^.\s*else\s*/ &&
5631 $fix && $prevline =~ /^\+/ && $line =~ /^\+/) {
5645 if ($prevline=~/}\s*$/ and $line=~/^.\s*while\s*/ &&
5649 # Find out what is on the end of the line after the
5657 $fix && $prevline =~ /^\+/ && $line =~ /^\+/) {
5671 while ($line =~ m{($Constant|$Lval)}g) {
5706 if ($line =~ /\#\s*define.*\\\s+$/) {
5715 # itself <asm/foo.h> (uses RAW line)
5740 $line =~ /^.\s*\#\s*define\s*$Ident(\()?/) {
5837 # Make $define_stmt single line, comment-free, etc
5886 # check for line continuations outside of #defines, preprocessor #, and asm
5890 $line !~ /^\+\s*\#.*\\$/ && # preprocessor
5891 $line !~ /^\+.*\b(__asm__|asm)\b.*\\$/ && # asm
5892 $line =~ /^\+.*\\$/) {
5894 "Avoid unnecessary line continuations\n" . $herecurr);
5903 $line =~ /^.\s*\#\s*define\s+$Ident(\()?/) {
5943 if ($line =~ /(^.*)\bif\b/ && $1 !~ /else\s*$/) {
5964 # We have looked at and allowed this specific line.
6006 $line =~ /\b(if|while|for|else)\b/) {
6010 if (substr($line, 0, $-[0]) =~ /(\}\s*)$/) {
6056 # check for single line unbalanced braces
6063 if (($line =~ /^.\s*}\s*$/ && $prevrawline =~ /^.\s*$/)) {
6080 if ($line =~ /\bvolatile\b/ && $line !~ /$asm_volatile/) {
6089 if ($line =~ /^\+\s*$String/ &&
6097 my $extracted_string = get_quoted_string($line, $rawline);
6126 # context providing the function name or a single line form for in-file
6128 if ($line =~ /^\+.*$String/ &&
6130 get_quoted_string($line, $rawline) =~ /\b$context_function\b/ &&
6131 length(get_quoted_string($line, $rawline)) != (length($context_function) + 2)) {
6158 if ($line =~ /$String[A-Z_]/ ||
6159 ($line =~ /([A-Za-z0-9_]+)$String/ && $1 !~ /^[Lu]$/)) {
6163 while ($line =~ /($String)/g) {
6172 if ($line =~ /$String\s*[Lu]?"/) {
6176 while ($line =~ /($String)(?=\s*")/g) {
6186 while ($line =~ /(?:^|")([X\t]*)(?:"|$)/g) {
6208 # check for line continuations in quoted strings with odd counts of "
6211 "Avoid line continuations in quoted strings\n" . $herecurr);
6215 if ($line =~ /^.\s*\#\s*if\s+0\b/) {
6221 if ($line =~ /^.\s*\#\s*if\s+1\b/) {
6230 if ($line =~ /\b(kfree|usb_free_urb|debugfs_remove(?:_recursive)?|(?:kmem_cache|mempool|dma_pool)_destroy)$expr/) {
6260 if ($line =~ /^\+.*\b$logFunctions\s*\(/ &&
6268 # print("line: <$line>\nprevline: <$prevline>\ns: <$s>\nc: <$c>\n\n\n");
6278 if ($line !~ /printk(?:_ratelimited|_once)?\s*\(/ &&
6279 $line =~ /\b$logFunctions\s*\(.*\b(KERN_[A-Z]+)\b/) {
6289 if ($line =~ /\bprintk\s*\(\s*KERN_CONT\b|\bpr_cont\s*\(/) {
6296 $line =~ /\b$logFunctions\s*\(/ &&
6318 $line =~ /$LvalOrFunc\s*\&\s*($LvalOrFunc)\s*>>/ &&
6326 while ($line =~ /\b$LvalOrFunc\s*(==|\!=)\s*NULL\b/g) {
6339 if ($line =~ /(\b$InitAttribute\b)/) {
6341 if ($line =~ /^\+\s*static\s+(?:const\s+)?(?:$attr\s+)?($NonptrTypeWithAttr)\s+(?:$attr\s+)?($Ident(?:\[[^]]*\])?)\s*[=;]/) {
6357 if ($line =~ /\bconst\b/ && $line =~ /($InitAttributeData)/) {
6371 if ($line !~ /\bconst\b/ && $line =~ /($InitAttributeConst)/) {
6386 if ($line =~ /\b__read_mostly\b/ &&
6387 $line =~ /($Type)\s*$Ident/ && $1 !~ /\*\s*$/ && $1 =~ /\bconst\b/) {
6397 $line =~ /(__constant_(?:htons|ntohs|[bl]e(?:16|32|64)_to_cpu|cpu_to_[bl]e(?:16|32|64)))\s*\(/) {
6409 if ($line =~ /\budelay\s*\(\s*(\d+)\s*\)/) {
6423 if ($line =~ /\bmsleep\s*\((\d+)\);/) {
6431 if ($line =~ /\bjiffies\s*$Compare|$Compare\s*jiffies\b/) {
6437 if ($line =~ /\bget_jiffies_64\s*\(\s*\)\s*$Compare|$Compare\s*get_jiffies_64\s*\(\s*\)/) {
6443 # if ($line =~ /^.\s*\#\s*if(|n)def/ && ($realfile =~ /\.c$/)) {
6450 if ($line =~ /^.\s*\#\s*(ifdef|ifndef|elif)\s\s+/) {
6461 if ($line =~ /^.\s*(struct\s+mutex|spinlock_t)\s+\S+;/ ||
6462 $line =~ /^.\s*(DEFINE_MUTEX)\s*\(/) {
6490 if ($line =~ /\b(?:$all_barriers)\s*\(/) {
6501 $line =~ m/\b(?:$underscore_smp_barriers)\s*\(/ &&
6502 $line !~ m/^.\s*\#\s*define\s+(?:$underscore_smp_barriers)\s*\(/) {
6508 if ($line =~ /\bwaitqueue_active\s*\(/) {
6516 if ($line =~ /\bdata_race\s*\(/) {
6524 if ($line =~ m@^.\s*\#\s*if.*\b(__i386__|__powerpc64__|__sun__|__s390x__)\b@ && $realfile !~ m@include/asm-@) {
6530 if ($line =~ /\b($Type)\s+($Storage)\b/) {
6535 if ($line =~ /\b$Storage\b/ &&
6536 $line !~ /^.\s*$Storage/ &&
6537 $line =~ /^.\s*(.+?)\$Storage\s/ &&
6545 if ($line =~ /\b$Type\s+$Inline\b/ ||
6546 $line =~ /\b$Inline\s+$Storage\b/) {
6553 $line =~ /\b(__inline__|__inline)\b/) {
6629 $line =~ /(?:$Declare|$DeclareMisordered)\s*$Ident\s*$balanced_parens\s*(?:$Attribute)?\s*;/ &&
6630 ($line =~ /\b__attribute__\s*\(\s*\(.*\bweak\b/ ||
6631 $line =~ /\b__weak\b/)) {
6639 $line =~ /\b($Declare)\s*$Ident\s*[=;,\[]/) {
6656 if ($line =~ /(\(\s*$C90_int_types\s*\)\s*)($Constant)\b/) {
6676 if ($line =~ /\bsizeof\s*\(\s*\&/) {
6682 if ($line =~ /\bsizeof\s+((?:\*\s*|)$Lval|$Type(?:\s+$Lval|))/) {
6691 if ($line =~ /^.\s*\bstruct\s+spinlock\s+\w+\s*;/) {
6698 my $fmt = get_quoted_string($line, $rawline);
6822 if ($line =~ /\bstrlcpy\s*\(/) {
6870 $line =~ /\bsscanf\b/ &&
6884 $line =~ /\bsscanf\b/) {
6901 $line =~ /^\+\s*(extern\s+)$Type\s*$Ident\s*\(/s) {
6971 "open brace '{' following function definitions go on the next line\n" . $herectx);
6986 if ($line =~ /\*\s*\)\s*$allocFunctions\b/) {
6994 $line =~ /\b($Lval)\s*\=\s*(?:$balanced_parens)?\s*((?:kv|k|v)[mz]alloc(?:_node)?)\s*\(\s*(sizeof\s*\(\s*struct\s+$Lval\s*\))/) {
7030 $line =~ /\b($Lval)\s*\=\s*(?:$balanced_parens)?\s*krealloc\s*\(\s*($Lval)\s*,/ &&
7037 if ($line =~ /\b((?:devm_)?(?:kcalloc|kmalloc_array))\s*\(\s*sizeof\b/) {
7043 if ($line =~ /;\s*;\s*$/) {
7053 $line =~ /#\s*define\s+\w+\s+\(?\s*1\s*([ulUL]*)\s*\<\<\s*(?:\d+|$Ident)\s*\)?/) {
7070 if ($line =~ /^\+\s*#\s*if\s+defined(?:\s*\(?\s*|\s+)(${CONFIG_}[A-Z_]+)\s*\)?\s*\|\|\s*defined(?:\s*\(?\s*|\s+)\1_MODULE\s*\)?\s*$/) {
7113 if ($line =~ /\b__FUNCTION__\b/) {
7122 while ($line =~ /\b(__(?:DATE|TIME|TIMESTAMP)__)\b/g) {
7128 if ($line =~ /\byield\s*\(\s*\)/) {
7134 if ($line =~ /\+\s*(.*?)\b(true|false|$Lval)\s*(==|\!=)\s*(true|false|$Lval)\b(.*)$/i) {
7161 if ($line =~ /^.\s*sema_init.+,\W?0\W?\)/) {
7167 if ($line =~ /\b((simple|strict)_(strto(l|ll|ul|ull)))\s*\(/) {
7173 if ($line =~ /^.\s*__initcall\s*\(/) {
7179 if ($line =~ /\bspin_is_locked\(/) {
7185 if ($line =~ /\b($deprecated_apis_search)\b\s*\(/) {
7195 $line !~ /\bconst\b/ &&
7196 $line =~ /\bstruct\s+($const_structs)\b(?!\s*\{)/) {
7204 if ($line =~ /\bNR_CPUS\b/ &&
7205 $line !~ /^.\s*\s*#\s*if\b.*\bNR_CPUS\b/ &&
7206 $line !~ /^.\s*\s*#\s*define\b.*\bNR_CPUS\b/ &&
7207 $line !~ /^.\s*$Declare\s.*\[[^\]]*NR_CPUS[^\]]*\]/ &&
7208 $line !~ /\[[^\]]*\.\.\.[^\]]*NR_CPUS[^\]]*\]/ &&
7209 $line !~ /\[[^\]]*NR_CPUS[^\]]*\.\.\.[^\]]*\]/ &&
7210 $line !~ /^.\s*\.\w+\s*=\s*.*\bNR_CPUS\b/)
7217 if ($line =~ /\+\s*#\s*define\s+((?:__)?ARCH_(?:HAS|HAVE)\w*)\b/) {
7224 $line =~ /\b((?:un)?likely)\s*\(\s*$FuncArg\s*\)\s*$Compare/) {
7230 if ($line =~ /\breturn\s+sysfs_emit\s*\(\s*$FuncArg\s*,\s*($String)/ &&
7241 if ($line =~ /\b(?:(?:un)?likely)\s*\(\s*!?\s*(IS_ERR(?:_OR_NULL|_VALUE)?|WARN)/) {
7247 if ($line =~ /\bin_atomic\s*\(/) {
7258 if ($line =~ /^.\s*lockdep_set_novalidate_class\s*\(/ ||
7259 $line =~ /__lockdep_no_validate__\s*\)/ ) {
7268 if ($line =~ /debugfs_create_\w+.*\b$mode_perms_world_writable\b/ ||
7269 $line =~ /DEVICE_ATTR.*\b$mode_perms_world_writable\b/) {
7339 $line =~ /$mode_perms_search/) {
7372 while ($line =~ m{\b($multi_mode_perms_string_search)\b}g) {
7383 if ($line =~ /\bMODULE_LICENSE\s*\(\s*($String)\s*\)/) {
7384 my $extracted_string = get_quoted_string($line, $rawline);
7401 if ($line =~ /\.extra[12]\s*=\s*&(zero|one|int_max)\b/) {
7432 "Missing Signed-off-by: line(s)\n");
7446 "Missing Signed-off-by: line by nominal patch author '$author'\n");