Lines Matching refs:line
90 --no-signoff do not check for 'Signed-off-by' line
93 --terse one line per report
111 --max-line-length=n set the maximum line length, (default $max_line_length)
126 If correctable single-line errors exist, create
226 my $line = $_;
228 $line =~ s/\s*\n?$//g;
229 $line =~ s/^\s*//g;
230 $line =~ s/\s+/ /g;
232 next if ($line =~ m/^\s*#/);
233 next if ($line =~ m/^\s*$/);
235 my @words = split(" ", $line);
255 my $line = $_;
256 $line =~ s/\s+$//;
258 if ($line =~ /^\s*\*\*(.+)\*\*$/) {
266 if ($line =~ /^(?:\s{4,}|$)/) {
267 $line =~ s/^\s{4}//;
268 $desc .= $line;
310 'max-line-length=i' => \$max_line_length,
936 my $line = $_;
938 $line =~ s/\s*\n?$//g;
939 $line =~ s/^\s*//g;
941 next if ($line =~ m/^\s*#/);
942 next if ($line =~ m/^\s*$/);
944 my ($suspect, $fix) = split(/\|\|/, $line);
956 my $line = $_;
958 $line =~ s/\s*\n?$//g;
959 $line =~ s/^\s*//g;
961 next if ($line =~ m/^\s*#/);
962 next if ($line =~ m/^\s*$/);
963 next if ($line =~ m/, disabled/i);
965 $line =~ s/,.*$//;
967 my ($suspect, $fix) = split(/->/, $line);
984 my $line = $_;
986 $line =~ s/\s*\n?$//g;
987 $line =~ s/^\s*//g;
989 next if ($line =~ m/^\s*#/);
990 next if ($line =~ m/^\s*$/);
991 if ($line =~ /\s/) {
992 print("$file: '$line' invalid - ignored\n");
997 $$wordsRef .= $line;
1121 foreach my $line (@lines) {
1122 next if ($line !~ /(?:[A-Z][a-z]|[a-z][A-Z])/);
1123 if ($line =~ /^[ \t]*(?:#[ \t]*define|typedef\s+$Type)\s+(\w*(?:[A-Z][a-z]|[a-z][A-Z])\w*)/) {
1125 } elsif ($line =~ /^\s*$Declare\s+(\w*(?:[A-Z][a-z]|[a-z][A-Z])\w*)\s*[\(\[,;]/) {
1127 } elsif ($line =~ /^\s*(?:union|struct|enum)\s+(\w*(?:[A-Z][a-z]|[a-z][A-Z])\w*)\s*[;\{]/) {
1243 # while read line ; do
1244 # git log --format='%H %s' -1 $line |
1283 foreach my $line (split(/\n/, $lines)) {
1284 $line =~ /^([0-9a-fA-F]{40,40}) (.*)$/;
1545 my ($line) = @_;
1547 # Drop the diff line leader and expand tabs
1548 $line =~ s/^.//;
1549 $line = expand_tabs($line);
1551 # Pick the indent from the front of the line.
1552 my ($white) = ($line =~ /^(\s*)/);
1554 return (length($line), length($white));
1569 my ($line) = @_;
1579 $res = substr($line, 0, 1);
1581 for ($off = 1; $off < length($line); $off++) {
1582 $c = substr($line, $off, 1);
1586 if ($sanitise_quote eq '' && substr($line, $off, 2) eq '/*') {
1593 if ($sanitise_quote eq '*/' && substr($line, $off, 2) eq '*/') {
1599 if ($sanitise_quote eq '' && substr($line, $off, 2) eq '//') {
1662 my ($line, $rawline) = @_;
1664 return "" if (!defined($line) || !defined($rawline));
1665 return "" if ($line !~ m/($String)/g);
1671 my $line = $linenr - 1;
1694 for (; $remain > 0; $line++) {
1695 last if (!defined $lines[$line]);
1696 next if ($lines[$line] =~ /^-/);
1699 $blk .= $lines[$line] . "\n";
1701 $line++;
1784 # We are truly at the end, so shuffle to the next line.
1787 $line++;
1800 $line, $remain + 1, $off - $loff + 1, $level);
1806 # Strip the diff line prefixes and rip blank lines at start and end.
1877 my $line;
1886 for ($line = $start; $remain > 0; $line++) {
1887 next if ($rawlines[$line] =~ /^-/);
1890 $blk .= $rawlines[$line];
1893 if ($lines[$line] =~ /^.\s*#\s*(?:ifndef|ifdef|if)\s/) {
1895 } elsif ($lines[$line] =~ /^.\s*#\s*(?:else|elif)\b/) {
1897 } elsif ($lines[$line] =~ /^.\s*#\s*endif\b/) {
1901 foreach my $c (split(//, $lines[$line])) {
1917 push(@res, $rawlines[$line]);
1957 # If c99 comment on the current line, or the line before or after
1965 # Catch a comment on the end of the line itself.
1974 my $line = $rawlines[$linenr - 1];
1975 #warn " $line\n";
1976 if ($linenr == $first_line and $line =~ m@^.\s*\*@) {
1979 if ($line =~ m@/\*@) {
1985 $current_comment .= $line . "\n" if ($in_comment);
1986 if ($line =~ m@\*/@) {
2010 my $line;
2012 $line = $rawlines[$offset++];
2013 next if (defined($line) && $line =~ /^-/);
2017 return $line;
2272 my ($possible, $line) = @_;
2292 warn "CHECK<$possible> ($line)\n" if ($dbg_possible > 2);
2303 warn "MODIFIER: $modifier ($possible) ($line)\n" if ($dbg_possible);
2309 warn "POSSIBLE: $possible ($line)\n" if ($dbg_possible);
2314 warn "NOTPOSS: $possible ($line)\n" if ($dbg_possible > 1);
2411 my $line = $old_line; #don't modify the array
2412 if ($line =~ /^(?:\+\+\+|\-\-\-)\s+\S+/) { #new filename
2414 } elsif ($line =~ /^\@\@ -\d+,\d+ \+\d+,\d+ \@\@/) { #new hunk
2416 fixup_current_range(\$line, $delta_offset, 0);
2433 push(@lines, $line);
2444 my ($linenr, $line) = @_;
2448 LINE => $line,
2454 my ($linenr, $line) = @_;
2458 LINE => $line,
2571 my ($line) = @_;
2575 my $opens = $line =~ tr/\(/\(/;
2576 my $closes = $line =~ tr/\)/\)/;
2584 my $len = length($line);
2587 my $string = substr($line, $pos);
2590 } elsif (substr($line, $pos, 1) eq '(') {
2597 return length(expand_tabs(substr($line, 0, $last_openparen))) + 1;
2601 my ($line, $rawline) = @_;
2604 for my $i (0 .. (length($line) - 1)) {
2605 if (substr($line, $i, 1) eq "$;") {
2645 my $has_patch_separator = 0; #Found a --- line
2665 # Trace the real file/line as we go.
2697 my $line;
2700 $line = $rawline;
2743 # is the start of a diff block and this line starts
2757 $line = sanitise_line($rawline);
2759 push(@lines, $line);
2762 $realcnt-- if ($line =~ /^(?:\+| |$)/);
2768 #print "-->$line\n";
2770 if ($setup_docs && $line =~ /^\+/) {
2771 push(@setup_docs, $line);
2780 foreach my $line (@lines) {
2783 my $sline = $line; #copy of $line
2787 my $raw_comment = get_raw_comment($line, $rawline);
2791 ($line =~ /^ mode change [0-7]+ => [0-7]+ \S+\s*$/ ||
2792 ($line =~ /^rename (?:from|to) \S+\s*$/ ||
2793 $line =~ /^diff --git a\/[\w\/\.\_\-]+ b\/\S+\s*$/))) {
2797 #extract the line range in the file after the patch is applied
2799 $line =~ /^\@\@ -\d+(?:,\d+)? \+(\d+)(,(\d+))? \@\@(.*)/) {
2823 # track the line number as we move through the hunk, note that
2826 } elsif ($line =~ /^( |\+|$)/) {
2830 # Measure the line length and indent.
2833 # Track the previous line.
2834 ($prevline, $stashline) = ($stashline, $line);
2838 #warn "line<$line>\n";
2851 if ($line =~ /^diff --git.*?(\S+)$/) {
2856 } elsif ($line =~ /^\+\+\+\s+(\S+)/) {
2875 #make up the handle for any error we report on this line
2924 if ($line !~ /^\s*$/) {
2935 (($line =~ m@^\s+diff\b.*a/([\w/]+)@ &&
2936 $line =~ m@^\s+diff\b.*a/[\w/]+\s+b/$1\b@) ||
2937 $line =~ m@^\s*(?:\-\-\-\s+a/|\+\+\+\s+b/)@ ||
2938 $line =~ m/^\s*\@\@ \-\d+,\d+ \+\d+,\d+ \@\@/)) {
2945 if ($line =~ /^new (file )?mode.*[7531]\d{0,2}$/) {
2955 if (decode("MIME-Header", $line) =~ /^From:\s*(.*)/) {
2961 $author = encode("utf8", $author) if ($line =~ /=\?utf-8\?/i);
2967 if ($line =~ /^\s*signed-off-by:\s*(.*)/i) {
3006 if ($line =~ /^---$/) {
3013 if ($line =~ /^\s*MAINTAINERS\s*\|/) {
3019 $line =~ /^(\s*)([a-z0-9_-]+by:|$signature_tags)(\s*)(.*)/i) {
3151 my $sig_nospace = $line;
3194 $line =~ /^\s*fixes:?\s*(?:commit\s*)?[0-9a-f]{5,}\b/i) {
3204 if ($line =~ /(\s*fixes:?)\s+([0-9a-f]{5,})\s+($balanced_parens)/i) {
3210 $tag_space = 0 if ($line =~ /^fixes:? [0-9a-f]{5,} ($balanced_parens)/i);
3229 "Please use correct Fixes: style 'Fixes: <12 chars of sha1> (\"<title line>\")' - ie: 'Fixes: $cid (\"$ctitle\")'\n" . $herecurr) &&
3238 $line =~ /^Subject:.*\b(?:checkpatch|sparse|smatch)\b[^:]/i) {
3240 "A patch subject line should describe the change not the tool that found it\n" . $herecurr);
3244 if ($realfile eq '' && !$has_patch_separator && $line =~ /^\s*change-id:/i) {
3254 ($line =~ /^\s*(?:WARNING:|BUG:)/ ||
3255 $line =~ /^\s*\[\s*\d+\.\d{6,6}\s*\]/ ||
3257 $line =~ /^\s*\[\<[0-9a-fA-F]{8,}\>\]/) ||
3258 $line =~ /^(?:\s+\w+:\s+[0-9a-fA-F]+){3,3}/ ||
3259 $line =~ /^\s*\#\d+\s*\[[0-9a-fA-F]+\]\s*\w+ at [0-9a-fA-F]+/) {
3264 # Check for line lengths > 75 in commit log, warn once
3266 length($line) > 75 &&
3267 !($line =~ /^\s*[a-zA-Z0-9_\/\.]+\s+\|\s+\d+/ ||
3269 $line =~ /^\s*(?:[\w\.\-\+]*\/)++[\w\.\-\+]+:/ ||
3271 $line =~ /^\s*(?:Fixes:|$link_tags_search|$signature_tags)/i ||
3272 # A Fixes:, link or signature tag line
3275 "Prefer a maximum 75 chars per line (possible unwrapped commit description?)\n" . $herecurr);
3279 # Reset possible stack dump if a blank line is found
3281 $line =~ /^\s*$/) {
3287 $line =~ /^\s*(\w+:)\s*http/ && $1 !~ /^$link_tags_search$/) {
3290 "Patch version information should be after the --- line\n" . $herecurr);
3299 $line =~ /^\s*(\w+:)\s*(\S+)/) {
3309 if ($in_commit_log && $line =~ /^#/) {
3328 $line !~ /^\s*(?:Link|Patchwork|http|https|BugLink|base-commit):/i &&
3329 $line !~ /^This reverts commit [0-9a-f]{7,40}/ &&
3330 (($line =~ /\bcommit\s+[0-9a-f]{5,}\b/i ||
3331 ($line =~ /\bcommit\s*$/i && defined($rawlines[$linenr]) && $rawlines[$linenr] =~ /^\s*[0-9a-f]{5,}\b/i)) ||
3332 ($line =~ /(?:\s|^)[0-9a-f]{12,40}(?:[\s"'\(\[]|$)/i &&
3333 $line !~ /[\<\[][0-9a-f]{12,40}[\>\]]/i &&
3334 $line !~ /\bfixes:\s*[0-9a-f]{12,40}/i))) {
3348 my $input = $line;
3349 if ($line =~ /(?:\bcommit\s+[0-9a-f]{5,}|\bcommit\s*$)/i) {
3387 "Please use git commit description style 'commit <12+ chars of sha1> (\"<title line>\")' - ie: '${init_char}ommit $id (\"$description\")'\n" . $herectx);
3389 #don't report the next line if this line ends in commit and the sha1 hash is the next line
3390 $last_git_commit_id_linenr = $linenr if ($line =~ /\bcommit\s*$/i);
3401 ($line =~ /^(?:new|deleted) file mode\s*\d+\s*$/ ||
3402 $line =~ /^rename (?:from|to) [\w\/\.\-]+\s*$/ ||
3403 ($line =~ /\{\s*([\w\/\.\-]*)\s*\=\>\s*([\w\/\.\-]*)\s*\}/ &&
3413 ($line =~ /^new file mode\s*\d+\s*$/) &&
3420 if ($realcnt != 0 && $line !~ m{^(?:\+|-| |\\ No newline|$)}) {
3422 "patch seems to be corrupt (line wrapped?)\n" .
3427 if (($realfile =~ /^$/ || $line =~ /^\+/) &&
3440 # (not a header line and we haven't seen the patch filename)
3465 while ($line =~ m{(?:^|\s)(/\S*)}g) {
3479 ($in_commit_log || $line =~ /^(?:\+|Subject:)/i)) {
3499 if ($in_commit_log && $line =~ /(^fixes:|\bcommit)\s+([0-9a-f]{6,40})\b/i) {
3564 next if (!$hunk_line || $line =~ /^-/);
3567 if ($line =~ /^\+.*\015/) {
3570 "DOS line endings\n" . $herevet) &&
3601 # 'choice' is usually the last thing on the line (though
3604 $line =~ /^\+\s*(?:config|menuconfig|choice)\b/) {
3689 ($line =~ /\+(EXTRA_[A-Z]+FLAGS).*/)) {
3704 (($realfile =~ /\.dtsi?$/ && $line =~ /^\+\s*compatible\s*=\s*\"/) ||
3705 ($realfile =~ /\.[ch]$/ && $line =~ /^\+.*\.compatible\s*=\s*\"/))) {
3760 "Missing or malformed SPDX-License-Identifier tag in line $checklicenseline\n" . $herecurr);
3796 # check for using SPDX-License-Identifier on the wrong line number
3799 substr($line, @-, @+ - @-) eq "$;" x (@+ - @-)) {
3801 "Misplaced SPDX-License-Identifier tag - use line $checklicenseline instead\n" . $herecurr);
3804 # line length limit (with some exclusions)
3812 # There are 3 different line length message types:
3820 if ($line =~ /^\+/ && $length > $max_line_length) {
3823 # Check the allowed long line types first
3827 if ($line =~ /^\+\s*$logFunctions\s*\(\s*(?:(?:KERN_\S+\s*|[^"]*))?($String\s*(?:|,|\)\s*;)\s*)$/ &&
3828 length(expand_tabs(substr($line, 1, length($line) - length($1) - 1))) <= $max_line_length) {
3833 } elsif ($line =~ /^\+\s*$String\s*(?:\s*|,|\)\s*;)\s*$/ ||
3834 $line =~ /^\+\s*#\s*define\s+\w+\s+$String$/) {
3838 } elsif ($line =~ /^\+.*\bEFI_GUID\s*\(/ ||
3839 $line =~ /^\+\s*(?:\w+)?\s*DEFINE_PER_CPU/) {
3849 } elsif ($line =~ /($;[\s$;]*)$/ &&
3850 length(expand_tabs(substr($line, 1, length($line) - length($1) - 1))) <= $max_line_length) {
3855 length(expand_tabs(substr($line, 1, length($line) - length($1) - 1))) <= $max_line_length) {
3864 "line length of $length exceeds $max_line_length columns\n" . $herecurr);
3869 if ($line =~ /^\+/ && defined $lines[$linenr] && $lines[$linenr] =~ /^\\ No newline at end of file/) {
3871 "adding a line without newline at end of file\n" . $herecurr) &&
3879 $line =~ /^\+\s*(?:[A-Z]+_)?SYM_[A-Z]+_(?:START|END)(?:_[A-Z_]+)?\s*\(\s*\.L/) {
3887 # at the beginning of a line any tabs must come first and anything
3913 # check for assignments on the start of a line
3917 "Assignment operator '$1' should be on the previous line\n" . $hereprev) &&
3919 # add assignment operator to the previous line, remove from current line
3925 # check for && or || at the start of a line
3929 "Logical continuations should be on the previous line\n" . $hereprev) &&
3931 # insert logical operator at last non-comment, non-whitepsace char on previous line
3952 # check multi-line statement indentation matches previous line
3961 $line =~ /^(\+| )([ \t]*)/;
3974 $fix && $line =~ /^\+/) {
3989 if ($line =~ /^\+(.*)\(\s*$Type\s*\)([ \t]++)((?![={]|\\$|$Attribute|__attribute__))/ &&
4006 "networking block comments don't use an empty /* line, use /* Comment...\n" . $hereprev);
4013 $rawline =~ /^\+/ && #line is new
4025 "Block comments use a trailing */ on a separate line\n" . $herecurr);
4030 $line =~ /^\+[ \t]*$;/ && #leading comment
4048 "Block comments should align the * on each line\n" . $hereprev);
4055 $line =~ /^\+/ &&
4056 !($line =~ /^\+\s*$/ ||
4057 $line =~ /^\+\s*(?:EXPORT_SYMBOL|early_param)/ ||
4058 $line =~ /^\+\s*MODULE_/i ||
4059 $line =~ /^\+\s*\#\s*(?:end|elif|else)/ ||
4060 $line =~ /^\+[a-z_]*init/ ||
4061 $line =~ /^\+\s*(?:static\s+)?[A-Z_]*ATTR/ ||
4062 $line =~ /^\+\s*DECLARE/ ||
4063 $line =~ /^\+\s*builtin_[\w_]*driver/ ||
4064 $line =~ /^\+\s*__setup/)) {
4066 "Please use a blank line after function/struct/union/enum declarations\n" . $hereprev) &&
4074 $line =~ /^\+\s*$/ &&
4086 # (declarations must have the same indentation and not be at the start of line)
4105 # not starting a section or a macro "\" extended line
4124 "Missing a blank line after declarations\n" . $hereprev) &&
4131 # check for spaces at the beginning of a line.
4136 if ($rawline =~ /^\+ / && $line !~ /^\+ *(?:$;|#|$Ident:)/) {
4139 "please, no spaces at the start of a line\n" . $herevet) &&
4148 # check for unusual line ending [ or (
4149 if ($line =~ /^\+.*([\[\(])\s*$/) {
4165 # check indentation of any line with a bare else
4166 # (but not if it is a multiple line "if (foo) return bar; else return baz;")
4167 # if the previous line is a break or return and is indented 1 tab more...
4179 # check indentation of a line with a break;
4180 # if the previous line is a goto, return or break
4200 if ($line =~ /\b(__dev(init|exit)(data|const|))\b/) {
4208 #print "LINE<$line>\n";
4226 # Find the real next line.
4287 if ($line=~/\bswitch\s*\(.*\)/) {
4308 # if/while/etc brace do not go on next line, unless defining a do while loop,
4309 # or if that brace on the next line is for something else
4310 if ($line =~ /(.*)\b((?:if|while|for|switch|(?:[a-z_]+|)for_each[a-z_]+)\s*\(|do\b|else\b)/ && $line !~ /^.\s*\#/) {
4315 if ($line =~ /^\+\t{6,}/) {
4335 #print "pre<$pre_ctx>\nline<$line>\nctx<$ctx>\nnext<$lines[$ctx_ln - 1]>\n";
4339 "that open brace { should be on the previous line\n" .
4356 if ($line =~ /\b(?:(?:if|while|for|(?:[a-z_]+|)for_each[a-z_]+)\s*\(|(?:do|else)\b)/ && $line !~ /^.\s*#/ && $line !~ /\}\s*while\s*/) {
4372 # Make sure we remove the line prefixes as we have
4373 # none on the first line, and are going to readd them
4380 # We want to check the first line inside the block
4382 # 1) any blank line termination
4383 # 2) any opening brace { on end of the line
4443 #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";
4457 my $opline = $line; $opline =~ s/^./ /;
4470 next if ($line =~ /^[^\+]/);
4475 if ($line =~ /^\+\s*(?:$Declare)?([A-Za-z_][A-Za-z\d_]*)\s*=/) {
4477 if ($line =~ /^\+\s*(?:$Declare)?$var\s*=\s*(?:$var|\*\s*\(?\s*&\s*\(?\s*$var\s*\)?\s*\)?)\s*[;,]/) {
4485 $line =~ /^\+\s*(?!\#\s*(?!define\s+|if))\s*$Lval/) {
4488 $line =~ /^.\s*($Lval)/;
4492 "Avoid multiple line dereference - prefer '$ref'\n" . $hereprev);
4496 while ($line =~ m{\b($Declare)\s*(?!char\b|short\b|int\b|long\b)\s*($Ident)?\s*[=,;\[\)\(]}g) {
4521 if ($line =~ /^.\s*$Declare\s*$/) {
4524 } elsif ($dbg_type > 1 && $line =~ /^.+($Declare)/) {
4532 if ($line =~ /^.\s*$Modifier\s*$/) {
4535 } elsif ($dbg_attr > 1 && $line =~ /^.+($Modifier)/) {
4542 # check for initialisation to aggregates open brace on the next line
4543 if ($line =~ /^.\s*{/ &&
4546 "that open brace { should be on the previous line\n" . $hereprev) &&
4547 $fix && $prevline =~ /^\+/ && $line =~ /^\+/) {
4553 $fixedline = $line;
4560 # Checks which are anchored on the added line.
4563 # check for malformed paths in #include statements (uses RAW line)
4577 if ($line =~ m{//}) {
4581 my $line = $fixed[$fixlinenr];
4582 if ($line =~ /\/\/(.*)$/) {
4589 $line =~ s@//.*@@;
4626 ($line =~ /EXPORT_SYMBOL.*\((.*)\)/)) {
4637 if ($line =~ /^\+$Type\s*$Ident(?:\s+$Modifier)*\s*=\s*($zero_initializer)\s*;/ &&
4646 if ($line =~ /^\+.*\bstatic\s.*=\s*($zero_initializer)\s*;/) {
4683 if ($line =~ /\bstatic\s+const\s+char\s*\*\s*(\w+)\s*\[\s*\]\s*=\s*/) {
4690 if ($line =~ /^\+\s*const\s+(char|unsigned\s+char|_*u8|(?:[us]_)?int8_t)\s+\w+\s*\[\s*(?:\w+\s*)?\]\s*=\s*"/) {
4699 if ($line =~ /\bstatic\s+char\s+(\w+)\s*\[\s*\]\s*=\s*"/) {
4730 if ($line =~ /^.\s+(?:static\s+|const\s+)?char\s+\*\s*\w+\s*\[\s*\]\s*=\s*\{/) {
4737 if ($line =~ m@\bsizeof\s*\(\s*($Lval)\s*\)@) {
4739 if ($line =~ m@\b(sizeof\s*\(\s*\Q$array\E\s*\)\s*/\s*sizeof\s*\(\s*\Q$array\E\s*\[\s*0\s*\]\s*\))@) {
4750 if ($line =~ /(\b$Type\s*$Ident)\s*\(\s*\)/) {
4760 if ($line =~ /\btypedef\s/ &&
4761 $line !~ /\btypedef\s+$Type\s*\(\s*\*?$Ident\s*\)\s*\(/ &&
4762 $line !~ /\btypedef\s+$Type\s+$Ident\s*\(/ &&
4763 $line !~ /\b$typeTypedefs\b/ &&
4764 $line !~ /\b__bitwise\b/) {
4771 while ($line =~ m{(\($NonptrType(\s*(?:$Modifier\b\s*|\*\s*)+)\))}g) {
4796 while ($line =~ m{(\b$NonptrType(\s*(?:$Modifier\b\s*|\*\s*)+)($Ident))}g) {
4826 if ($line =~ /\b(?!AA_|BUILD_|DCCP_|IDA_|KVM_|RWLOCK_|snd_|SPIN_)(?:[a-zA-Z_]*_)?BUG(?:_ON)?(?:_[A-Z_]+)?\s*\(/) {
4834 if ($line =~ /\bLINUX_VERSION_CODE\b/) {
4840 if ($line =~ /\bprintk_ratelimit\s*\(/) {
4846 if ($line =~ /\bprintk\s*\(\s*(?!KERN_[A-Z]+\b)/) {
4852 if ($line =~ /\b(printk(_once|_ratelimited)?)\s*\(\s*KERN_([A-Z]+)/) {
4868 if ($line =~ /\bdev_printk\s*\(\s*KERN_([A-Z]+)/) {
4878 if ($line =~ /\b(trace_printk|trace_puts|ftrace_vprintk)\s*\(/) {
4886 if ($line =~ /\bENOSYS\b/) {
4894 if (!$file && $line =~ /\bENOTSUPP\b/) {
4902 # function brace can't be on same line, except for #defines of do while,
4903 # or if closed on same line
4909 "open brace '{' following function definitions go on the next line\n" . $herecurr) &&
4924 # open braces for enum, union and struct go on the same line.
4925 if ($line =~ /^.\s*{/ &&
4928 "open brace '{' following $1 go on the same line\n" . $hereprev) &&
4929 $fix && $prevline =~ /^\+/ && $line =~ /^\+/) {
4943 if ($line =~ /^.\s*(?:typedef\s+)?(enum|union|struct)(?:\s+$Ident){1,2}[=\{]/) {
4955 if ($line =~ /^.\s*($Declare)\((\s*)\*(\s*)($Ident)(\s*)\)(\s*)\(/) {
5024 # 2. at the beginning of a line for slice initialisers -- [0...10] = 5,
5026 while ($line =~ /(.*?\s)\[/g) {
5041 while ($line =~ /($Ident)\s+\(/g) {
5043 my $ctx_before = substr($line, 0, $-[1]);
5076 if (!($line=~/\#\s*include/)) {
5165 # ; should have either the end of line or a space or \ after it
5387 if ($line =~ /^\+.*\S\s+;\s*$/) {
5397 if ($line =~ /^.\s*$Lval\s*=\s*$Lval\s*=(?!=)/) {
5404 ## if ($line =~ /^.\s*$Type\s+$Ident(?:\s*=[^,{]*)?\s*,\s*$Ident.*/ &&
5405 ## $line !~ /^.\s*$Type\s+$Ident(?:\s*=[^,{]*)?\s*,\s*$Type\s*$Ident.*/) {
5409 ## my $ln = $line;
5419 if (($line =~ /\(.*\)\{/ && $line !~ /\($Type\)\{/) ||
5420 $line =~ /\b(?:else|do)\{/) {
5429 ## if ($line =~ /^.\t+$Type\s+$Ident(?:\s*=.*)?;/ &&
5437 # on the line
5438 if ($line =~ /}(?!(?:,|;|\)|\}))\S/) {
5448 if ($line =~ /\[\s/ && $line !~ /\[\s*$/) {
5456 if ($line =~ /\s\]/) {
5466 if ($line =~ /\(\s/ && $line !~ /\(\s*(?:\\)?$/ &&
5467 $line !~ /for\s*\(\s+;/) {
5475 if ($line =~ /(\s+)\)/ && $line !~ /^.\s*\)/ &&
5476 $line !~ /for\s*\(.*;\s+\)/ &&
5477 $line !~ /:\s+\)/) {
5489 while ($line =~ /(?:[^&]&\s*|\*)\(\s*($Ident\s*(?:$Member\s*)+)\s*\)/g) {
5501 if ($line =~ /(\bif\s*|)(\(\s*$Ident\s*(?:$Member\s*)+\))[ \t]*\(/ && $1 !~ /^if/) {
5513 # when !drivers/staging or command-line uses --strict
5582 # at end-of-function, with the previous line a single leading tab, then return;
5583 # and the line before that not a goto label target like "out:"
5595 $line =~ /\bif\s*((?:\(\s*){2,})/) {
5599 if ($line =~ /\bif\s*(?:\(\s*){$count,$count}$LvalOrFunc\s*($Compare)\s*$LvalOrFunc(?:\s*\)){$count,$count}/) {
5612 $line =~ /^\+(.*)\b($Constant|[A-Z_][A-Z0-9_]*)\s*($Compare)\s*($LvalOrFunc)/) {
5646 if ($line =~ /\b(if|while|for|switch)\(/) {
5657 if ($line =~ /do\s*(?!{)/) {
5680 $line =~ /\b(?:if|while|for)\s*\(/ && $line !~ /^.\s*#/) {
5712 # Find out what is on the end of the line after the
5732 "trailing statements should be on next line\n" . $herecurr . $stat_real) &&
5749 if ($line =~ /
5765 if ($line =~ /^.\s*(?:}\s*)?else\b(.*)/) {
5770 "trailing statements should be on next line\n" . $herecurr);
5774 if ($line =~ /}\s*if\b/) {
5776 "trailing statements should be on next line (or did you mean 'else if'?)\n" .
5780 if ($line =~ /^.\s*(?:case\s*.*|default\s*):/g &&
5781 $line !~ /\G(?:
5787 "trailing statements should be on next line\n" . $herecurr);
5792 if ($prevline=~/}\s*$/ and $line=~/^.\s*else\s*/ &&
5796 $fix && $prevline =~ /^\+/ && $line =~ /^\+/) {
5810 if ($prevline=~/}\s*$/ and $line=~/^.\s*while\s*/ &&
5814 # Find out what is on the end of the line after the
5822 $fix && $prevline =~ /^\+/ && $line =~ /^\+/) {
5836 while ($line =~ m{($Constant|$Lval)}g) {
5873 if ($line =~ /\#\s*define.*\\\s+$/) {
5882 # itself <asm/foo.h> (uses RAW line)
5907 $line =~ /^.\s*\#\s*define\s*$Ident(\()?/) {
6005 # Make $define_stmt single line, comment-free, etc
6054 # check for line continuations outside of #defines, preprocessor #, and asm
6057 $line =~ s/(\w+)/$maybe_linker_symbol{$1}++/ge;
6058 #print "REAL: $realfile\nln: $line\nkeys:", sort keys %maybe_linker_symbol;
6061 $line !~ /^\+\s*\#.*\\$/ && # preprocessor
6062 $line !~ /^\+.*\b(__asm__|asm)\b.*\\$/ && # asm
6063 $line =~ /^\+.*\\$/) {
6065 "Avoid unnecessary line continuations\n" . $herecurr);
6074 $line =~ /^.\s*\#\s*define\s+$Ident(\()?/) {
6114 if ($line =~ /(^.*)\bif\b/ && $1 !~ /else\s*$/) {
6135 # We have looked at and allowed this specific line.
6177 $line =~ /\b(if|while|for|else)\b/) {
6181 if (substr($line, 0, $-[0]) =~ /(\}\s*)$/) {
6227 # check for single line unbalanced braces
6234 if (($line =~ /^.\s*}\s*$/ && $prevrawline =~ /^.\s*$/)) {
6251 if ($line =~ /\bvolatile\b/ && $line !~ /$asm_volatile/) {
6260 if ($line =~ /^\+\s*$String/ &&
6268 my $extracted_string = get_quoted_string($line, $rawline);
6297 # context providing the function name or a single line form for in-file
6299 if ($line =~ /^\+.*$String/ &&
6301 get_quoted_string($line, $rawline) =~ /\b$context_function\b/ &&
6302 length(get_quoted_string($line, $rawline)) != (length($context_function) + 2)) {
6329 if ($line =~ /$String[A-Z_]/ ||
6330 ($line =~ /([A-Za-z0-9_]+)$String/ && $1 !~ /^[Lu]$/)) {
6334 while ($line =~ /($String)/g) {
6343 if ($line =~ /$String\s*[Lu]?"/) {
6347 while ($line =~ /($String)(?=\s*")/g) {
6357 while ($line =~ /(?:^|")([X\t]*)(?:"|$)/g) {
6379 # check for line continuations in quoted strings with odd counts of "
6382 "Avoid line continuations in quoted strings\n" . $herecurr);
6386 if ($line =~ /^.\s*\#\s*if\s+0\b/) {
6392 if ($line =~ /^.\s*\#\s*if\s+1\b/) {
6401 if ($line =~ /\b(kfree|usb_free_urb|debugfs_remove(?:_recursive)?|(?:kmem_cache|mempool|dma_pool)_destroy)$expr/) {
6431 if ($line =~ /\bk[v]?free_rcu\s*\([^(]+\)/) {
6432 if ($line =~ /\bk[v]?free_rcu\s*\([^,]+\)/) {
6440 if ($line =~ /^\+.*\b$logFunctions\s*\(/ &&
6448 # print("line: <$line>\nprevline: <$prevline>\ns: <$s>\nc: <$c>\n\n\n");
6458 if ($line !~ /printk(?:_ratelimited|_once)?\s*\(/ &&
6459 $line =~ /\b$logFunctions\s*\(.*\b(KERN_[A-Z]+)\b/) {
6469 if ($line =~ /\bprintk\s*\(\s*KERN_CONT\b|\bpr_cont\s*\(/) {
6476 $line =~ /\b$logFunctions\s*\(/ &&
6498 $line =~ /$LvalOrFunc\s*\&\s*($LvalOrFunc)\s*>>/ &&
6506 while ($line =~ /\b$LvalOrFunc\s*(==|\!=)\s*NULL\b/g) {
6519 if ($line =~ /(\b$InitAttribute\b)/) {
6521 if ($line =~ /^\+\s*static\s+(?:const\s+)?(?:$attr\s+)?($NonptrTypeWithAttr)\s+(?:$attr\s+)?($Ident(?:\[[^]]*\])?)\s*[=;]/) {
6537 if ($line =~ /\bconst\b/ && $line =~ /($InitAttributeData)/) {
6551 if ($line !~ /\bconst\b/ && $line =~ /($InitAttributeConst)/) {
6566 if ($line =~ /\b__read_mostly\b/ &&
6567 $line =~ /($Type)\s*$Ident/ && $1 !~ /\*\s*$/ && $1 =~ /\bconst\b/) {
6577 $line =~ /(__constant_(?:htons|ntohs|[bl]e(?:16|32|64)_to_cpu|cpu_to_[bl]e(?:16|32|64)))\s*\(/) {
6589 if ($line =~ /\budelay\s*\(\s*(\d+)\s*\)/) {
6603 if ($line =~ /\bmsleep\s*\((\d+)\);/) {
6611 if ($line =~ /\bjiffies\s*$Compare|$Compare\s*jiffies\b/) {
6617 if ($line =~ /\bget_jiffies_64\s*\(\s*\)\s*$Compare|$Compare\s*get_jiffies_64\s*\(\s*\)/) {
6623 # if ($line =~ /^.\s*\#\s*if(|n)def/ && ($realfile =~ /\.c$/)) {
6630 if ($line =~ /^.\s*\#\s*(ifdef|ifndef|elif)\s\s+/) {
6641 if ($line =~ /^.\s*(struct\s+mutex|spinlock_t)\s+\S+;/ ||
6642 $line =~ /^.\s*(DEFINE_MUTEX)\s*\(/) {
6670 if ($line =~ /\b(?:$all_barriers)\s*\(/) {
6681 $line =~ m/\b(?:$underscore_smp_barriers)\s*\(/ &&
6682 $line !~ m/^.\s*\#\s*define\s+(?:$underscore_smp_barriers)\s*\(/) {
6688 if ($line =~ /\bwaitqueue_active\s*\(/) {
6696 if ($line =~ /\bdata_race\s*\(/) {
6704 if ($line =~ m@^.\s*\#\s*if.*\b(__i386__|__powerpc64__|__sun__|__s390x__)\b@ && $realfile !~ m@include/asm-@) {
6710 if ($line =~ /\b($Type)\s+($Storage)\b/) {
6715 if ($line =~ /\b$Storage\b/ &&
6716 $line !~ /^.\s*$Storage/ &&
6717 $line =~ /^.\s*(.+?)\$Storage\s/ &&
6725 if ($line =~ /\b$Type\s+$Inline\b/ ||
6726 $line =~ /\b$Inline\s+$Storage\b/) {
6733 $line =~ /\b(__inline__|__inline)\b/) {
6809 $line =~ /(?:$Declare|$DeclareMisordered)\s*$Ident\s*$balanced_parens\s*(?:$Attribute)?\s*;/ &&
6810 ($line =~ /\b__attribute__\s*\(\s*\(.*\bweak\b/ ||
6811 $line =~ /\b__weak\b/)) {
6819 $line =~ /\b($Declare)\s*$Ident\s*[=;,\[]/) {
6836 if ($line =~ /(\(\s*$C90_int_types\s*\)\s*)($Constant)\b/) {
6856 if ($line =~ /\bsizeof\s*\(\s*\&/) {
6862 if ($line =~ /\bsizeof\s+((?:\*\s*|)$Lval|$Type(?:\s+$Lval|))/) {
6871 if ($line =~ /^.\s*\bstruct\s+spinlock\s+\w+\s*;/) {
6878 my $fmt = get_quoted_string($line, $rawline);
7006 if ($line =~ /\bstrcpy\s*\(/) {
7012 if ($line =~ /\bstrlcpy\s*\(/) {
7018 if ($line =~ /\bstrncpy\s*\(/) {
7066 $line =~ /\bsscanf\b/ &&
7080 $line =~ /\bsscanf\b/) {
7097 $line =~ /^\+\s*(extern\s+)$Type\s*$Ident\s*\(/s) {
7182 "open brace '{' following function definitions go on the next line\n" . $herectx);
7197 if ($line =~ /\*\s*\)\s*$allocFunctions\b/) {
7205 $line =~ /\b($Lval)\s*\=\s*(?:$balanced_parens)?\s*((?:kv|k|v)[mz]alloc(?:_node)?)\s*\(\s*(sizeof\s*\(\s*struct\s+$Lval\s*\))/) {
7243 $line =~ /\b($Lval)\s*\=\s*(?:$balanced_parens)?\s*krealloc\s*\(\s*($Lval)\s*,/ &&
7250 if ($line =~ /\b((?:devm_)?((?:k|kv)?(calloc|malloc_array)(?:_node)?))\s*\(\s*sizeof\b/) {
7256 if ($line =~ /;\s*;\s*$/) {
7266 $line =~ /#\s*define\s+\w+\s+\(?\s*1\s*([ulUL]*)\s*\<\<\s*(?:\d+|$Ident)\s*\)?/) {
7283 if ($line =~ /^\+\s*#\s*if\s+defined(?:\s*\(?\s*|\s+)(${CONFIG_}[A-Z_]+)\s*\)?\s*\|\|\s*defined(?:\s*\(?\s*|\s+)\1_MODULE\s*\)?\s*$/) {
7326 if ($line =~ /\b__FUNCTION__\b/) {
7335 while ($line =~ /\b(__(?:DATE|TIME|TIMESTAMP)__)\b/g) {
7341 if ($line =~ /\byield\s*\(\s*\)/) {
7347 if ($line =~ /\+\s*(.*?)\b(true|false|$Lval)\s*(==|\!=)\s*(true|false|$Lval)\b(.*)$/i) {
7374 if ($line =~ /^.\s*sema_init.+,\W?0\W?\)/) {
7380 if ($line =~ /\b((simple|strict)_(strto(l|ll|ul|ull)))\s*\(/) {
7386 if ($line =~ /^.\s*__initcall\s*\(/) {
7392 if ($line =~ /\bspin_is_locked\(/) {
7398 if ($line =~ /\b($deprecated_apis_search)\b\s*\(/) {
7408 $line !~ /\bconst\b/ &&
7409 $line =~ /\bstruct\s+($const_structs)\b(?!\s*\{)/) {
7417 if ($line =~ /\bNR_CPUS\b/ &&
7418 $line !~ /^.\s*\s*#\s*if\b.*\bNR_CPUS\b/ &&
7419 $line !~ /^.\s*\s*#\s*define\b.*\bNR_CPUS\b/ &&
7420 $line !~ /^.\s*$Declare\s.*\[[^\]]*NR_CPUS[^\]]*\]/ &&
7421 $line !~ /\[[^\]]*\.\.\.[^\]]*NR_CPUS[^\]]*\]/ &&
7422 $line !~ /\[[^\]]*NR_CPUS[^\]]*\.\.\.[^\]]*\]/ &&
7423 $line !~ /^.\s*\.\w+\s*=\s*.*\bNR_CPUS\b/)
7430 if ($line =~ /\+\s*#\s*define\s+((?:__)?ARCH_(?:HAS|HAVE)\w*)\b/) {
7437 $line =~ /\b((?:un)?likely)\s*\(\s*$FuncArg\s*\)\s*$Compare/) {
7443 if ($line =~ /\breturn\s+sysfs_emit\s*\(\s*$FuncArg\s*,\s*($String)/ &&
7464 if ($line =~ /\b(?:(?:un)?likely)\s*\(\s*!?\s*(IS_ERR(?:_OR_NULL|_VALUE)?|WARN)/) {
7470 if ($line =~ /\bin_atomic\s*\(/) {
7497 if ($line =~ /\b($rcu_trace_funcs)\s*\(/) {
7505 if ($line =~ /^.\s*lockdep_set_novalidate_class\s*\(/ ||
7506 $line =~ /__lockdep_no_validate__\s*\)/ ) {
7515 if ($line =~ /debugfs_create_\w+.*\b$mode_perms_world_writable\b/ ||
7516 $line =~ /DEVICE_ATTR.*\b$mode_perms_world_writable\b/) {
7586 $line =~ /$mode_perms_search/) {
7619 while ($line =~ m{\b($multi_mode_perms_string_search)\b}g) {
7630 if ($line =~ /\bMODULE_LICENSE\s*\(\s*($String)\s*\)/) {
7631 my $extracted_string = get_quoted_string($line, $rawline);
7655 if ($line =~ /\.extra[12]\s*=\s*&(zero|one|int_max)\b/) {
7686 "Missing Signed-off-by: line(s)\n");
7700 "Missing Signed-off-by: line by nominal patch author '$author'\n");