diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/Makefile.fwinst | 10 | ||||
-rw-r--r-- | scripts/Makefile.modpost | 1 | ||||
-rwxr-xr-x | scripts/checkpatch.pl | 310 | ||||
-rwxr-xr-x | scripts/checkstack.pl | 27 | ||||
-rw-r--r-- | scripts/genksyms/genksyms.c | 3 | ||||
-rw-r--r-- | scripts/mod/file2alias.c | 26 | ||||
-rw-r--r-- | scripts/mod/mk_elfconfig.c | 2 | ||||
-rw-r--r-- | scripts/mod/modpost.c | 3 |
8 files changed, 287 insertions, 95 deletions
diff --git a/scripts/Makefile.fwinst b/scripts/Makefile.fwinst index c972c0f54ce0..f63a663de158 100644 --- a/scripts/Makefile.fwinst +++ b/scripts/Makefile.fwinst | |||
@@ -17,14 +17,15 @@ include $(srctree)/$(obj)/Makefile | |||
17 | 17 | ||
18 | include scripts/Makefile.host | 18 | include scripts/Makefile.host |
19 | 19 | ||
20 | mod-fw := $(addprefix $(INSTALL_FW_PATH)/,$(fw-shipped-m)) | 20 | mod-fw := $(fw-shipped-m) |
21 | |||
22 | # If CONFIG_FIRMWARE_IN_KERNEL isn't set, then install the | 21 | # If CONFIG_FIRMWARE_IN_KERNEL isn't set, then install the |
23 | # firmware for in-kernel drivers too. | 22 | # firmware for in-kernel drivers too. |
24 | ifndef CONFIG_FIRMWARE_IN_KERNEL | 23 | ifndef CONFIG_FIRMWARE_IN_KERNEL |
25 | mod-fw += $(addprefix $(INSTALL_FW_PATH)/,$(fw-shipped-y)) | 24 | mod-fw += $(fw-shipped-y) |
26 | endif | 25 | endif |
27 | 26 | ||
27 | installed-mod-fw := $(addprefix $(INSTALL_FW_PATH)/,$(mod-fw)) | ||
28 | |||
28 | installed-fw := $(addprefix $(INSTALL_FW_PATH)/,$(fw-shipped-all)) | 29 | installed-fw := $(addprefix $(INSTALL_FW_PATH)/,$(fw-shipped-all)) |
29 | installed-fw-dirs := $(sort $(dir $(installed-fw))) $(INSTALL_FW_PATH)/. | 30 | installed-fw-dirs := $(sort $(dir $(installed-fw))) $(INSTALL_FW_PATH)/. |
30 | 31 | ||
@@ -49,7 +50,8 @@ PHONY += __fw_install __fw_modinst FORCE | |||
49 | .PHONY: $(PHONY) | 50 | .PHONY: $(PHONY) |
50 | 51 | ||
51 | __fw_install: $(installed-fw) | 52 | __fw_install: $(installed-fw) |
52 | __fw_modinst: $(mod-fw) | 53 | __fw_modinst: $(installed-mod-fw) |
54 | __fw_modbuild: $(addprefix $(obj)/,$(mod-fw)) | ||
53 | 55 | ||
54 | FORCE: | 56 | FORCE: |
55 | 57 | ||
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index 17092d6c7db3..9ee9783aea57 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost | |||
@@ -101,6 +101,7 @@ quiet_cmd_kernel-mod = MODPOST $@ | |||
101 | cmd_kernel-mod = $(modpost) $@ | 101 | cmd_kernel-mod = $(modpost) $@ |
102 | 102 | ||
103 | vmlinux.o: FORCE | 103 | vmlinux.o: FORCE |
104 | @rm -fr $(kernelmarkersfile) | ||
104 | $(call cmd,kernel-mod) | 105 | $(call cmd,kernel-mod) |
105 | 106 | ||
106 | # Declare generated files as targets for modpost | 107 | # Declare generated files as targets for modpost |
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 6971bf078d13..bc6779398229 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.19'; | 12 | my $V = '0.21'; |
13 | 13 | ||
14 | use Getopt::Long qw(:config no_auto_abbrev); | 14 | use Getopt::Long qw(:config no_auto_abbrev); |
15 | 15 | ||
@@ -17,7 +17,6 @@ my $quiet = 0; | |||
17 | my $tree = 1; | 17 | my $tree = 1; |
18 | my $chk_signoff = 1; | 18 | my $chk_signoff = 1; |
19 | my $chk_patch = 1; | 19 | my $chk_patch = 1; |
20 | my $tst_type = 0; | ||
21 | my $tst_only; | 20 | my $tst_only; |
22 | my $emacs = 0; | 21 | my $emacs = 0; |
23 | my $terse = 0; | 22 | my $terse = 0; |
@@ -44,7 +43,6 @@ GetOptions( | |||
44 | 'summary-file!' => \$summary_file, | 43 | 'summary-file!' => \$summary_file, |
45 | 44 | ||
46 | 'debug=s' => \%debug, | 45 | 'debug=s' => \%debug, |
47 | 'test-type!' => \$tst_type, | ||
48 | 'test-only=s' => \$tst_only, | 46 | 'test-only=s' => \$tst_only, |
49 | ) or exit; | 47 | ) or exit; |
50 | 48 | ||
@@ -67,6 +65,7 @@ if ($#ARGV < 0) { | |||
67 | 65 | ||
68 | my $dbg_values = 0; | 66 | my $dbg_values = 0; |
69 | my $dbg_possible = 0; | 67 | my $dbg_possible = 0; |
68 | my $dbg_type = 0; | ||
70 | for my $key (keys %debug) { | 69 | for my $key (keys %debug) { |
71 | eval "\${dbg_$key} = '$debug{$key}';" | 70 | eval "\${dbg_$key} = '$debug{$key}';" |
72 | } | 71 | } |
@@ -169,24 +168,23 @@ our @modifierList = ( | |||
169 | ); | 168 | ); |
170 | 169 | ||
171 | sub build_types { | 170 | sub build_types { |
172 | my $mods = "(?: \n" . join("|\n ", @modifierList) . "\n)"; | 171 | my $mods = "(?x: \n" . join("|\n ", @modifierList) . "\n)"; |
173 | my $all = "(?: \n" . join("|\n ", @typeList) . "\n)"; | 172 | my $all = "(?x: \n" . join("|\n ", @typeList) . "\n)"; |
173 | $Modifier = qr{(?:$Attribute|$Sparse|$mods)}; | ||
174 | $NonptrType = qr{ | 174 | $NonptrType = qr{ |
175 | (?:const\s+)? | 175 | (?:$Modifier\s+|const\s+)* |
176 | (?:$mods\s+)? | ||
177 | (?: | 176 | (?: |
178 | (?:typeof|__typeof__)\s*\(\s*\**\s*$Ident\s*\)| | 177 | (?:typeof|__typeof__)\s*\(\s*\**\s*$Ident\s*\)| |
179 | (?:${all}\b) | 178 | (?:${all}\b) |
180 | ) | 179 | ) |
181 | (?:\s+$Sparse|\s+const)* | 180 | (?:\s+$Modifier|\s+const)* |
182 | }x; | 181 | }x; |
183 | $Type = qr{ | 182 | $Type = qr{ |
184 | $NonptrType | 183 | $NonptrType |
185 | (?:\s*\*+\s*const|\s*\*+|(?:\s*\[\s*\])+)? | 184 | (?:\s*\*+\s*const|\s*\*+|(?:\s*\[\s*\])+)? |
186 | (?:\s+$Inline|\s+$Sparse|\s+$Attribute|\s+$mods)* | 185 | (?:\s+$Inline|\s+$Modifier)* |
187 | }x; | 186 | }x; |
188 | $Declare = qr{(?:$Storage\s+)?$Type}; | 187 | $Declare = qr{(?:$Storage\s+)?$Type}; |
189 | $Modifier = qr{(?:$Attribute|$Sparse|$mods)}; | ||
190 | } | 188 | } |
191 | build_types(); | 189 | build_types(); |
192 | 190 | ||
@@ -470,7 +468,9 @@ sub ctx_statement_block { | |||
470 | } | 468 | } |
471 | $off++; | 469 | $off++; |
472 | } | 470 | } |
471 | # We are truly at the end, so shuffle to the next line. | ||
473 | if ($off == $len) { | 472 | if ($off == $len) { |
473 | $loff = $len + 1; | ||
474 | $line++; | 474 | $line++; |
475 | $remain--; | 475 | $remain--; |
476 | } | 476 | } |
@@ -631,7 +631,7 @@ sub ctx_locate_comment { | |||
631 | my ($first_line, $end_line) = @_; | 631 | my ($first_line, $end_line) = @_; |
632 | 632 | ||
633 | # Catch a comment on the end of the line itself. | 633 | # Catch a comment on the end of the line itself. |
634 | my ($current_comment) = ($rawlines[$end_line - 1] =~ m@.*(/\*.*\*/)\s*$@); | 634 | my ($current_comment) = ($rawlines[$end_line - 1] =~ m@.*(/\*.*\*/)\s*(?:\\\s*)?$@); |
635 | return $current_comment if (defined $current_comment); | 635 | return $current_comment if (defined $current_comment); |
636 | 636 | ||
637 | # Look through the context and try and figure out if there is a | 637 | # Look through the context and try and figure out if there is a |
@@ -689,17 +689,20 @@ sub cat_vet { | |||
689 | my $av_preprocessor = 0; | 689 | my $av_preprocessor = 0; |
690 | my $av_pending; | 690 | my $av_pending; |
691 | my @av_paren_type; | 691 | my @av_paren_type; |
692 | my $av_pend_colon; | ||
692 | 693 | ||
693 | sub annotate_reset { | 694 | sub annotate_reset { |
694 | $av_preprocessor = 0; | 695 | $av_preprocessor = 0; |
695 | $av_pending = '_'; | 696 | $av_pending = '_'; |
696 | @av_paren_type = ('E'); | 697 | @av_paren_type = ('E'); |
698 | $av_pend_colon = 'O'; | ||
697 | } | 699 | } |
698 | 700 | ||
699 | sub annotate_values { | 701 | sub annotate_values { |
700 | my ($stream, $type) = @_; | 702 | my ($stream, $type) = @_; |
701 | 703 | ||
702 | my $res; | 704 | my $res; |
705 | my $var = '_' x length($stream); | ||
703 | my $cur = $stream; | 706 | my $cur = $stream; |
704 | 707 | ||
705 | print "$stream\n" if ($dbg_values > 1); | 708 | print "$stream\n" if ($dbg_values > 1); |
@@ -715,10 +718,14 @@ sub annotate_values { | |||
715 | $av_preprocessor = 0; | 718 | $av_preprocessor = 0; |
716 | } | 719 | } |
717 | 720 | ||
718 | } elsif ($cur =~ /^($Type)/) { | 721 | } elsif ($cur =~ /^($Type)\s*(?:$Ident|,|\)|\()/) { |
719 | print "DECLARE($1)\n" if ($dbg_values > 1); | 722 | print "DECLARE($1)\n" if ($dbg_values > 1); |
720 | $type = 'T'; | 723 | $type = 'T'; |
721 | 724 | ||
725 | } elsif ($cur =~ /^($Modifier)\s*/) { | ||
726 | print "MODIFIER($1)\n" if ($dbg_values > 1); | ||
727 | $type = 'T'; | ||
728 | |||
722 | } elsif ($cur =~ /^(\#\s*define\s*$Ident)(\(?)/o) { | 729 | } elsif ($cur =~ /^(\#\s*define\s*$Ident)(\(?)/o) { |
723 | print "DEFINE($1,$2)\n" if ($dbg_values > 1); | 730 | print "DEFINE($1,$2)\n" if ($dbg_values > 1); |
724 | $av_preprocessor = 1; | 731 | $av_preprocessor = 1; |
@@ -780,7 +787,12 @@ sub annotate_values { | |||
780 | $av_pending = 'N'; | 787 | $av_pending = 'N'; |
781 | $type = 'N'; | 788 | $type = 'N'; |
782 | 789 | ||
783 | } elsif ($cur =~/^(return|case|else)/o) { | 790 | } elsif ($cur =~/^(case)/o) { |
791 | print "CASE($1)\n" if ($dbg_values > 1); | ||
792 | $av_pend_colon = 'C'; | ||
793 | $type = 'N'; | ||
794 | |||
795 | } elsif ($cur =~/^(return|else|goto)/o) { | ||
784 | print "KEYWORD($1)\n" if ($dbg_values > 1); | 796 | print "KEYWORD($1)\n" if ($dbg_values > 1); |
785 | $type = 'N'; | 797 | $type = 'N'; |
786 | 798 | ||
@@ -800,10 +812,20 @@ sub annotate_values { | |||
800 | print "PAREN('$1')\n" if ($dbg_values > 1); | 812 | print "PAREN('$1')\n" if ($dbg_values > 1); |
801 | } | 813 | } |
802 | 814 | ||
803 | } elsif ($cur =~ /^($Ident)\(/o) { | 815 | } elsif ($cur =~ /^($Ident)\s*\(/o) { |
804 | print "FUNC($1)\n" if ($dbg_values > 1); | 816 | print "FUNC($1)\n" if ($dbg_values > 1); |
817 | $type = 'V'; | ||
805 | $av_pending = 'V'; | 818 | $av_pending = 'V'; |
806 | 819 | ||
820 | } elsif ($cur =~ /^($Ident\s*):/) { | ||
821 | if ($type eq 'E') { | ||
822 | $av_pend_colon = 'L'; | ||
823 | } elsif ($type eq 'T') { | ||
824 | $av_pend_colon = 'B'; | ||
825 | } | ||
826 | print "IDENT_COLON($1,$type>$av_pend_colon)\n" if ($dbg_values > 1); | ||
827 | $type = 'V'; | ||
828 | |||
807 | } elsif ($cur =~ /^($Ident|$Constant)/o) { | 829 | } elsif ($cur =~ /^($Ident|$Constant)/o) { |
808 | print "IDENT($1)\n" if ($dbg_values > 1); | 830 | print "IDENT($1)\n" if ($dbg_values > 1); |
809 | $type = 'V'; | 831 | $type = 'V'; |
@@ -815,11 +837,40 @@ sub annotate_values { | |||
815 | } elsif ($cur =~/^(;|{|})/) { | 837 | } elsif ($cur =~/^(;|{|})/) { |
816 | print "END($1)\n" if ($dbg_values > 1); | 838 | print "END($1)\n" if ($dbg_values > 1); |
817 | $type = 'E'; | 839 | $type = 'E'; |
840 | $av_pend_colon = 'O'; | ||
841 | |||
842 | } elsif ($cur =~ /^(\?)/o) { | ||
843 | print "QUESTION($1)\n" if ($dbg_values > 1); | ||
844 | $type = 'N'; | ||
818 | 845 | ||
819 | } elsif ($cur =~ /^(;|\?|:|\[)/o) { | 846 | } elsif ($cur =~ /^(:)/o) { |
847 | print "COLON($1,$av_pend_colon)\n" if ($dbg_values > 1); | ||
848 | |||
849 | substr($var, length($res), 1, $av_pend_colon); | ||
850 | if ($av_pend_colon eq 'C' || $av_pend_colon eq 'L') { | ||
851 | $type = 'E'; | ||
852 | } else { | ||
853 | $type = 'N'; | ||
854 | } | ||
855 | $av_pend_colon = 'O'; | ||
856 | |||
857 | } elsif ($cur =~ /^(;|\[)/o) { | ||
820 | print "CLOSE($1)\n" if ($dbg_values > 1); | 858 | print "CLOSE($1)\n" if ($dbg_values > 1); |
821 | $type = 'N'; | 859 | $type = 'N'; |
822 | 860 | ||
861 | } elsif ($cur =~ /^(-(?![->])|\+(?!\+)|\*|\&(?!\&))/o) { | ||
862 | my $variant; | ||
863 | |||
864 | print "OPV($1)\n" if ($dbg_values > 1); | ||
865 | if ($type eq 'V') { | ||
866 | $variant = 'B'; | ||
867 | } else { | ||
868 | $variant = 'U'; | ||
869 | } | ||
870 | |||
871 | substr($var, length($res), 1, $variant); | ||
872 | $type = 'N'; | ||
873 | |||
823 | } elsif ($cur =~ /^($Operators)/o) { | 874 | } elsif ($cur =~ /^($Operators)/o) { |
824 | print "OP($1)\n" if ($dbg_values > 1); | 875 | print "OP($1)\n" if ($dbg_values > 1); |
825 | if ($1 ne '++' && $1 ne '--') { | 876 | if ($1 ne '++' && $1 ne '--') { |
@@ -835,17 +886,17 @@ sub annotate_values { | |||
835 | } | 886 | } |
836 | } | 887 | } |
837 | 888 | ||
838 | return $res; | 889 | return ($res, $var); |
839 | } | 890 | } |
840 | 891 | ||
841 | sub possible { | 892 | sub possible { |
842 | my ($possible, $line) = @_; | 893 | my ($possible, $line) = @_; |
843 | 894 | ||
844 | print "CHECK<$possible> ($line)\n" if ($dbg_possible > 1); | 895 | print "CHECK<$possible> ($line)\n" if ($dbg_possible > 1); |
845 | if ($possible !~ /^(?:$Storage|$Type|DEFINE_\S+)$/ && | 896 | if ($possible !~ /^(?:$Modifier|$Storage|$Type|DEFINE_\S+)$/ && |
846 | $possible ne 'goto' && $possible ne 'return' && | 897 | $possible ne 'goto' && $possible ne 'return' && |
847 | $possible ne 'case' && $possible ne 'else' && | 898 | $possible ne 'case' && $possible ne 'else' && |
848 | $possible ne 'asm' && | 899 | $possible ne 'asm' && $possible ne '__asm__' && |
849 | $possible !~ /^(typedef|struct|enum)\b/) { | 900 | $possible !~ /^(typedef|struct|enum)\b/) { |
850 | # Check for modifiers. | 901 | # Check for modifiers. |
851 | $possible =~ s/\s*$Storage\s*//g; | 902 | $possible =~ s/\s*$Storage\s*//g; |
@@ -854,8 +905,10 @@ sub possible { | |||
854 | 905 | ||
855 | } elsif ($possible =~ /\s/) { | 906 | } elsif ($possible =~ /\s/) { |
856 | $possible =~ s/\s*$Type\s*//g; | 907 | $possible =~ s/\s*$Type\s*//g; |
857 | warn "MODIFIER: $possible ($line)\n" if ($dbg_possible); | 908 | for my $modifier (split(' ', $possible)) { |
858 | push(@modifierList, $possible); | 909 | warn "MODIFIER: $modifier ($possible) ($line)\n" if ($dbg_possible); |
910 | push(@modifierList, $modifier); | ||
911 | } | ||
859 | 912 | ||
860 | } else { | 913 | } else { |
861 | warn "POSSIBLE: $possible ($line)\n" if ($dbg_possible); | 914 | warn "POSSIBLE: $possible ($line)\n" if ($dbg_possible); |
@@ -1135,7 +1188,9 @@ sub process { | |||
1135 | } | 1188 | } |
1136 | #80 column limit | 1189 | #80 column limit |
1137 | if ($line =~ /^\+/ && $prevrawline !~ /\/\*\*/ && | 1190 | if ($line =~ /^\+/ && $prevrawline !~ /\/\*\*/ && |
1138 | $rawline !~ /^.\s*\*\s*\@$Ident\s/ && $length > 80) | 1191 | $rawline !~ /^.\s*\*\s*\@$Ident\s/ && |
1192 | $line !~ /^\+\s*printk\s*\(\s*(?:KERN_\S+\s*)?"[X\t]*"\s*(?:,|\)\s*;)\s*$/ && | ||
1193 | $length > 80) | ||
1139 | { | 1194 | { |
1140 | WARN("line over 80 characters\n" . $herecurr); | 1195 | WARN("line over 80 characters\n" . $herecurr); |
1141 | } | 1196 | } |
@@ -1162,10 +1217,10 @@ sub process { | |||
1162 | } | 1217 | } |
1163 | 1218 | ||
1164 | # Check for potential 'bare' types | 1219 | # Check for potential 'bare' types |
1165 | my ($stat, $cond); | 1220 | my ($stat, $cond, $line_nr_next, $remain_next); |
1166 | if ($realcnt && $line =~ /.\s*\S/) { | 1221 | if ($realcnt && $line =~ /.\s*\S/) { |
1167 | ($stat, $cond) = ctx_statement_block($linenr, | 1222 | ($stat, $cond, $line_nr_next, $remain_next) = |
1168 | $realcnt, 0); | 1223 | ctx_statement_block($linenr, $realcnt, 0); |
1169 | $stat =~ s/\n./\n /g; | 1224 | $stat =~ s/\n./\n /g; |
1170 | $cond =~ s/\n./\n /g; | 1225 | $cond =~ s/\n./\n /g; |
1171 | 1226 | ||
@@ -1179,7 +1234,7 @@ sub process { | |||
1179 | } elsif ($s =~ /^.\s*$Ident\s*\(/s) { | 1234 | } elsif ($s =~ /^.\s*$Ident\s*\(/s) { |
1180 | 1235 | ||
1181 | # declarations always start with types | 1236 | # declarations always start with types |
1182 | } elsif ($prev_values eq 'E' && $s =~ /^.\s*(?:$Storage\s+)?(?:$Inline\s+)?(?:const\s+)?((?:\s*$Ident)+)\b(?:\s+$Sparse)?\s*\**\s*(?:$Ident|\(\*[^\)]*\))\s*(?:;|=|,|\()/s) { | 1237 | } elsif ($prev_values eq 'E' && $s =~ /^.\s*(?:$Storage\s+)?(?:$Inline\s+)?(?:const\s+)?((?:\s*$Ident)+?)\b(?:\s+$Sparse)?\s*\**\s*(?:$Ident|\(\*[^\)]*\))(?:\s*$Modifier)?\s*(?:;|=|,|\()/s) { |
1183 | my $type = $1; | 1238 | my $type = $1; |
1184 | $type =~ s/\s+/ /g; | 1239 | $type =~ s/\s+/ /g; |
1185 | possible($type, "A:" . $s); | 1240 | possible($type, "A:" . $s); |
@@ -1239,6 +1294,10 @@ sub process { | |||
1239 | ERROR("switch and case should be at the same indent\n$hereline$err"); | 1294 | ERROR("switch and case should be at the same indent\n$hereline$err"); |
1240 | } | 1295 | } |
1241 | } | 1296 | } |
1297 | if ($line =~ /^.\s*(?:case\s*.*|default\s*):/g && | ||
1298 | $line !~ /\G(?:\s*{)?(?:\s*$;*)(?:\s*\\)?\s*$/g) { | ||
1299 | ERROR("trailing statements should be on next line\n" . $herecurr); | ||
1300 | } | ||
1242 | 1301 | ||
1243 | # if/while/etc brace do not go on next line, unless defining a do while loop, | 1302 | # if/while/etc brace do not go on next line, unless defining a do while loop, |
1244 | # or if that brace on the next line is for something else | 1303 | # or if that brace on the next line is for something else |
@@ -1246,17 +1305,22 @@ sub process { | |||
1246 | my $pre_ctx = "$1$2"; | 1305 | my $pre_ctx = "$1$2"; |
1247 | 1306 | ||
1248 | my ($level, @ctx) = ctx_statement_level($linenr, $realcnt, 0); | 1307 | my ($level, @ctx) = ctx_statement_level($linenr, $realcnt, 0); |
1249 | my $ctx_ln = $linenr + $#ctx + 1; | ||
1250 | my $ctx_cnt = $realcnt - $#ctx - 1; | 1308 | my $ctx_cnt = $realcnt - $#ctx - 1; |
1251 | my $ctx = join("\n", @ctx); | 1309 | my $ctx = join("\n", @ctx); |
1252 | 1310 | ||
1253 | ##warn "realcnt<$realcnt> ctx_cnt<$ctx_cnt>\n"; | 1311 | my $ctx_ln = $linenr; |
1312 | my $ctx_skip = $realcnt; | ||
1254 | 1313 | ||
1255 | # Skip over any removed lines in the context following statement. | 1314 | while ($ctx_skip > $ctx_cnt || ($ctx_skip == $ctx_cnt && |
1256 | while (defined($lines[$ctx_ln - 1]) && $lines[$ctx_ln - 1] =~ /^-/) { | 1315 | defined $lines[$ctx_ln - 1] && |
1316 | $lines[$ctx_ln - 1] =~ /^-/)) { | ||
1317 | ##print "SKIP<$ctx_skip> CNT<$ctx_cnt>\n"; | ||
1318 | $ctx_skip-- if (!defined $lines[$ctx_ln - 1] || $lines[$ctx_ln - 1] !~ /^-/); | ||
1257 | $ctx_ln++; | 1319 | $ctx_ln++; |
1258 | } | 1320 | } |
1259 | ##warn "pre<$pre_ctx>\nline<$line>\nctx<$ctx>\nnext<$lines[$ctx_ln - 1]>\n"; | 1321 | |
1322 | #print "realcnt<$realcnt> ctx_cnt<$ctx_cnt>\n"; | ||
1323 | #print "pre<$pre_ctx>\nline<$line>\nctx<$ctx>\nnext<$lines[$ctx_ln - 1]>\n"; | ||
1260 | 1324 | ||
1261 | if ($ctx !~ /{\s*/ && defined($lines[$ctx_ln -1]) && $lines[$ctx_ln - 1] =~ /^\+\s*{/) { | 1325 | if ($ctx !~ /{\s*/ && defined($lines[$ctx_ln -1]) && $lines[$ctx_ln - 1] =~ /^\+\s*{/) { |
1262 | ERROR("that open brace { should be on the previous line\n" . | 1326 | ERROR("that open brace { should be on the previous line\n" . |
@@ -1276,12 +1340,14 @@ sub process { | |||
1276 | 1340 | ||
1277 | # Track the 'values' across context and added lines. | 1341 | # Track the 'values' across context and added lines. |
1278 | my $opline = $line; $opline =~ s/^./ /; | 1342 | my $opline = $line; $opline =~ s/^./ /; |
1279 | my $curr_values = annotate_values($opline . "\n", $prev_values); | 1343 | my ($curr_values, $curr_vars) = |
1344 | annotate_values($opline . "\n", $prev_values); | ||
1280 | $curr_values = $prev_values . $curr_values; | 1345 | $curr_values = $prev_values . $curr_values; |
1281 | if ($dbg_values) { | 1346 | if ($dbg_values) { |
1282 | my $outline = $opline; $outline =~ s/\t/ /g; | 1347 | my $outline = $opline; $outline =~ s/\t/ /g; |
1283 | print "$linenr > .$outline\n"; | 1348 | print "$linenr > .$outline\n"; |
1284 | print "$linenr > $curr_values\n"; | 1349 | print "$linenr > $curr_values\n"; |
1350 | print "$linenr > $curr_vars\n"; | ||
1285 | } | 1351 | } |
1286 | $prev_values = substr($curr_values, -1); | 1352 | $prev_values = substr($curr_values, -1); |
1287 | 1353 | ||
@@ -1289,8 +1355,12 @@ sub process { | |||
1289 | if ($line=~/^[^\+]/) {next;} | 1355 | if ($line=~/^[^\+]/) {next;} |
1290 | 1356 | ||
1291 | # TEST: allow direct testing of the type matcher. | 1357 | # TEST: allow direct testing of the type matcher. |
1292 | if ($tst_type && $line =~ /^.$Declare$/) { | 1358 | if ($dbg_type) { |
1293 | ERROR("TEST: is type $Declare\n" . $herecurr); | 1359 | if ($line =~ /^.\s*$Declare\s*$/) { |
1360 | ERROR("TEST: is type\n" . $herecurr); | ||
1361 | } elsif ($dbg_type > 1 && $line =~ /^.+($Declare)/) { | ||
1362 | ERROR("TEST: is not type ($1 is)\n". $herecurr); | ||
1363 | } | ||
1294 | next; | 1364 | next; |
1295 | } | 1365 | } |
1296 | 1366 | ||
@@ -1365,11 +1435,11 @@ sub process { | |||
1365 | ERROR("\"(foo $1 )\" should be \"(foo $1)\"\n" . | 1435 | ERROR("\"(foo $1 )\" should be \"(foo $1)\"\n" . |
1366 | $herecurr); | 1436 | $herecurr); |
1367 | 1437 | ||
1368 | } elsif ($line =~ m{$NonptrType(\*+)(?:\s+(?:$Attribute|$Sparse))?\s+[A-Za-z\d_]+}) { | 1438 | } elsif ($line =~ m{\b$NonptrType(\*+)(?:\s+(?:$Attribute|$Sparse))?\s+[A-Za-z\d_]+}) { |
1369 | ERROR("\"foo$1 bar\" should be \"foo $1bar\"\n" . | 1439 | ERROR("\"foo$1 bar\" should be \"foo $1bar\"\n" . |
1370 | $herecurr); | 1440 | $herecurr); |
1371 | 1441 | ||
1372 | } elsif ($line =~ m{$NonptrType\s+(\*+)(?!\s+(?:$Attribute|$Sparse))\s+[A-Za-z\d_]+}) { | 1442 | } elsif ($line =~ m{\b$NonptrType\s+(\*+)(?!\s+(?:$Attribute|$Sparse))\s+[A-Za-z\d_]+}) { |
1373 | ERROR("\"foo $1 bar\" should be \"foo $1bar\"\n" . | 1443 | ERROR("\"foo $1 bar\" should be \"foo $1bar\"\n" . |
1374 | $herecurr); | 1444 | $herecurr); |
1375 | } | 1445 | } |
@@ -1421,6 +1491,17 @@ sub process { | |||
1421 | ERROR("open brace '{' following $1 go on the same line\n" . $hereprev); | 1491 | ERROR("open brace '{' following $1 go on the same line\n" . $hereprev); |
1422 | } | 1492 | } |
1423 | 1493 | ||
1494 | # check for spacing round square brackets; allowed: | ||
1495 | # 1. with a type on the left -- int [] a; | ||
1496 | # 2. at the beginning of a line for slice initialisers -- [0..10] = 5, | ||
1497 | while ($line =~ /(.*?\s)\[/g) { | ||
1498 | my ($where, $prefix) = ($-[1], $1); | ||
1499 | if ($prefix !~ /$Type\s+$/ && | ||
1500 | ($where != 0 || $prefix !~ /^.\s+$/)) { | ||
1501 | ERROR("space prohibited before open square bracket '['\n" . $herecurr); | ||
1502 | } | ||
1503 | } | ||
1504 | |||
1424 | # check for spaces between functions and their parentheses. | 1505 | # check for spaces between functions and their parentheses. |
1425 | while ($line =~ /($Ident)\s+\(/g) { | 1506 | while ($line =~ /($Ident)\s+\(/g) { |
1426 | my $name = $1; | 1507 | my $name = $1; |
@@ -1457,7 +1538,8 @@ sub process { | |||
1457 | <<=|>>=|<=|>=|==|!=| | 1538 | <<=|>>=|<=|>=|==|!=| |
1458 | \+=|-=|\*=|\/=|%=|\^=|\|=|&=| | 1539 | \+=|-=|\*=|\/=|%=|\^=|\|=|&=| |
1459 | =>|->|<<|>>|<|>|=|!|~| | 1540 | =>|->|<<|>>|<|>|=|!|~| |
1460 | &&|\|\||,|\^|\+\+|--|&|\||\+|-|\*|\/|% | 1541 | &&|\|\||,|\^|\+\+|--|&|\||\+|-|\*|\/|%| |
1542 | \?|: | ||
1461 | }x; | 1543 | }x; |
1462 | my @elements = split(/($ops|;)/, $opline); | 1544 | my @elements = split(/($ops|;)/, $opline); |
1463 | my $off = 0; | 1545 | my $off = 0; |
@@ -1504,22 +1586,11 @@ sub process { | |||
1504 | my $ptr = substr($blank, 0, $off) . "^"; | 1586 | my $ptr = substr($blank, 0, $off) . "^"; |
1505 | my $hereptr = "$hereline$ptr\n"; | 1587 | my $hereptr = "$hereline$ptr\n"; |
1506 | 1588 | ||
1507 | # Classify operators into binary, unary, or | 1589 | # Pull out the value of this operator. |
1508 | # definitions (* only) where they have more | ||
1509 | # than one mode. | ||
1510 | my $op_type = substr($curr_values, $off + 1, 1); | 1590 | my $op_type = substr($curr_values, $off + 1, 1); |
1511 | my $op_left = substr($curr_values, $off, 1); | 1591 | |
1512 | my $is_unary; | 1592 | # Get the full operator variant. |
1513 | if ($op_type eq 'T') { | 1593 | my $opv = $op . substr($curr_vars, $off, 1); |
1514 | $is_unary = 2; | ||
1515 | } elsif ($op_left eq 'V') { | ||
1516 | $is_unary = 0; | ||
1517 | } else { | ||
1518 | $is_unary = 1; | ||
1519 | } | ||
1520 | #if ($op eq '-' || $op eq '&' || $op eq '*') { | ||
1521 | # print "UNARY: <$op_left$op_type $is_unary $a:$op:$c> <$ca:$op:$cc> <$unary_ctx>\n"; | ||
1522 | #} | ||
1523 | 1594 | ||
1524 | # Ignore operators passed as parameters. | 1595 | # Ignore operators passed as parameters. |
1525 | if ($op_type ne 'V' && | 1596 | if ($op_type ne 'V' && |
@@ -1538,8 +1609,10 @@ sub process { | |||
1538 | # // is a comment | 1609 | # // is a comment |
1539 | } elsif ($op eq '//') { | 1610 | } elsif ($op eq '//') { |
1540 | 1611 | ||
1541 | # -> should have no spaces | 1612 | # No spaces for: |
1542 | } elsif ($op eq '->') { | 1613 | # -> |
1614 | # : when part of a bitfield | ||
1615 | } elsif ($op eq '->' || $opv eq ':B') { | ||
1543 | if ($ctx =~ /Wx.|.xW/) { | 1616 | if ($ctx =~ /Wx.|.xW/) { |
1544 | ERROR("spaces prohibited around that '$op' $at\n" . $hereptr); | 1617 | ERROR("spaces prohibited around that '$op' $at\n" . $hereptr); |
1545 | } | 1618 | } |
@@ -1551,18 +1624,19 @@ sub process { | |||
1551 | } | 1624 | } |
1552 | 1625 | ||
1553 | # '*' as part of a type definition -- reported already. | 1626 | # '*' as part of a type definition -- reported already. |
1554 | } elsif ($op eq '*' && $is_unary == 2) { | 1627 | } elsif ($opv eq '*_') { |
1555 | #warn "'*' is part of type\n"; | 1628 | #warn "'*' is part of type\n"; |
1556 | 1629 | ||
1557 | # unary operators should have a space before and | 1630 | # unary operators should have a space before and |
1558 | # none after. May be left adjacent to another | 1631 | # none after. May be left adjacent to another |
1559 | # unary operator, or a cast | 1632 | # unary operator, or a cast |
1560 | } elsif ($op eq '!' || $op eq '~' || | 1633 | } elsif ($op eq '!' || $op eq '~' || |
1561 | ($is_unary && ($op eq '*' || $op eq '-' || $op eq '&'))) { | 1634 | $opv eq '*U' || $opv eq '-U' || |
1635 | $opv eq '&U') { | ||
1562 | if ($ctx !~ /[WEBC]x./ && $ca !~ /(?:\)|!|~|\*|-|\&|\||\+\+|\-\-|\{)$/) { | 1636 | if ($ctx !~ /[WEBC]x./ && $ca !~ /(?:\)|!|~|\*|-|\&|\||\+\+|\-\-|\{)$/) { |
1563 | ERROR("space required before that '$op' $at\n" . $hereptr); | 1637 | ERROR("space required before that '$op' $at\n" . $hereptr); |
1564 | } | 1638 | } |
1565 | if ($op eq '*' && $cc =~/\s*const\b/) { | 1639 | if ($op eq '*' && $cc =~/\s*const\b/) { |
1566 | # A unary '*' may be const | 1640 | # A unary '*' may be const |
1567 | 1641 | ||
1568 | } elsif ($ctx =~ /.xW/) { | 1642 | } elsif ($ctx =~ /.xW/) { |
@@ -1595,11 +1669,33 @@ sub process { | |||
1595 | $hereptr); | 1669 | $hereptr); |
1596 | } | 1670 | } |
1597 | 1671 | ||
1672 | # A colon needs no spaces before when it is | ||
1673 | # terminating a case value or a label. | ||
1674 | } elsif ($opv eq ':C' || $opv eq ':L') { | ||
1675 | if ($ctx =~ /Wx./) { | ||
1676 | ERROR("space prohibited before that '$op' $at\n" . $hereptr); | ||
1677 | } | ||
1678 | |||
1598 | # All the others need spaces both sides. | 1679 | # All the others need spaces both sides. |
1599 | } elsif ($ctx !~ /[EWC]x[CWE]/) { | 1680 | } elsif ($ctx !~ /[EWC]x[CWE]/) { |
1681 | my $ok = 0; | ||
1682 | |||
1600 | # Ignore email addresses <foo@bar> | 1683 | # Ignore email addresses <foo@bar> |
1601 | if (!($op eq '<' && $cb =~ /$;\S+\@\S+>/) && | 1684 | if (($op eq '<' && |
1602 | !($op eq '>' && $cb =~ /<\S+\@\S+$;/)) { | 1685 | $cc =~ /^\S+\@\S+>/) || |
1686 | ($op eq '>' && | ||
1687 | $ca =~ /<\S+\@\S+$/)) | ||
1688 | { | ||
1689 | $ok = 1; | ||
1690 | } | ||
1691 | |||
1692 | # Ignore ?: | ||
1693 | if (($opv eq ':O' && $ca =~ /\?$/) || | ||
1694 | ($op eq '?' && $cc =~ /^:/)) { | ||
1695 | $ok = 1; | ||
1696 | } | ||
1697 | |||
1698 | if ($ok == 0) { | ||
1603 | ERROR("spaces required around that '$op' $at\n" . $hereptr); | 1699 | ERROR("spaces required around that '$op' $at\n" . $hereptr); |
1604 | } | 1700 | } |
1605 | } | 1701 | } |
@@ -1670,6 +1766,7 @@ sub process { | |||
1670 | my $value = $2; | 1766 | my $value = $2; |
1671 | 1767 | ||
1672 | # Flatten any parentheses and braces | 1768 | # Flatten any parentheses and braces |
1769 | $value =~ s/\)\(/\) \(/g; | ||
1673 | while ($value =~ s/\([^\(\)]*\)/1/) { | 1770 | while ($value =~ s/\([^\(\)]*\)/1/) { |
1674 | } | 1771 | } |
1675 | 1772 | ||
@@ -1686,8 +1783,9 @@ sub process { | |||
1686 | ERROR("space required before the open parenthesis '('\n" . $herecurr); | 1783 | ERROR("space required before the open parenthesis '('\n" . $herecurr); |
1687 | } | 1784 | } |
1688 | 1785 | ||
1689 | # Check for illegal assignment in if conditional. | 1786 | # Check for illegal assignment in if conditional -- and check for trailing |
1690 | if ($line =~ /\bif\s*\(/) { | 1787 | # statements after the conditional. |
1788 | if ($line =~ /\b(?:if|while|for)\s*\(/ && $line !~ /^.\s*#/) { | ||
1691 | my ($s, $c) = ($stat, $cond); | 1789 | my ($s, $c) = ($stat, $cond); |
1692 | 1790 | ||
1693 | if ($c =~ /\bif\s*\(.*[^<>!=]=[^=].*/) { | 1791 | if ($c =~ /\bif\s*\(.*[^<>!=]=[^=].*/) { |
@@ -1699,13 +1797,63 @@ sub process { | |||
1699 | substr($s, 0, length($c), ''); | 1797 | substr($s, 0, length($c), ''); |
1700 | $s =~ s/\n.*//g; | 1798 | $s =~ s/\n.*//g; |
1701 | $s =~ s/$;//g; # Remove any comments | 1799 | $s =~ s/$;//g; # Remove any comments |
1702 | if (length($c) && $s !~ /^\s*({|;|)\s*\\*\s*$/ && | 1800 | if (length($c) && $s !~ /^\s*{?\s*\\*\s*$/ && |
1703 | $c !~ /^.\s*\#\s*if/) | 1801 | $c !~ /}\s*while\s*/) |
1704 | { | 1802 | { |
1705 | ERROR("trailing statements should be on next line\n" . $herecurr); | 1803 | ERROR("trailing statements should be on next line\n" . $herecurr); |
1706 | } | 1804 | } |
1707 | } | 1805 | } |
1708 | 1806 | ||
1807 | # Check relative indent for conditionals and blocks. | ||
1808 | if ($line =~ /\b(?:(?:if|while|for)\s*\(|do\b)/ && $line !~ /^.\s*#/ && $line !~ /\}\s*while\s*/) { | ||
1809 | my ($s, $c) = ($stat, $cond); | ||
1810 | |||
1811 | substr($s, 0, length($c), ''); | ||
1812 | |||
1813 | # Make sure we remove the line prefixes as we have | ||
1814 | # none on the first line, and are going to readd them | ||
1815 | # where necessary. | ||
1816 | $s =~ s/\n./\n/gs; | ||
1817 | |||
1818 | # We want to check the first line inside the block | ||
1819 | # starting at the end of the conditional, so remove: | ||
1820 | # 1) any blank line termination | ||
1821 | # 2) any opening brace { on end of the line | ||
1822 | # 3) any do (...) { | ||
1823 | my $continuation = 0; | ||
1824 | my $check = 0; | ||
1825 | $s =~ s/^.*\bdo\b//; | ||
1826 | $s =~ s/^\s*{//; | ||
1827 | if ($s =~ s/^\s*\\//) { | ||
1828 | $continuation = 1; | ||
1829 | } | ||
1830 | if ($s =~ s/^\s*\n//) { | ||
1831 | $check = 1; | ||
1832 | } | ||
1833 | |||
1834 | # Also ignore a loop construct at the end of a | ||
1835 | # preprocessor statement. | ||
1836 | if (($prevline =~ /^.\s*#\s*define\s/ || | ||
1837 | $prevline =~ /\\\s*$/) && $continuation == 0) { | ||
1838 | $check = 0; | ||
1839 | } | ||
1840 | |||
1841 | # Ignore the current line if its is a preprocessor | ||
1842 | # line. | ||
1843 | if ($s =~ /^\s*#\s*/) { | ||
1844 | $check = 0; | ||
1845 | } | ||
1846 | |||
1847 | my (undef, $sindent) = line_stats("+" . $s); | ||
1848 | |||
1849 | ##print "line<$line> prevline<$prevline> indent<$indent> sindent<$sindent> check<$check> continuation<$continuation> s<$s>\n"; | ||
1850 | |||
1851 | if ($check && (($sindent % 8) != 0 || | ||
1852 | ($sindent <= $indent && $s ne ''))) { | ||
1853 | WARN("suspect code indent for conditional statements\n" . $herecurr); | ||
1854 | } | ||
1855 | } | ||
1856 | |||
1709 | # Check for bitwise tests written as boolean | 1857 | # Check for bitwise tests written as boolean |
1710 | if ($line =~ / | 1858 | if ($line =~ / |
1711 | (?: | 1859 | (?: |
@@ -1777,7 +1925,8 @@ sub process { | |||
1777 | # multi-statement macros should be enclosed in a do while loop, grab the | 1925 | # multi-statement macros should be enclosed in a do while loop, grab the |
1778 | # first statement and ensure its the whole macro if its not enclosed | 1926 | # first statement and ensure its the whole macro if its not enclosed |
1779 | # in a known good container | 1927 | # in a known good container |
1780 | if ($line =~ /^.\s*\#\s*define\s*$Ident(\()?/) { | 1928 | if ($realfile !~ m@/vmlinux.lds.h$@ && |
1929 | $line =~ /^.\s*\#\s*define\s*$Ident(\()?/) { | ||
1781 | my $ln = $linenr; | 1930 | my $ln = $linenr; |
1782 | my $cnt = $realcnt; | 1931 | my $cnt = $realcnt; |
1783 | my ($off, $dstat, $dcond, $rest); | 1932 | my ($off, $dstat, $dcond, $rest); |
@@ -1791,30 +1940,26 @@ sub process { | |||
1791 | $lines[$ln - 1] =~ /^(?:-|..*\\$)/) | 1940 | $lines[$ln - 1] =~ /^(?:-|..*\\$)/) |
1792 | { | 1941 | { |
1793 | $ctx .= $rawlines[$ln - 1] . "\n"; | 1942 | $ctx .= $rawlines[$ln - 1] . "\n"; |
1943 | $cnt-- if ($lines[$ln - 1] !~ /^-/); | ||
1794 | $ln++; | 1944 | $ln++; |
1795 | $cnt--; | ||
1796 | } | 1945 | } |
1797 | $ctx .= $rawlines[$ln - 1]; | 1946 | $ctx .= $rawlines[$ln - 1]; |
1798 | 1947 | ||
1799 | ($dstat, $dcond, $ln, $cnt, $off) = | 1948 | ($dstat, $dcond, $ln, $cnt, $off) = |
1800 | ctx_statement_block($linenr, $ln - $linenr + 1, 0); | 1949 | ctx_statement_block($linenr, $ln - $linenr + 1, 0); |
1801 | #print "dstat<$dstat> dcond<$dcond> cnt<$cnt> off<$off>\n"; | 1950 | #print "dstat<$dstat> dcond<$dcond> cnt<$cnt> off<$off>\n"; |
1802 | #print "LINE<$lines[$ln]> len<" . length($lines[$ln]) . "\n"; | 1951 | #print "LINE<$lines[$ln-1]> len<" . length($lines[$ln-1]) . "\n"; |
1803 | 1952 | ||
1804 | # Extract the remainder of the define (if any) and | 1953 | # Extract the remainder of the define (if any) and |
1805 | # rip off surrounding spaces, and trailing \'s. | 1954 | # rip off surrounding spaces, and trailing \'s. |
1806 | $rest = ''; | 1955 | $rest = ''; |
1807 | if (defined $lines[$ln - 1] && | 1956 | while ($off != 0 || ($cnt > 0 && $rest =~ /(?:^|\\)\s*$/)) { |
1808 | $off > length($lines[$ln - 1])) | 1957 | #print "ADDING $off <" . substr($lines[$ln - 1], $off) . ">\n"; |
1809 | { | 1958 | if ($off != 0 || $lines[$ln - 1] !~ /^-/) { |
1810 | $ln++; | 1959 | $rest .= substr($lines[$ln - 1], $off) . "\n"; |
1811 | $cnt--; | 1960 | $cnt--; |
1812 | $off = 0; | 1961 | } |
1813 | } | ||
1814 | while ($cnt > 0) { | ||
1815 | $rest .= substr($lines[$ln - 1], $off) . "\n"; | ||
1816 | $ln++; | 1962 | $ln++; |
1817 | $cnt--; | ||
1818 | $off = 0; | 1963 | $off = 0; |
1819 | } | 1964 | } |
1820 | $rest =~ s/\\\n.//g; | 1965 | $rest =~ s/\\\n.//g; |
@@ -1827,6 +1972,7 @@ sub process { | |||
1827 | } else { | 1972 | } else { |
1828 | $dstat =~ s/^.\s*\#\s*define\s+$Ident\s*//; | 1973 | $dstat =~ s/^.\s*\#\s*define\s+$Ident\s*//; |
1829 | } | 1974 | } |
1975 | $dstat =~ s/$;//g; | ||
1830 | $dstat =~ s/\\\n.//g; | 1976 | $dstat =~ s/\\\n.//g; |
1831 | $dstat =~ s/^\s*//s; | 1977 | $dstat =~ s/^\s*//s; |
1832 | $dstat =~ s/\s*$//s; | 1978 | $dstat =~ s/\s*$//s; |
@@ -1845,6 +1991,7 @@ sub process { | |||
1845 | DEFINE_PER_CPU| | 1991 | DEFINE_PER_CPU| |
1846 | __typeof__\( | 1992 | __typeof__\( |
1847 | }x; | 1993 | }x; |
1994 | #print "REST<$rest>\n"; | ||
1848 | if ($rest ne '') { | 1995 | if ($rest ne '') { |
1849 | if ($rest !~ /while\s*\(/ && | 1996 | if ($rest !~ /while\s*\(/ && |
1850 | $dstat !~ /$exceptions/) | 1997 | $dstat !~ /$exceptions/) |
@@ -2001,7 +2148,14 @@ sub process { | |||
2001 | if ($prevline =~ /\bif\s*\(([^\)]*)\)/) { | 2148 | if ($prevline =~ /\bif\s*\(([^\)]*)\)/) { |
2002 | my $expr = $1; | 2149 | my $expr = $1; |
2003 | if ($line =~ /\bkfree\(\Q$expr\E\);/) { | 2150 | if ($line =~ /\bkfree\(\Q$expr\E\);/) { |
2004 | WARN("kfree(NULL) is safe this check is probabally not required\n" . $hereprev); | 2151 | WARN("kfree(NULL) is safe this check is probably not required\n" . $hereprev); |
2152 | } | ||
2153 | } | ||
2154 | # check for needless usb_free_urb() checks | ||
2155 | if ($prevline =~ /\bif\s*\(([^\)]*)\)/) { | ||
2156 | my $expr = $1; | ||
2157 | if ($line =~ /\busb_free_urb\(\Q$expr\E\);/) { | ||
2158 | WARN("usb_free_urb(NULL) is safe this check is probably not required\n" . $hereprev); | ||
2005 | } | 2159 | } |
2006 | } | 2160 | } |
2007 | 2161 | ||
@@ -2106,6 +2260,10 @@ sub process { | |||
2106 | if ($line =~ /\bsimple_(strto.*?)\s*\(/) { | 2260 | if ($line =~ /\bsimple_(strto.*?)\s*\(/) { |
2107 | WARN("consider using strict_$1 in preference to simple_$1\n" . $herecurr); | 2261 | WARN("consider using strict_$1 in preference to simple_$1\n" . $herecurr); |
2108 | } | 2262 | } |
2263 | # check for __initcall(), use device_initcall() explicitly please | ||
2264 | if ($line =~ /^.\s*__initcall\s*\(/) { | ||
2265 | WARN("please use device_initcall() instead of __initcall()\n" . $herecurr); | ||
2266 | } | ||
2109 | 2267 | ||
2110 | # use of NR_CPUS is usually wrong | 2268 | # use of NR_CPUS is usually wrong |
2111 | # ignore definitions of NR_CPUS and usage to define arrays as likely right | 2269 | # ignore definitions of NR_CPUS and usage to define arrays as likely right |
diff --git a/scripts/checkstack.pl b/scripts/checkstack.pl index 340ad6920511..3eca62566d6b 100755 --- a/scripts/checkstack.pl +++ b/scripts/checkstack.pl | |||
@@ -26,12 +26,17 @@ | |||
26 | # $& (whole re) matches the complete objdump line with the stack growth | 26 | # $& (whole re) matches the complete objdump line with the stack growth |
27 | # $1 (first bracket) matches the size of the stack growth | 27 | # $1 (first bracket) matches the size of the stack growth |
28 | # | 28 | # |
29 | # $dre is similar, but for dynamic stack redutions: | ||
30 | # $& (whole re) matches the complete objdump line with the stack growth | ||
31 | # $1 (first bracket) matches the dynamic amount of the stack growth | ||
32 | # | ||
29 | # use anything else and feel the pain ;) | 33 | # use anything else and feel the pain ;) |
30 | my (@stack, $re, $x, $xs); | 34 | my (@stack, $re, $dre, $x, $xs); |
31 | { | 35 | { |
32 | my $arch = shift; | 36 | my $arch = shift; |
33 | if ($arch eq "") { | 37 | if ($arch eq "") { |
34 | $arch = `uname -m`; | 38 | $arch = `uname -m`; |
39 | chomp($arch); | ||
35 | } | 40 | } |
36 | 41 | ||
37 | $x = "[0-9a-f]"; # hex character | 42 | $x = "[0-9a-f]"; # hex character |
@@ -46,9 +51,11 @@ my (@stack, $re, $x, $xs); | |||
46 | } elsif ($arch =~ /^i[3456]86$/) { | 51 | } elsif ($arch =~ /^i[3456]86$/) { |
47 | #c0105234: 81 ec ac 05 00 00 sub $0x5ac,%esp | 52 | #c0105234: 81 ec ac 05 00 00 sub $0x5ac,%esp |
48 | $re = qr/^.*[as][du][db] \$(0x$x{1,8}),\%esp$/o; | 53 | $re = qr/^.*[as][du][db] \$(0x$x{1,8}),\%esp$/o; |
54 | $dre = qr/^.*[as][du][db] (%.*),\%esp$/o; | ||
49 | } elsif ($arch eq 'x86_64') { | 55 | } elsif ($arch eq 'x86_64') { |
50 | # 2f60: 48 81 ec e8 05 00 00 sub $0x5e8,%rsp | 56 | # 2f60: 48 81 ec e8 05 00 00 sub $0x5e8,%rsp |
51 | $re = qr/^.*[as][du][db] \$(0x$x{1,8}),\%rsp$/o; | 57 | $re = qr/^.*[as][du][db] \$(0x$x{1,8}),\%rsp$/o; |
58 | $dre = qr/^.*[as][du][db] (\%.*),\%rsp$/o; | ||
52 | } elsif ($arch eq 'ia64') { | 59 | } elsif ($arch eq 'ia64') { |
53 | #e0000000044011fc: 01 0f fc 8c adds r12=-384,r12 | 60 | #e0000000044011fc: 01 0f fc 8c adds r12=-384,r12 |
54 | $re = qr/.*adds.*r12=-(([0-9]{2}|[3-9])[0-9]{2}),r12/o; | 61 | $re = qr/.*adds.*r12=-(([0-9]{2}|[3-9])[0-9]{2}),r12/o; |
@@ -85,7 +92,7 @@ my (@stack, $re, $x, $xs); | |||
85 | # 0: 00 e8 38 01 LINK 0x4e0; | 92 | # 0: 00 e8 38 01 LINK 0x4e0; |
86 | $re = qr/.*[[:space:]]LINK[[:space:]]*(0x$x{1,8})/o; | 93 | $re = qr/.*[[:space:]]LINK[[:space:]]*(0x$x{1,8})/o; |
87 | } else { | 94 | } else { |
88 | print("wrong or unknown architecture\n"); | 95 | print("wrong or unknown architecture \"$arch\"\n"); |
89 | exit | 96 | exit |
90 | } | 97 | } |
91 | } | 98 | } |
@@ -141,6 +148,22 @@ while (my $line = <STDIN>) { | |||
141 | next if ($size < 100); | 148 | next if ($size < 100); |
142 | push @stack, "$intro$size\n"; | 149 | push @stack, "$intro$size\n"; |
143 | } | 150 | } |
151 | elsif (defined $dre && $line =~ m/$dre/) { | ||
152 | my $size = "Dynamic ($1)"; | ||
153 | |||
154 | next if $line !~ m/^($xs*)/; | ||
155 | my $addr = $1; | ||
156 | $addr =~ s/ /0/g; | ||
157 | $addr = "0x$addr"; | ||
158 | |||
159 | my $intro = "$addr $func [$file]:"; | ||
160 | my $padlen = 56 - length($intro); | ||
161 | while ($padlen > 0) { | ||
162 | $intro .= ' '; | ||
163 | $padlen -= 8; | ||
164 | } | ||
165 | push @stack, "$intro$size\n"; | ||
166 | } | ||
144 | } | 167 | } |
145 | 168 | ||
146 | print sort bysize @stack; | 169 | print sort bysize @stack; |
diff --git a/scripts/genksyms/genksyms.c b/scripts/genksyms/genksyms.c index dca5e0dd09bf..4f8a3007e457 100644 --- a/scripts/genksyms/genksyms.c +++ b/scripts/genksyms/genksyms.c | |||
@@ -520,8 +520,7 @@ int main(int argc, char **argv) | |||
520 | genksyms_usage(); | 520 | genksyms_usage(); |
521 | return 1; | 521 | return 1; |
522 | } | 522 | } |
523 | if ((strcmp(arch, "v850") == 0) || (strcmp(arch, "h8300") == 0) | 523 | if ((strcmp(arch, "h8300") == 0) || (strcmp(arch, "blackfin") == 0)) |
524 | || (strcmp(arch, "blackfin") == 0)) | ||
525 | mod_prefix = "_"; | 524 | mod_prefix = "_"; |
526 | { | 525 | { |
527 | extern int yydebug; | 526 | extern int yydebug; |
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index 37d5c363fbcd..4fa1f3ad2513 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c | |||
@@ -340,11 +340,18 @@ static int do_acpi_entry(const char *filename, | |||
340 | } | 340 | } |
341 | 341 | ||
342 | /* looks like: "pnp:dD" */ | 342 | /* looks like: "pnp:dD" */ |
343 | static int do_pnp_entry(const char *filename, | 343 | static void do_pnp_device_entry(void *symval, unsigned long size, |
344 | struct pnp_device_id *id, char *alias) | 344 | struct module *mod) |
345 | { | 345 | { |
346 | sprintf(alias, "pnp:d%s*", id->id); | 346 | const unsigned long id_size = sizeof(struct pnp_device_id); |
347 | return 1; | 347 | const struct pnp_device_id *id = symval; |
348 | |||
349 | device_id_check(mod->name, "pnp", size, id_size, symval); | ||
350 | |||
351 | buf_printf(&mod->dev_table_buf, | ||
352 | "MODULE_ALIAS(\"pnp:d%s*\");\n", id->id); | ||
353 | buf_printf(&mod->dev_table_buf, | ||
354 | "MODULE_ALIAS(\"acpi*:%s:*\");\n", id->id); | ||
348 | } | 355 | } |
349 | 356 | ||
350 | /* looks like: "pnp:dD" for every device of the card */ | 357 | /* looks like: "pnp:dD" for every device of the card */ |
@@ -388,9 +395,12 @@ static void do_pnp_card_entries(void *symval, unsigned long size, | |||
388 | } | 395 | } |
389 | 396 | ||
390 | /* add an individual alias for every device entry */ | 397 | /* add an individual alias for every device entry */ |
391 | if (!dup) | 398 | if (!dup) { |
392 | buf_printf(&mod->dev_table_buf, | 399 | buf_printf(&mod->dev_table_buf, |
393 | "MODULE_ALIAS(\"pnp:d%s*\");\n", id); | 400 | "MODULE_ALIAS(\"pnp:d%s*\");\n", id); |
401 | buf_printf(&mod->dev_table_buf, | ||
402 | "MODULE_ALIAS(\"acpi*:%s:*\");\n", id); | ||
403 | } | ||
394 | } | 404 | } |
395 | } | 405 | } |
396 | } | 406 | } |
@@ -613,7 +623,7 @@ static int do_i2c_entry(const char *filename, struct i2c_device_id *id, | |||
613 | return 1; | 623 | return 1; |
614 | } | 624 | } |
615 | 625 | ||
616 | /* Ignore any prefix, eg. v850 prepends _ */ | 626 | /* Ignore any prefix, eg. some architectures prepend _ */ |
617 | static inline int sym_is(const char *symbol, const char *name) | 627 | static inline int sym_is(const char *symbol, const char *name) |
618 | { | 628 | { |
619 | const char *match; | 629 | const char *match; |
@@ -701,9 +711,7 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, | |||
701 | sizeof(struct acpi_device_id), "acpi", | 711 | sizeof(struct acpi_device_id), "acpi", |
702 | do_acpi_entry, mod); | 712 | do_acpi_entry, mod); |
703 | else if (sym_is(symname, "__mod_pnp_device_table")) | 713 | else if (sym_is(symname, "__mod_pnp_device_table")) |
704 | do_table(symval, sym->st_size, | 714 | do_pnp_device_entry(symval, sym->st_size, mod); |
705 | sizeof(struct pnp_device_id), "pnp", | ||
706 | do_pnp_entry, mod); | ||
707 | else if (sym_is(symname, "__mod_pnp_card_device_table")) | 715 | else if (sym_is(symname, "__mod_pnp_card_device_table")) |
708 | do_pnp_card_entries(symval, sym->st_size, mod); | 716 | do_pnp_card_entries(symval, sym->st_size, mod); |
709 | else if (sym_is(symname, "__mod_pcmcia_device_table")) | 717 | else if (sym_is(symname, "__mod_pcmcia_device_table")) |
diff --git a/scripts/mod/mk_elfconfig.c b/scripts/mod/mk_elfconfig.c index db3881f14c2d..6a96d47bd1e6 100644 --- a/scripts/mod/mk_elfconfig.c +++ b/scripts/mod/mk_elfconfig.c | |||
@@ -55,7 +55,7 @@ main(int argc, char **argv) | |||
55 | else | 55 | else |
56 | exit(1); | 56 | exit(1); |
57 | 57 | ||
58 | if ((strcmp(argv[1], "v850") == 0) || (strcmp(argv[1], "h8300") == 0) | 58 | if ((strcmp(argv[1], "h8300") == 0) |
59 | || (strcmp(argv[1], "blackfin") == 0)) | 59 | || (strcmp(argv[1], "blackfin") == 0)) |
60 | printf("#define MODULE_SYMBOL_PREFIX \"_\"\n"); | 60 | printf("#define MODULE_SYMBOL_PREFIX \"_\"\n"); |
61 | else | 61 | else |
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index a07f91aac920..8f038e6d5f98 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c | |||
@@ -1992,7 +1992,8 @@ static void read_markers(const char *fname) | |||
1992 | mod->skip = 1; | 1992 | mod->skip = 1; |
1993 | } | 1993 | } |
1994 | 1994 | ||
1995 | add_marker(mod, marker, fmt); | 1995 | if (!mod->skip) |
1996 | add_marker(mod, marker, fmt); | ||
1996 | } | 1997 | } |
1997 | return; | 1998 | return; |
1998 | fail: | 1999 | fail: |