diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/checkpatch.pl | 254 | ||||
-rwxr-xr-x | scripts/checkstack.pl | 3 | ||||
-rwxr-xr-x | scripts/kernel-doc | 41 |
3 files changed, 231 insertions, 67 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index dae7d30dca0f..59ad83caa210 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
@@ -9,7 +9,7 @@ use strict; | |||
9 | my $P = $0; | 9 | my $P = $0; |
10 | $P =~ s@.*/@@g; | 10 | $P =~ s@.*/@@g; |
11 | 11 | ||
12 | my $V = '0.09'; | 12 | my $V = '0.10'; |
13 | 13 | ||
14 | use Getopt::Long qw(:config no_auto_abbrev); | 14 | use Getopt::Long qw(:config no_auto_abbrev); |
15 | 15 | ||
@@ -212,6 +212,11 @@ sub ctx_block_level { | |||
212 | 212 | ||
213 | return ctx_block_get($linenr, $remain, 0, '{', '}', 0); | 213 | return ctx_block_get($linenr, $remain, 0, '{', '}', 0); |
214 | } | 214 | } |
215 | sub ctx_statement_level { | ||
216 | my ($linenr, $remain, $off) = @_; | ||
217 | |||
218 | return ctx_block_get($linenr, $remain, 0, '(', ')', $off); | ||
219 | } | ||
215 | 220 | ||
216 | sub ctx_locate_comment { | 221 | sub ctx_locate_comment { |
217 | my ($first_line, $end_line) = @_; | 222 | my ($first_line, $end_line) = @_; |
@@ -255,13 +260,42 @@ sub ctx_has_comment { | |||
255 | return ($cmt ne ''); | 260 | return ($cmt ne ''); |
256 | } | 261 | } |
257 | 262 | ||
263 | sub ctx_expr_before { | ||
264 | my ($line) = @_; | ||
265 | |||
266 | ##print "CHECK<$line>\n"; | ||
267 | |||
268 | my $pos = length($line) - 1; | ||
269 | my $count = 0; | ||
270 | my $c; | ||
271 | |||
272 | for (; $pos >= 0; $pos--) { | ||
273 | $c = substr($line, $pos, 1); | ||
274 | ##print "CHECK: c<$c> count<$count>\n"; | ||
275 | if ($c eq ')') { | ||
276 | $count++; | ||
277 | } elsif ($c eq '(') { | ||
278 | last if (--$count == 0); | ||
279 | } | ||
280 | } | ||
281 | |||
282 | ##print "CHECK: result<" . substr($line, 0, $pos) . ">\n"; | ||
283 | |||
284 | return substr($line, 0, $pos); | ||
285 | } | ||
286 | |||
258 | sub cat_vet { | 287 | sub cat_vet { |
259 | my ($vet) = @_; | 288 | my ($vet) = @_; |
289 | my ($res, $coded); | ||
260 | 290 | ||
261 | $vet =~ s/\t/^I/; | 291 | $res = ''; |
262 | $vet =~ s/$/\$/; | 292 | while ($vet =~ /([^[:cntrl:]]*)([[:cntrl:]])/g) { |
293 | $coded = sprintf("^%c", unpack('C', $2) + 64); | ||
294 | $res .= $1 . $coded; | ||
295 | } | ||
296 | $res =~ s/$/\$/; | ||
263 | 297 | ||
264 | return $vet; | 298 | return $res; |
265 | } | 299 | } |
266 | 300 | ||
267 | my @report = (); | 301 | my @report = (); |
@@ -310,8 +344,17 @@ sub process { | |||
310 | my $first_line = 0; | 344 | my $first_line = 0; |
311 | 345 | ||
312 | my $Ident = qr{[A-Za-z\d_]+}; | 346 | my $Ident = qr{[A-Za-z\d_]+}; |
313 | my $Storage = qr{extern|static}; | 347 | my $Storage = qr{extern|static|asmlinkage}; |
314 | my $Sparse = qr{__user|__kernel|__force|__iomem|__must_check|__init_refok}; | 348 | my $Sparse = qr{ |
349 | __user| | ||
350 | __kernel| | ||
351 | __force| | ||
352 | __iomem| | ||
353 | __must_check| | ||
354 | __init_refok| | ||
355 | fastcall | ||
356 | }x; | ||
357 | my $Inline = qr{inline|__always_inline|noinline}; | ||
315 | my $NonptrType = qr{ | 358 | my $NonptrType = qr{ |
316 | \b | 359 | \b |
317 | (?:const\s+)? | 360 | (?:const\s+)? |
@@ -345,11 +388,18 @@ sub process { | |||
345 | (?:\s+$Sparse)* | 388 | (?:\s+$Sparse)* |
346 | }x; | 389 | }x; |
347 | my $Declare = qr{(?:$Storage\s+)?$Type}; | 390 | my $Declare = qr{(?:$Storage\s+)?$Type}; |
348 | my $Attribute = qr{const|__read_mostly|__init|__initdata|__meminit}; | 391 | my $Attribute = qr{ |
349 | 392 | const| | |
393 | __read_mostly| | ||
394 | __(?:mem|cpu|dev|)(?:initdata|init) | ||
395 | }x; | ||
350 | my $Member = qr{->$Ident|\.$Ident|\[[^]]*\]}; | 396 | my $Member = qr{->$Ident|\.$Ident|\[[^]]*\]}; |
351 | my $Lval = qr{$Ident(?:$Member)*}; | 397 | my $Lval = qr{$Ident(?:$Member)*}; |
352 | 398 | ||
399 | # Possible bare types. | ||
400 | my @bare = (); | ||
401 | my $Bare = $NonptrType; | ||
402 | |||
353 | # Pre-scan the patch looking for any __setup documentation. | 403 | # Pre-scan the patch looking for any __setup documentation. |
354 | my @setup_docs = (); | 404 | my @setup_docs = (); |
355 | my $setup_docs = 0; | 405 | my $setup_docs = 0; |
@@ -477,7 +527,11 @@ sub process { | |||
477 | next if ($realfile !~ /\.(h|c|s|S|pl|sh)$/); | 527 | next if ($realfile !~ /\.(h|c|s|S|pl|sh)$/); |
478 | 528 | ||
479 | #trailing whitespace | 529 | #trailing whitespace |
480 | if ($line =~ /^\+.*\S\s+$/ || $line =~ /^\+\s+$/) { | 530 | if ($line =~ /^\+.*\015/) { |
531 | my $herevet = "$here\n" . cat_vet($line) . "\n"; | ||
532 | ERROR("DOS line endings\n" . $herevet); | ||
533 | |||
534 | } elsif ($line =~ /^\+.*\S\s+$/ || $line =~ /^\+\s+$/) { | ||
481 | my $herevet = "$here\n" . cat_vet($line) . "\n"; | 535 | my $herevet = "$here\n" . cat_vet($line) . "\n"; |
482 | ERROR("trailing whitespace\n" . $herevet); | 536 | ERROR("trailing whitespace\n" . $herevet); |
483 | } | 537 | } |
@@ -509,6 +563,30 @@ sub process { | |||
509 | # Standardise the strings and chars within the input to simplify matching. | 563 | # Standardise the strings and chars within the input to simplify matching. |
510 | $line = sanitise_line($line); | 564 | $line = sanitise_line($line); |
511 | 565 | ||
566 | # Check for potential 'bare' types | ||
567 | if ($realcnt && | ||
568 | $line !~ /^.\s*(?:$Storage\s+)?(?:$Inline\s+)?$Type\b/ && | ||
569 | $line !~ /$Ident:\s*$/ && | ||
570 | $line !~ /^.\s*$Ident\s*\(/ && | ||
571 | ($line =~ /^.(?:$Storage\s+)?(?:$Inline\s+)?($Ident)\b/ || | ||
572 | $line =~ /^.\s*(?:$Storage\s+)?($Ident)\b\s*\**\s*$Ident\s*(?:;|=)/)) { | ||
573 | my $possible = $1; | ||
574 | if ($possible !~ /^(?:$Storage|$Type|DEFINE_\S+)$/ && | ||
575 | $possible ne 'goto' && $possible ne 'return' && | ||
576 | $possible ne 'struct' && $possible ne 'enum' && | ||
577 | $possible ne 'case' && $possible ne 'else' && | ||
578 | $possible ne 'typedef') { | ||
579 | #print "POSSIBLE<$possible>\n"; | ||
580 | push(@bare, $possible); | ||
581 | my $bare = join("|", @bare); | ||
582 | $Bare = qr{ | ||
583 | \b(?:$bare)\b | ||
584 | (?:\s*\*+\s*const|\s*\*+|(?:\s*\[\s*\])+)? | ||
585 | (?:\s+$Sparse)* | ||
586 | }x; | ||
587 | } | ||
588 | } | ||
589 | |||
512 | # | 590 | # |
513 | # Checks which may be anchored in the context. | 591 | # Checks which may be anchored in the context. |
514 | # | 592 | # |
@@ -531,18 +609,19 @@ sub process { | |||
531 | } | 609 | } |
532 | } | 610 | } |
533 | if ($err ne '') { | 611 | if ($err ne '') { |
534 | ERROR("switch and case should be at the same indent\n$hereline\n$err\n"); | 612 | ERROR("switch and case should be at the same indent\n$hereline$err"); |
535 | } | 613 | } |
536 | } | 614 | } |
537 | 615 | ||
538 | # if/while/etc brace do not go on next line, unless defining a do while loop, | 616 | # if/while/etc brace do not go on next line, unless defining a do while loop, |
539 | # or if that brace on the next line is for something else | 617 | # or if that brace on the next line is for something else |
540 | if ($line =~ /\b(?:(if|while|for|switch)\s*\(|do\b|else\b)/ && $line !~ /^.#/) { | 618 | if ($line =~ /\b(?:(if|while|for|switch)\s*\(|do\b|else\b)/ && $line !~ /^.#/) { |
541 | my @ctx = ctx_statement($linenr, $realcnt, 0); | 619 | my ($level, @ctx) = ctx_statement_level($linenr, $realcnt, 0); |
542 | my $ctx_ln = $linenr + $#ctx + 1; | 620 | my $ctx_ln = $linenr + $#ctx + 1; |
543 | my $ctx_cnt = $realcnt - $#ctx - 1; | 621 | my $ctx_cnt = $realcnt - $#ctx - 1; |
544 | my $ctx = join("\n", @ctx); | 622 | my $ctx = join("\n", @ctx); |
545 | 623 | ||
624 | # Skip over any removed lines in the context following statement. | ||
546 | while ($ctx_cnt > 0 && $lines[$ctx_ln - 1] =~ /^-/) { | 625 | while ($ctx_cnt > 0 && $lines[$ctx_ln - 1] =~ /^-/) { |
547 | $ctx_ln++; | 626 | $ctx_ln++; |
548 | $ctx_cnt--; | 627 | $ctx_cnt--; |
@@ -553,6 +632,13 @@ sub process { | |||
553 | ERROR("That open brace { should be on the previous line\n" . | 632 | ERROR("That open brace { should be on the previous line\n" . |
554 | "$here\n$ctx\n$lines[$ctx_ln - 1]"); | 633 | "$here\n$ctx\n$lines[$ctx_ln - 1]"); |
555 | } | 634 | } |
635 | if ($level == 0 && $ctx =~ /\)\s*\;\s*$/ && defined $lines[$ctx_ln - 1]) { | ||
636 | my ($nlength, $nindent) = line_stats($lines[$ctx_ln - 1]); | ||
637 | if ($nindent > $indent) { | ||
638 | WARN("Trailing semicolon indicates no statements, indent implies otherwise\n" . | ||
639 | "$here\n$ctx\n$lines[$ctx_ln - 1]"); | ||
640 | } | ||
641 | } | ||
556 | } | 642 | } |
557 | 643 | ||
558 | #ignore lines not being added | 644 | #ignore lines not being added |
@@ -619,7 +705,7 @@ sub process { | |||
619 | # check for new typedefs, only function parameters and sparse annotations | 705 | # check for new typedefs, only function parameters and sparse annotations |
620 | # make sense. | 706 | # make sense. |
621 | if ($line =~ /\btypedef\s/ && | 707 | if ($line =~ /\btypedef\s/ && |
622 | $line !~ /\btypedef\s+$Type\s+\(\s*\*$Ident\s*\)\s*\(/ && | 708 | $line !~ /\btypedef\s+$Type\s+\(\s*\*?$Ident\s*\)\s*\(/ && |
623 | $line !~ /\b__bitwise(?:__|)\b/) { | 709 | $line !~ /\b__bitwise(?:__|)\b/) { |
624 | WARN("do not add new typedefs\n" . $herecurr); | 710 | WARN("do not add new typedefs\n" . $herecurr); |
625 | } | 711 | } |
@@ -633,11 +719,11 @@ sub process { | |||
633 | ERROR("\"(foo $1 )\" should be \"(foo $1)\"\n" . | 719 | ERROR("\"(foo $1 )\" should be \"(foo $1)\"\n" . |
634 | $herecurr); | 720 | $herecurr); |
635 | 721 | ||
636 | } elsif ($line =~ m{$NonptrType(\*+)(?:\s+$Attribute)?\s+[A-Za-z\d_]+}) { | 722 | } elsif ($line =~ m{$NonptrType(\*+)(?:\s+(?:$Attribute|$Sparse))?\s+[A-Za-z\d_]+}) { |
637 | ERROR("\"foo$1 bar\" should be \"foo $1bar\"\n" . | 723 | ERROR("\"foo$1 bar\" should be \"foo $1bar\"\n" . |
638 | $herecurr); | 724 | $herecurr); |
639 | 725 | ||
640 | } elsif ($line =~ m{$NonptrType\s+(\*+)(?!\s+$Attribute)\s+[A-Za-z\d_]+}) { | 726 | } elsif ($line =~ m{$NonptrType\s+(\*+)(?!\s+(?:$Attribute|$Sparse))\s+[A-Za-z\d_]+}) { |
641 | ERROR("\"foo $1 bar\" should be \"foo $1bar\"\n" . | 727 | ERROR("\"foo $1 bar\" should be \"foo $1bar\"\n" . |
642 | $herecurr); | 728 | $herecurr); |
643 | } | 729 | } |
@@ -693,7 +779,13 @@ sub process { | |||
693 | $opline = expand_tabs($opline); | 779 | $opline = expand_tabs($opline); |
694 | $opline =~ s/^./ /; | 780 | $opline =~ s/^./ /; |
695 | if (!($line=~/\#\s*include/)) { | 781 | if (!($line=~/\#\s*include/)) { |
696 | my @elements = split(/(<<=|>>=|<=|>=|==|!=|\+=|-=|\*=|\/=|%=|\^=|\|=|&=|=>|->|<<|>>|<|>|=|!|~|&&|\|\||,|\^|\+\+|--|;|&|\||\+|-|\*|\/\/|\/)/, $opline); | 782 | my $ops = qr{ |
783 | <<=|>>=|<=|>=|==|!=| | ||
784 | \+=|-=|\*=|\/=|%=|\^=|\|=|&=| | ||
785 | =>|->|<<|>>|<|>|=|!|~| | ||
786 | &&|\|\||,|\^|\+\+|--|&|\||\+|-|\*|\/ | ||
787 | }x; | ||
788 | my @elements = split(/($ops|;)/, $opline); | ||
697 | my $off = 0; | 789 | my $off = 0; |
698 | for (my $n = 0; $n < $#elements; $n += 2) { | 790 | for (my $n = 0; $n < $#elements; $n += 2) { |
699 | $off += length($elements[$n]); | 791 | $off += length($elements[$n]); |
@@ -733,7 +825,60 @@ sub process { | |||
733 | my $ptr = (" " x $off) . "^"; | 825 | my $ptr = (" " x $off) . "^"; |
734 | my $hereptr = "$hereline$ptr\n"; | 826 | my $hereptr = "$hereline$ptr\n"; |
735 | 827 | ||
736 | ##print "<$s1:$op:$s2> <$elements[$n]:$elements[$n + 1]:$elements[$n + 2]>\n"; | 828 | # Classify operators into binary, unary, or |
829 | # definitions (* only) where they have more | ||
830 | # than one mode. | ||
831 | my $unary_ctx = $prevline . $ca; | ||
832 | $unary_ctx =~ s/^./ /; | ||
833 | my $is_unary = 0; | ||
834 | my $Unary = qr{ | ||
835 | (?: | ||
836 | ^|;|,|$ops|\(|\?|:| | ||
837 | \(\s*$Type\s*\)| | ||
838 | $Type| | ||
839 | return|case|else| | ||
840 | \{|\}| | ||
841 | \[| | ||
842 | ^.\#\s*define\s+$Ident\s*(?:\([^\)]*\))?| | ||
843 | ^.\#\s*else| | ||
844 | ^.\#\s*endif| | ||
845 | ^.\#\s*(?:if|ifndef|ifdef)\b.* | ||
846 | )\s*(?:|\\)\s*$ | ||
847 | }x; | ||
848 | my $UnaryFalse = qr{ | ||
849 | sizeof\s*\(\s*$Type\s*\)\s*$ | ||
850 | }x; | ||
851 | my $UnaryDefine = qr{ | ||
852 | (?:$Type|$Bare)\s*| | ||
853 | (?:$Type|$Bare).*,\s*\** | ||
854 | }x; | ||
855 | if ($op eq '-' || $op eq '&' || $op eq '*') { | ||
856 | # An operator is binary if the left hand | ||
857 | # side is a value. Pick out the known | ||
858 | # non-values. | ||
859 | if ($unary_ctx =~ /$Unary$/s && | ||
860 | $unary_ctx !~ /$UnaryFalse$/s) { | ||
861 | $is_unary = 1; | ||
862 | |||
863 | # Special handling for ')' check if this | ||
864 | # brace represents a conditional, if so | ||
865 | # we are unary. | ||
866 | } elsif ($unary_ctx =~ /\)\s*$/) { | ||
867 | my $before = ctx_expr_before($unary_ctx); | ||
868 | if ($before =~ /(?:for|if|while)\s*$/) { | ||
869 | $is_unary = 1; | ||
870 | } | ||
871 | } | ||
872 | |||
873 | # Check for type definition for of '*'. | ||
874 | if ($op eq '*' && $unary_ctx =~ /$UnaryDefine$/) { | ||
875 | $is_unary = 2; | ||
876 | } | ||
877 | } | ||
878 | |||
879 | #if ($op eq '-' || $op eq '&' || $op eq '*') { | ||
880 | # print "UNARY: <$is_unary $a:$op:$c> <$ca:$op:$cc> <$unary_ctx>\n"; | ||
881 | #} | ||
737 | 882 | ||
738 | # ; should have either the end of line or a space or \ after it | 883 | # ; should have either the end of line or a space or \ after it |
739 | if ($op eq ';') { | 884 | if ($op eq ';') { |
@@ -757,9 +902,16 @@ sub process { | |||
757 | ERROR("need space after that '$op' $at\n" . $hereptr); | 902 | ERROR("need space after that '$op' $at\n" . $hereptr); |
758 | } | 903 | } |
759 | 904 | ||
760 | # unary ! and unary ~ are allowed no space on the right | 905 | # '*' as part of a type definition -- reported already. |
761 | } elsif ($op eq '!' or $op eq '~') { | 906 | } elsif ($op eq '*' && $is_unary == 2) { |
762 | if ($ctx !~ /[WOEB]x./) { | 907 | #warn "'*' is part of type\n"; |
908 | |||
909 | # unary operators should have a space before and | ||
910 | # none after. May be left adjacent to another | ||
911 | # unary operator, or a cast | ||
912 | } elsif ($op eq '!' || $op eq '~' || | ||
913 | ($is_unary && ($op eq '*' || $op eq '-' || $op eq '&'))) { | ||
914 | if ($ctx !~ /[WEB]x./ && $ca !~ /(?:\)|!|~|\*|-|\&|\||\+\+|\-\-|\{)$/) { | ||
763 | ERROR("need space before that '$op' $at\n" . $hereptr); | 915 | ERROR("need space before that '$op' $at\n" . $hereptr); |
764 | } | 916 | } |
765 | if ($ctx =~ /.xW/) { | 917 | if ($ctx =~ /.xW/) { |
@@ -775,39 +927,13 @@ sub process { | |||
775 | ERROR("no space before that '$op' $at\n" . $hereptr); | 927 | ERROR("no space before that '$op' $at\n" . $hereptr); |
776 | } | 928 | } |
777 | 929 | ||
778 | # & is both unary and binary | ||
779 | # unary: | ||
780 | # a &b | ||
781 | # binary (consistent spacing): | ||
782 | # a&b OK | ||
783 | # a & b OK | ||
784 | # | ||
785 | # boiling down to: if there is a space on the right then there | ||
786 | # should be one on the left. | ||
787 | # | ||
788 | # - is the same | ||
789 | # | ||
790 | } elsif ($op eq '&' or $op eq '-') { | ||
791 | if ($ctx !~ /VxV|[EW]x[WE]|[EWB]x[VO]/) { | ||
792 | ERROR("need space before that '$op' $at\n" . $hereptr); | ||
793 | } | ||
794 | |||
795 | # * is the same as & only adding: | ||
796 | # type: | ||
797 | # (foo *) | ||
798 | # (foo **) | ||
799 | # | ||
800 | } elsif ($op eq '*') { | ||
801 | if ($ca !~ /$Type$/ && $cb !~ /(\*$;|$;\*)/ && | ||
802 | $ctx !~ /VxV|[EW]x[WE]|[EWB]x[VO]|OxV|WxB|BxB/) { | ||
803 | ERROR("need space before that '$op' $at\n" . $hereptr); | ||
804 | } | ||
805 | |||
806 | # << and >> may either have or not have spaces both sides | 930 | # << and >> may either have or not have spaces both sides |
807 | } elsif ($op eq '<<' or $op eq '>>' or $op eq '+' or $op eq '/' or | 931 | } elsif ($op eq '<<' or $op eq '>>' or |
808 | $op eq '^' or $op eq '|') | 932 | $op eq '&' or $op eq '^' or $op eq '|' or |
933 | $op eq '+' or $op eq '-' or | ||
934 | $op eq '*' or $op eq '/') | ||
809 | { | 935 | { |
810 | if ($ctx !~ /VxV|WxW|VxE|WxE/) { | 936 | if ($ctx !~ /VxV|WxW|VxE|WxE|VxO/) { |
811 | ERROR("need consistent spacing around '$op' $at\n" . | 937 | ERROR("need consistent spacing around '$op' $at\n" . |
812 | $hereptr); | 938 | $hereptr); |
813 | } | 939 | } |
@@ -865,10 +991,12 @@ sub process { | |||
865 | } | 991 | } |
866 | 992 | ||
867 | # check spacing on paretheses | 993 | # check spacing on paretheses |
868 | if ($line =~ /\(\s/ && $line !~ /\(\s*$/) { | 994 | if ($line =~ /\(\s/ && $line !~ /\(\s*(?:\\)?$/ && |
995 | $line !~ /for\s*\(\s+;/) { | ||
869 | ERROR("no space after that open parenthesis '('\n" . $herecurr); | 996 | ERROR("no space after that open parenthesis '('\n" . $herecurr); |
870 | } | 997 | } |
871 | if ($line =~ /\s\)/) { | 998 | if ($line =~ /\s\)/ && $line !~ /^.\s*\)/ && |
999 | $line !~ /for\s*\(.*;\s+\)/) { | ||
872 | ERROR("no space before that close parenthesis ')'\n" . $herecurr); | 1000 | ERROR("no space before that close parenthesis ')'\n" . $herecurr); |
873 | } | 1001 | } |
874 | 1002 | ||
@@ -926,10 +1054,10 @@ sub process { | |||
926 | # multi-statement macros should be enclosed in a do while loop, grab the | 1054 | # multi-statement macros should be enclosed in a do while loop, grab the |
927 | # first statement and ensure its the whole macro if its not enclosed | 1055 | # first statement and ensure its the whole macro if its not enclosed |
928 | # in a known goot container | 1056 | # in a known goot container |
929 | if (($prevline=~/\#define.*\\/) and | 1057 | if ($prevline =~ /\#define.*\\/ && |
930 | !($prevline=~/do\s+{/) and !($prevline=~/\(\{/) and | 1058 | $prevline !~/(?:do\s+{|\(\{|\{)/ && |
931 | !($line=~/do.*{/) and !($line=~/\(\{/) and | 1059 | $line !~ /(?:do\s+{|\(\{|\{)/ && |
932 | !($line=~/^.\s*$Declare\s/)) { | 1060 | $line !~ /^.\s*$Declare\s/) { |
933 | # Grab the first statement, if that is the entire macro | 1061 | # Grab the first statement, if that is the entire macro |
934 | # its ok. This may start either on the #define line | 1062 | # its ok. This may start either on the #define line |
935 | # or the one below. | 1063 | # or the one below. |
@@ -1027,6 +1155,11 @@ sub process { | |||
1027 | WARN("Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt\n" . $herecurr); | 1155 | WARN("Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt\n" . $herecurr); |
1028 | } | 1156 | } |
1029 | 1157 | ||
1158 | # SPIN_LOCK_UNLOCKED & RW_LOCK_UNLOCKED are deprecated | ||
1159 | if ($line =~ /\b(SPIN_LOCK_UNLOCKED|RW_LOCK_UNLOCKED)/) { | ||
1160 | ERROR("Use of $1 is deprecated: see Documentation/spinlocks.txt\n" . $herecurr); | ||
1161 | } | ||
1162 | |||
1030 | # warn about #if 0 | 1163 | # warn about #if 0 |
1031 | if ($line =~ /^.#\s*if\s+0\b/) { | 1164 | if ($line =~ /^.#\s*if\s+0\b/) { |
1032 | CHK("if this code is redundant consider removing it\n" . | 1165 | CHK("if this code is redundant consider removing it\n" . |
@@ -1073,8 +1206,8 @@ sub process { | |||
1073 | 1206 | ||
1074 | # check the location of the inline attribute, that it is between | 1207 | # check the location of the inline attribute, that it is between |
1075 | # storage class and type. | 1208 | # storage class and type. |
1076 | if ($line =~ /$Type\s+(?:inline|__always_inline|noinline)\b/ || | 1209 | if ($line =~ /\b$Type\s+$Inline\b/ || |
1077 | $line =~ /\b(?:inline|__always_inline|noinline)\s+$Storage/) { | 1210 | $line =~ /\b$Inline\s+$Storage\b/) { |
1078 | ERROR("inline keyword should sit between storage class and type\n" . $herecurr); | 1211 | ERROR("inline keyword should sit between storage class and type\n" . $herecurr); |
1079 | } | 1212 | } |
1080 | 1213 | ||
@@ -1091,6 +1224,11 @@ sub process { | |||
1091 | CHK("__setup appears un-documented -- check Documentation/kernel-parameters.txt\n" . $herecurr); | 1224 | CHK("__setup appears un-documented -- check Documentation/kernel-parameters.txt\n" . $herecurr); |
1092 | } | 1225 | } |
1093 | } | 1226 | } |
1227 | |||
1228 | # check for pointless casting of kmalloc return | ||
1229 | if ($line =~ /\*\s*\)\s*k[czm]alloc\b/) { | ||
1230 | WARN("unnecessary cast may hide bugs, see http://c-faq.com/malloc/mallocnocast.html\n" . $herecurr); | ||
1231 | } | ||
1094 | } | 1232 | } |
1095 | 1233 | ||
1096 | if ($chk_patch && !$is_patch) { | 1234 | if ($chk_patch && !$is_patch) { |
diff --git a/scripts/checkstack.pl b/scripts/checkstack.pl index 663158627155..b458e2acb4ac 100755 --- a/scripts/checkstack.pl +++ b/scripts/checkstack.pl | |||
@@ -78,6 +78,9 @@ my (@stack, $re, $x, $xs); | |||
78 | # pair for larger users. -- PFM. | 78 | # pair for larger users. -- PFM. |
79 | #a00048e0: d4fc40f0 addi.l r15,-240,r15 | 79 | #a00048e0: d4fc40f0 addi.l r15,-240,r15 |
80 | $re = qr/.*addi\.l.*r15,-(([0-9]{2}|[3-9])[0-9]{2}),r15/o; | 80 | $re = qr/.*addi\.l.*r15,-(([0-9]{2}|[3-9])[0-9]{2}),r15/o; |
81 | } elsif ($arch =~ /^blackfin$/) { | ||
82 | # 0: 00 e8 38 01 LINK 0x4e0; | ||
83 | $re = qr/.*[[:space:]]LINK[[:space:]]*(0x$x{1,8})/o; | ||
81 | } else { | 84 | } else { |
82 | print("wrong or unknown architecture\n"); | 85 | print("wrong or unknown architecture\n"); |
83 | exit | 86 | exit |
diff --git a/scripts/kernel-doc b/scripts/kernel-doc index 1f5835115cad..1d1401807e95 100755 --- a/scripts/kernel-doc +++ b/scripts/kernel-doc | |||
@@ -5,6 +5,7 @@ use strict; | |||
5 | ## Copyright (c) 1998 Michael Zucchi, All Rights Reserved ## | 5 | ## Copyright (c) 1998 Michael Zucchi, All Rights Reserved ## |
6 | ## Copyright (C) 2000, 1 Tim Waugh <twaugh@redhat.com> ## | 6 | ## Copyright (C) 2000, 1 Tim Waugh <twaugh@redhat.com> ## |
7 | ## Copyright (C) 2001 Simon Huggins ## | 7 | ## Copyright (C) 2001 Simon Huggins ## |
8 | ## Copyright (C) 2005-2007 Randy Dunlap ## | ||
8 | ## ## | 9 | ## ## |
9 | ## #define enhancements by Armin Kuster <akuster@mvista.com> ## | 10 | ## #define enhancements by Armin Kuster <akuster@mvista.com> ## |
10 | ## Copyright (c) 2000 MontaVista Software, Inc. ## | 11 | ## Copyright (c) 2000 MontaVista Software, Inc. ## |
@@ -161,7 +162,7 @@ my $type_constant = '\%([-_\w]+)'; | |||
161 | my $type_func = '(\w+)\(\)'; | 162 | my $type_func = '(\w+)\(\)'; |
162 | my $type_param = '\@(\w+)'; | 163 | my $type_param = '\@(\w+)'; |
163 | my $type_struct = '\&((struct\s*)*[_\w]+)'; | 164 | my $type_struct = '\&((struct\s*)*[_\w]+)'; |
164 | my $type_struct_xml = '\\\amp;((struct\s*)*[_\w]+)'; | 165 | my $type_struct_xml = '\\&((struct\s*)*[_\w]+)'; |
165 | my $type_env = '(\$\w+)'; | 166 | my $type_env = '(\$\w+)'; |
166 | 167 | ||
167 | # Output conversion substitutions. | 168 | # Output conversion substitutions. |
@@ -173,7 +174,9 @@ my %highlights_html = ( $type_constant, "<i>\$1</i>", | |||
173 | $type_struct_xml, "<i>\$1</i>", | 174 | $type_struct_xml, "<i>\$1</i>", |
174 | $type_env, "<b><i>\$1</i></b>", | 175 | $type_env, "<b><i>\$1</i></b>", |
175 | $type_param, "<tt><b>\$1</b></tt>" ); | 176 | $type_param, "<tt><b>\$1</b></tt>" ); |
176 | my $blankline_html = "<p>"; | 177 | my $local_lt = "\\\\\\\\lt:"; |
178 | my $local_gt = "\\\\\\\\gt:"; | ||
179 | my $blankline_html = $local_lt . "p" . $local_gt; # was "<p>" | ||
177 | 180 | ||
178 | # XML, docbook format | 181 | # XML, docbook format |
179 | my %highlights_xml = ( "([^=])\\\"([^\\\"<]+)\\\"", "\$1<quote>\$2</quote>", | 182 | my %highlights_xml = ( "([^=])\\\"([^\\\"<]+)\\\"", "\$1<quote>\$2</quote>", |
@@ -391,17 +394,19 @@ sub output_highlight { | |||
391 | # confess "output_highlight got called with no args?\n"; | 394 | # confess "output_highlight got called with no args?\n"; |
392 | # } | 395 | # } |
393 | 396 | ||
397 | if ($output_mode eq "html") { | ||
398 | $contents = local_unescape($contents); | ||
399 | # convert data read & converted thru xml_escape() into &xyz; format: | ||
400 | $contents =~ s/\\\\\\/&/g; | ||
401 | } | ||
394 | # print STDERR "contents b4:$contents\n"; | 402 | # print STDERR "contents b4:$contents\n"; |
395 | eval $dohighlight; | 403 | eval $dohighlight; |
396 | die $@ if $@; | 404 | die $@ if $@; |
397 | if ($output_mode eq "html") { | ||
398 | $contents =~ s/\\\\//; | ||
399 | } | ||
400 | # print STDERR "contents af:$contents\n"; | 405 | # print STDERR "contents af:$contents\n"; |
401 | 406 | ||
402 | foreach $line (split "\n", $contents) { | 407 | foreach $line (split "\n", $contents) { |
403 | if ($line eq ""){ | 408 | if ($line eq ""){ |
404 | print $lineprefix, $blankline; | 409 | print $lineprefix, local_unescape($blankline); |
405 | } else { | 410 | } else { |
406 | $line =~ s/\\\\\\/\&/g; | 411 | $line =~ s/\\\\\\/\&/g; |
407 | if ($output_mode eq "man" && substr($line, 0, 1) eq ".") { | 412 | if ($output_mode eq "man" && substr($line, 0, 1) eq ".") { |
@@ -1752,7 +1757,13 @@ sub process_state3_type($$) { | |||
1752 | } | 1757 | } |
1753 | } | 1758 | } |
1754 | 1759 | ||
1755 | # replace <, >, and & | 1760 | # xml_escape: replace <, >, and & in the text stream; |
1761 | # | ||
1762 | # however, formatting controls that are generated internally/locally in the | ||
1763 | # kernel-doc script are not escaped here; instead, they begin life like | ||
1764 | # $blankline_html (4 of '\' followed by a mnemonic + ':'), then these strings | ||
1765 | # are converted to their mnemonic-expected output, without the 4 * '\' & ':', | ||
1766 | # just before actual output; (this is done by local_unescape()) | ||
1756 | sub xml_escape($) { | 1767 | sub xml_escape($) { |
1757 | my $text = shift; | 1768 | my $text = shift; |
1758 | if (($output_mode eq "text") || ($output_mode eq "man")) { | 1769 | if (($output_mode eq "text") || ($output_mode eq "man")) { |
@@ -1764,6 +1775,18 @@ sub xml_escape($) { | |||
1764 | return $text; | 1775 | return $text; |
1765 | } | 1776 | } |
1766 | 1777 | ||
1778 | # convert local escape strings to html | ||
1779 | # local escape strings look like: '\\\\menmonic:' (that's 4 backslashes) | ||
1780 | sub local_unescape($) { | ||
1781 | my $text = shift; | ||
1782 | if (($output_mode eq "text") || ($output_mode eq "man")) { | ||
1783 | return $text; | ||
1784 | } | ||
1785 | $text =~ s/\\\\\\\\lt:/</g; | ||
1786 | $text =~ s/\\\\\\\\gt:/>/g; | ||
1787 | return $text; | ||
1788 | } | ||
1789 | |||
1767 | sub process_file($) { | 1790 | sub process_file($) { |
1768 | my $file; | 1791 | my $file; |
1769 | my $identifier; | 1792 | my $identifier; |
@@ -1903,7 +1926,7 @@ sub process_file($) { | |||
1903 | } elsif ($state == 4) { | 1926 | } elsif ($state == 4) { |
1904 | # Documentation block | 1927 | # Documentation block |
1905 | if (/$doc_block/) { | 1928 | if (/$doc_block/) { |
1906 | dump_section($section, $contents); | 1929 | dump_section($section, xml_escape($contents)); |
1907 | output_intro({'sectionlist' => \@sectionlist, | 1930 | output_intro({'sectionlist' => \@sectionlist, |
1908 | 'sections' => \%sections }); | 1931 | 'sections' => \%sections }); |
1909 | $contents = ""; | 1932 | $contents = ""; |
@@ -1923,7 +1946,7 @@ sub process_file($) { | |||
1923 | } | 1946 | } |
1924 | elsif (/$doc_end/) | 1947 | elsif (/$doc_end/) |
1925 | { | 1948 | { |
1926 | dump_section($section, $contents); | 1949 | dump_section($section, xml_escape($contents)); |
1927 | output_intro({'sectionlist' => \@sectionlist, | 1950 | output_intro({'sectionlist' => \@sectionlist, |
1928 | 'sections' => \%sections }); | 1951 | 'sections' => \%sections }); |
1929 | $contents = ""; | 1952 | $contents = ""; |