diff options
author | David Woodhouse <dwmw2@infradead.org> | 2007-07-23 05:20:10 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@infradead.org> | 2007-07-23 05:20:10 -0400 |
commit | 39fe5434cb9de5da40510028b17b96bc4eb312b3 (patch) | |
tree | 7a02a317b9ad57da51ca99887c119e779ccf3f13 /scripts | |
parent | 0fc72b81d3111d114ab378935b1cf07680ca1289 (diff) | |
parent | f695baf2df9e0413d3521661070103711545207a (diff) |
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/Kbuild.include | 7 | ||||
-rwxr-xr-x | scripts/Lindent | 2 | ||||
-rw-r--r-- | scripts/Makefile.build | 16 | ||||
-rw-r--r-- | scripts/Makefile.headersinst | 14 | ||||
-rw-r--r-- | scripts/Makefile.modpost | 4 | ||||
-rwxr-xr-x | scripts/checkpatch.pl | 535 | ||||
-rwxr-xr-x | scripts/cleanfile | 54 | ||||
-rwxr-xr-x | scripts/cleanpatch | 58 | ||||
-rw-r--r-- | scripts/decodecode | 51 | ||||
-rw-r--r-- | scripts/gcc-version.sh | 15 | ||||
-rw-r--r-- | scripts/gen_initramfs_list.sh | 12 | ||||
-rw-r--r-- | scripts/kallsyms.c | 21 | ||||
-rw-r--r-- | scripts/kconfig/Makefile | 35 | ||||
-rw-r--r-- | scripts/kconfig/confdata.c | 37 | ||||
-rw-r--r-- | scripts/kconfig/kxgettext.c | 4 | ||||
-rw-r--r-- | scripts/kconfig/lxdialog/check-lxdialog.sh | 2 | ||||
-rw-r--r-- | scripts/kconfig/mconf.c | 11 | ||||
-rwxr-xr-x | scripts/kernel-doc | 28 | ||||
-rw-r--r-- | scripts/mod/modpost.c | 313 | ||||
-rw-r--r-- | scripts/mod/modpost.h | 3 |
20 files changed, 805 insertions, 417 deletions
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 06c1a377c4c5..677bc6c175cb 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include | |||
@@ -100,9 +100,14 @@ cc-option-align = $(subst -functions=0,,\ | |||
100 | $(call cc-option,-falign-functions=0,-malign-functions=0)) | 100 | $(call cc-option,-falign-functions=0,-malign-functions=0)) |
101 | 101 | ||
102 | # cc-version | 102 | # cc-version |
103 | # Usage gcc-ver := $(call cc-version,$(CC)) | 103 | # Usage gcc-ver := $(call cc-version) |
104 | cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh $(CC)) | 104 | cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh $(CC)) |
105 | 105 | ||
106 | # cc-fullversion | ||
107 | # Usage gcc-ver := $(call cc-fullversion) | ||
108 | cc-fullversion = $(shell $(CONFIG_SHELL) \ | ||
109 | $(srctree)/scripts/gcc-version.sh -p $(CC)) | ||
110 | |||
106 | # cc-ifversion | 111 | # cc-ifversion |
107 | # Usage: EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1) | 112 | # Usage: EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1) |
108 | cc-ifversion = $(shell [ $(call cc-version, $(CC)) $(1) $(2) ] && echo $(3)) | 113 | cc-ifversion = $(shell [ $(call cc-version, $(CC)) $(1) $(2) ] && echo $(3)) |
diff --git a/scripts/Lindent b/scripts/Lindent index 7d8d8896e309..9468ec7971db 100755 --- a/scripts/Lindent +++ b/scripts/Lindent | |||
@@ -1,2 +1,2 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | indent -npro -kr -i8 -ts8 -sob -l80 -ss -ncs "$@" | 2 | indent -npro -kr -i8 -ts8 -sob -l80 -ss -ncs -cp1 "$@" |
diff --git a/scripts/Makefile.build b/scripts/Makefile.build index a525112847fd..3f7b451f3955 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build | |||
@@ -7,6 +7,22 @@ src := $(obj) | |||
7 | PHONY := __build | 7 | PHONY := __build |
8 | __build: | 8 | __build: |
9 | 9 | ||
10 | # Init all relevant variables used in kbuild files so | ||
11 | # 1) they have correct type | ||
12 | # 2) they do not inherit any value from the environment | ||
13 | obj-y := | ||
14 | obj-m := | ||
15 | lib-y := | ||
16 | lib-m := | ||
17 | always := | ||
18 | targets := | ||
19 | subdir-y := | ||
20 | subdir-m := | ||
21 | EXTRA_AFLAGS := | ||
22 | EXTRA_CFLAGS := | ||
23 | EXTRA_CPPFLAGS := | ||
24 | EXTRA_LDFLAGS := | ||
25 | |||
10 | # Read .config if it exist, otherwise ignore | 26 | # Read .config if it exist, otherwise ignore |
11 | -include include/config/auto.conf | 27 | -include include/config/auto.conf |
12 | 28 | ||
diff --git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst index f98d772aac80..53dae3eb3d1f 100644 --- a/scripts/Makefile.headersinst +++ b/scripts/Makefile.headersinst | |||
@@ -11,13 +11,13 @@ UNIFDEF := scripts/unifdef -U__KERNEL__ | |||
11 | 11 | ||
12 | # Eliminate the contents of (and inclusions of) compiler.h | 12 | # Eliminate the contents of (and inclusions of) compiler.h |
13 | HDRSED := sed -e "s/ inline / __inline__ /g" \ | 13 | HDRSED := sed -e "s/ inline / __inline__ /g" \ |
14 | -e "s/[[:space:]]__user[[:space:]]\+/ /g" \ | 14 | -e "s/[[:space:]]__user[[:space:]]\{1,\}/ /g" \ |
15 | -e "s/(__user[[:space:]]\+/ (/g" \ | 15 | -e "s/(__user[[:space:]]\{1,\}/ (/g" \ |
16 | -e "s/[[:space:]]__force[[:space:]]\+/ /g" \ | 16 | -e "s/[[:space:]]__force[[:space:]]\{1,\}/ /g" \ |
17 | -e "s/(__force[[:space:]]\+/ (/g" \ | 17 | -e "s/(__force[[:space:]]\{1,\}/ (/g" \ |
18 | -e "s/[[:space:]]__iomem[[:space:]]\+/ /g" \ | 18 | -e "s/[[:space:]]__iomem[[:space:]]\{1,\}/ /g" \ |
19 | -e "s/(__iomem[[:space:]]\+/ (/g" \ | 19 | -e "s/(__iomem[[:space:]]\{1,\}/ (/g" \ |
20 | -e "s/[[:space:]]__attribute_const__[[:space:]]\+/\ /g" \ | 20 | -e "s/[[:space:]]__attribute_const__[[:space:]]\{1,\}/\ /g" \ |
21 | -e "s/[[:space:]]__attribute_const__$$//" \ | 21 | -e "s/[[:space:]]__attribute_const__$$//" \ |
22 | -e "/^\#include <linux\/compiler.h>/d" | 22 | -e "/^\#include <linux\/compiler.h>/d" |
23 | 23 | ||
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index d5bbbcce31ef..c6fcc597b3be 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost | |||
@@ -70,10 +70,10 @@ __modpost: $(modules:.ko=.o) FORCE | |||
70 | $(call cmd,modpost) $(wildcard vmlinux) $(filter-out FORCE,$^) | 70 | $(call cmd,modpost) $(wildcard vmlinux) $(filter-out FORCE,$^) |
71 | 71 | ||
72 | quiet_cmd_kernel-mod = MODPOST $@ | 72 | quiet_cmd_kernel-mod = MODPOST $@ |
73 | cmd_kernel-mod = $(cmd_modpost) $(KBUILD_VMLINUX_OBJS) | 73 | cmd_kernel-mod = $(cmd_modpost) $@ |
74 | 74 | ||
75 | PHONY += vmlinux | 75 | PHONY += vmlinux |
76 | vmlinux: FORCE | 76 | vmlinux.o: FORCE |
77 | $(call cmd,kernel-mod) | 77 | $(call cmd,kernel-mod) |
78 | 78 | ||
79 | # Declare generated files as targets for modpost | 79 | # Declare generated files as targets for modpost |
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 277c32647f36..73751ab6ec0c 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.06'; | 12 | my $V = '0.08'; |
13 | 13 | ||
14 | use Getopt::Long qw(:config no_auto_abbrev); | 14 | use Getopt::Long qw(:config no_auto_abbrev); |
15 | 15 | ||
@@ -47,16 +47,14 @@ my $removal = 'Documentation/feature-removal-schedule.txt'; | |||
47 | if ($tree && -f $removal) { | 47 | if ($tree && -f $removal) { |
48 | open(REMOVE, "<$removal") || die "$P: $removal: open failed - $!\n"; | 48 | open(REMOVE, "<$removal") || die "$P: $removal: open failed - $!\n"; |
49 | while (<REMOVE>) { | 49 | while (<REMOVE>) { |
50 | if (/^Files:\s+(.*\S)/) { | 50 | if (/^Check:\s+(.*\S)/) { |
51 | for my $file (split(/[, ]+/, $1)) { | 51 | for my $entry (split(/[, ]+/, $1)) { |
52 | if ($file =~ m@include/(.*)@) { | 52 | if ($entry =~ m@include/(.*)@) { |
53 | push(@dep_includes, $1); | 53 | push(@dep_includes, $1); |
54 | } | ||
55 | } | ||
56 | 54 | ||
57 | } elsif (/^Funcs:\s+(.*\S)/) { | 55 | } elsif ($entry !~ m@/@) { |
58 | for my $func (split(/[, ]+/, $1)) { | 56 | push(@dep_functions, $entry); |
59 | push(@dep_functions, $func); | 57 | } |
60 | } | 58 | } |
61 | } | 59 | } |
62 | } | 60 | } |
@@ -153,7 +151,7 @@ sub sanitise_line { | |||
153 | } | 151 | } |
154 | 152 | ||
155 | sub ctx_block_get { | 153 | sub ctx_block_get { |
156 | my ($linenr, $remain, $outer, $open, $close) = @_; | 154 | my ($linenr, $remain, $outer, $open, $close, $off) = @_; |
157 | my $line; | 155 | my $line; |
158 | my $start = $linenr - 1; | 156 | my $start = $linenr - 1; |
159 | my $blk = ''; | 157 | my $blk = ''; |
@@ -161,38 +159,58 @@ sub ctx_block_get { | |||
161 | my @c; | 159 | my @c; |
162 | my @res = (); | 160 | my @res = (); |
163 | 161 | ||
162 | my $level = 0; | ||
164 | for ($line = $start; $remain > 0; $line++) { | 163 | for ($line = $start; $remain > 0; $line++) { |
165 | next if ($rawlines[$line] =~ /^-/); | 164 | next if ($rawlines[$line] =~ /^-/); |
166 | $remain--; | 165 | $remain--; |
167 | 166 | ||
168 | $blk .= $rawlines[$line]; | 167 | $blk .= $rawlines[$line]; |
168 | foreach my $c (split(//, $rawlines[$line])) { | ||
169 | ##print "C<$c>L<$level><$open$close>O<$off>\n"; | ||
170 | if ($off > 0) { | ||
171 | $off--; | ||
172 | next; | ||
173 | } | ||
169 | 174 | ||
170 | @o = ($blk =~ /$open/g); | 175 | if ($c eq $close && $level > 0) { |
171 | @c = ($blk =~ /$close/g); | 176 | $level--; |
177 | last if ($level == 0); | ||
178 | } elsif ($c eq $open) { | ||
179 | $level++; | ||
180 | } | ||
181 | } | ||
172 | 182 | ||
173 | if (!$outer || (scalar(@o) - scalar(@c)) == 1) { | 183 | if (!$outer || $level <= 1) { |
174 | push(@res, $rawlines[$line]); | 184 | push(@res, $rawlines[$line]); |
175 | } | 185 | } |
176 | 186 | ||
177 | last if (scalar(@o) == scalar(@c)); | 187 | last if ($level == 0); |
178 | } | 188 | } |
179 | 189 | ||
180 | return @res; | 190 | return ($level, @res); |
181 | } | 191 | } |
182 | sub ctx_block_outer { | 192 | sub ctx_block_outer { |
183 | my ($linenr, $remain) = @_; | 193 | my ($linenr, $remain) = @_; |
184 | 194 | ||
185 | return ctx_block_get($linenr, $remain, 1, '\{', '\}'); | 195 | my ($level, @r) = ctx_block_get($linenr, $remain, 1, '{', '}', 0); |
196 | return @r; | ||
186 | } | 197 | } |
187 | sub ctx_block { | 198 | sub ctx_block { |
188 | my ($linenr, $remain) = @_; | 199 | my ($linenr, $remain) = @_; |
189 | 200 | ||
190 | return ctx_block_get($linenr, $remain, 0, '\{', '\}'); | 201 | my ($level, @r) = ctx_block_get($linenr, $remain, 0, '{', '}', 0); |
202 | return @r; | ||
191 | } | 203 | } |
192 | sub ctx_statement { | 204 | sub ctx_statement { |
205 | my ($linenr, $remain, $off) = @_; | ||
206 | |||
207 | my ($level, @r) = ctx_block_get($linenr, $remain, 0, '(', ')', $off); | ||
208 | return @r; | ||
209 | } | ||
210 | sub ctx_block_level { | ||
193 | my ($linenr, $remain) = @_; | 211 | my ($linenr, $remain) = @_; |
194 | 212 | ||
195 | return ctx_block_get($linenr, $remain, 0, '\(', '\)'); | 213 | return ctx_block_get($linenr, $remain, 0, '{', '}', 0); |
196 | } | 214 | } |
197 | 215 | ||
198 | sub ctx_locate_comment { | 216 | sub ctx_locate_comment { |
@@ -246,6 +264,26 @@ sub cat_vet { | |||
246 | return $vet; | 264 | return $vet; |
247 | } | 265 | } |
248 | 266 | ||
267 | my @report = (); | ||
268 | sub report { | ||
269 | push(@report, $_[0]); | ||
270 | } | ||
271 | sub report_dump { | ||
272 | @report; | ||
273 | } | ||
274 | sub ERROR { | ||
275 | report("ERROR: $_[0]\n"); | ||
276 | our $clean = 0; | ||
277 | } | ||
278 | sub WARN { | ||
279 | report("WARNING: $_[0]\n"); | ||
280 | our $clean = 0; | ||
281 | } | ||
282 | sub CHK { | ||
283 | report("CHECK: $_[0]\n"); | ||
284 | our $clean = 0; | ||
285 | } | ||
286 | |||
249 | sub process { | 287 | sub process { |
250 | my $filename = shift; | 288 | my $filename = shift; |
251 | my @lines = @_; | 289 | my @lines = @_; |
@@ -259,7 +297,7 @@ sub process { | |||
259 | my $previndent=0; | 297 | my $previndent=0; |
260 | my $stashindent=0; | 298 | my $stashindent=0; |
261 | 299 | ||
262 | my $clean = 1; | 300 | our $clean = 1; |
263 | my $signoff = 0; | 301 | my $signoff = 0; |
264 | my $is_patch = 0; | 302 | my $is_patch = 0; |
265 | 303 | ||
@@ -290,8 +328,11 @@ sub process { | |||
290 | long\s+int| | 328 | long\s+int| |
291 | long\s+long| | 329 | long\s+long| |
292 | long\s+long\s+int| | 330 | long\s+long\s+int| |
331 | u8|u16|u32|u64| | ||
332 | s8|s16|s32|s64| | ||
293 | struct\s+$Ident| | 333 | struct\s+$Ident| |
294 | union\s+$Ident| | 334 | union\s+$Ident| |
335 | enum\s+$Ident| | ||
295 | ${Ident}_t | 336 | ${Ident}_t |
296 | ) | 337 | ) |
297 | (?:\s+$Sparse)* | 338 | (?:\s+$Sparse)* |
@@ -302,7 +343,27 @@ sub process { | |||
302 | (?:\s*\*+\s*const|\s*\*+)? | 343 | (?:\s*\*+\s*const|\s*\*+)? |
303 | }x; | 344 | }x; |
304 | my $Declare = qr{(?:$Storage\s+)?$Type}; | 345 | my $Declare = qr{(?:$Storage\s+)?$Type}; |
305 | my $Attribute = qr{__read_mostly|__init|__initdata}; | 346 | my $Attribute = qr{const|__read_mostly|__init|__initdata|__meminit}; |
347 | |||
348 | my $Member = qr{->$Ident|\.$Ident|\[[^]]*\]}; | ||
349 | my $Lval = qr{$Ident(?:$Member)*}; | ||
350 | |||
351 | # Pre-scan the patch looking for any __setup documentation. | ||
352 | my @setup_docs = (); | ||
353 | my $setup_docs = 0; | ||
354 | foreach my $line (@lines) { | ||
355 | if ($line=~/^\+\+\+\s+(\S+)/) { | ||
356 | $setup_docs = 0; | ||
357 | if ($1 =~ m@Documentation/kernel-parameters.txt$@) { | ||
358 | $setup_docs = 1; | ||
359 | } | ||
360 | next; | ||
361 | } | ||
362 | |||
363 | if ($setup_docs && $line =~ /^\+/) { | ||
364 | push(@setup_docs, $line); | ||
365 | } | ||
366 | } | ||
306 | 367 | ||
307 | foreach my $line (@lines) { | 368 | foreach my $line (@lines) { |
308 | $linenr++; | 369 | $linenr++; |
@@ -369,30 +430,42 @@ sub process { | |||
369 | $here .= "FILE: $realfile:$realline:" if ($realcnt != 0); | 430 | $here .= "FILE: $realfile:$realline:" if ($realcnt != 0); |
370 | 431 | ||
371 | my $hereline = "$here\n$line\n"; | 432 | my $hereline = "$here\n$line\n"; |
372 | my $herecurr = "$here\n$line\n\n"; | 433 | my $herecurr = "$here\n$line\n"; |
373 | my $hereprev = "$here\n$prevline\n$line\n\n"; | 434 | my $hereprev = "$here\n$prevline\n$line\n"; |
374 | 435 | ||
375 | #check the patch for a signoff: | 436 | #check the patch for a signoff: |
376 | if ($line =~ /^\s*signed-off-by:/i) { | 437 | if ($line =~ /^\s*signed-off-by:/i) { |
377 | # This is a signoff, if ugly, so do not double report. | 438 | # This is a signoff, if ugly, so do not double report. |
378 | $signoff++; | 439 | $signoff++; |
379 | if (!($line =~ /^\s*Signed-off-by:/)) { | 440 | if (!($line =~ /^\s*Signed-off-by:/)) { |
380 | print "Signed-off-by: is the preferred form\n"; | 441 | WARN("Signed-off-by: is the preferred form\n" . |
381 | print "$herecurr"; | 442 | $herecurr); |
382 | $clean = 0; | ||
383 | } | 443 | } |
384 | if ($line =~ /^\s*signed-off-by:\S/i) { | 444 | if ($line =~ /^\s*signed-off-by:\S/i) { |
385 | print "need space after Signed-off-by:\n"; | 445 | WARN("need space after Signed-off-by:\n" . |
386 | print "$herecurr"; | 446 | $herecurr); |
387 | $clean = 0; | ||
388 | } | 447 | } |
389 | } | 448 | } |
390 | 449 | ||
391 | # Check for wrappage within a valid hunk of the file | 450 | # Check for wrappage within a valid hunk of the file |
392 | if ($realcnt != 0 && $line !~ m{^(?:\+|-| |$)}) { | 451 | if ($realcnt != 0 && $line !~ m{^(?:\+|-| |$)}) { |
393 | print "patch seems to be corrupt (line wrapped?) [$realcnt]\n"; | 452 | ERROR("patch seems to be corrupt (line wrapped?)\n" . |
394 | print "$herecurr"; | 453 | $herecurr); |
395 | $clean = 0; | 454 | } |
455 | |||
456 | # UTF-8 regex found at http://www.w3.org/International/questions/qa-forms-utf-8.en.php | ||
457 | if (($realfile =~ /^$/ || $line =~ /^\+/) && | ||
458 | !($line =~ m/^( | ||
459 | [\x09\x0A\x0D\x20-\x7E] # ASCII | ||
460 | | [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte | ||
461 | | \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs | ||
462 | | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte | ||
463 | | \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates | ||
464 | | \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3 | ||
465 | | [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15 | ||
466 | | \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16 | ||
467 | )*$/x )) { | ||
468 | ERROR("Invalid UTF-8\n" . $herecurr); | ||
396 | } | 469 | } |
397 | 470 | ||
398 | #ignore lines being removed | 471 | #ignore lines being removed |
@@ -403,16 +476,12 @@ sub process { | |||
403 | 476 | ||
404 | #trailing whitespace | 477 | #trailing whitespace |
405 | if ($line =~ /^\+.*\S\s+$/ || $line =~ /^\+\s+$/) { | 478 | if ($line =~ /^\+.*\S\s+$/ || $line =~ /^\+\s+$/) { |
406 | my $herevet = "$here\n" . cat_vet($line) . "\n\n"; | 479 | my $herevet = "$here\n" . cat_vet($line) . "\n"; |
407 | print "trailing whitespace\n"; | 480 | ERROR("trailing whitespace\n" . $herevet); |
408 | print "$herevet"; | ||
409 | $clean = 0; | ||
410 | } | 481 | } |
411 | #80 column limit | 482 | #80 column limit |
412 | if ($line =~ /^\+/ && !($prevline=~/\/\*\*/) && $length > 80) { | 483 | if ($line =~ /^\+/ && !($prevline=~/\/\*\*/) && $length > 80) { |
413 | print "line over 80 characters\n"; | 484 | WARN("line over 80 characters\n" . $herecurr); |
414 | print "$herecurr"; | ||
415 | $clean = 0; | ||
416 | } | 485 | } |
417 | 486 | ||
418 | # check we are in a valid source file *.[hc] if not then ignore this hunk | 487 | # check we are in a valid source file *.[hc] if not then ignore this hunk |
@@ -421,10 +490,8 @@ sub process { | |||
421 | # at the beginning of a line any tabs must come first and anything | 490 | # at the beginning of a line any tabs must come first and anything |
422 | # more than 8 must use tabs. | 491 | # more than 8 must use tabs. |
423 | if ($line=~/^\+\s* \t\s*\S/ or $line=~/^\+\s* \s*/) { | 492 | if ($line=~/^\+\s* \t\s*\S/ or $line=~/^\+\s* \s*/) { |
424 | my $herevet = "$here\n" . cat_vet($line) . "\n\n"; | 493 | my $herevet = "$here\n" . cat_vet($line) . "\n"; |
425 | print "use tabs not spaces\n"; | 494 | ERROR("use tabs not spaces\n" . $herevet); |
426 | print "$herevet"; | ||
427 | $clean = 0; | ||
428 | } | 495 | } |
429 | 496 | ||
430 | # | 497 | # |
@@ -463,9 +530,27 @@ sub process { | |||
463 | } | 530 | } |
464 | } | 531 | } |
465 | if ($err ne '') { | 532 | if ($err ne '') { |
466 | print "switch and case should be at the same indent\n"; | 533 | ERROR("switch and case should be at the same indent\n$hereline\n$err\n"); |
467 | print "$here\n$line\n$err\n"; | 534 | } |
468 | $clean = 0; | 535 | } |
536 | |||
537 | # if/while/etc brace do not go on next line, unless defining a do while loop, | ||
538 | # or if that brace on the next line is for something else | ||
539 | if ($line =~ /\b(?:(if|while|for|switch)\s*\(|do\b|else\b)/ && $line !~ /^.#/) { | ||
540 | my @ctx = ctx_statement($linenr, $realcnt, 0); | ||
541 | my $ctx_ln = $linenr + $#ctx + 1; | ||
542 | my $ctx_cnt = $realcnt - $#ctx - 1; | ||
543 | my $ctx = join("\n", @ctx); | ||
544 | |||
545 | while ($ctx_cnt > 0 && $lines[$ctx_ln - 1] =~ /^-/) { | ||
546 | $ctx_ln++; | ||
547 | $ctx_cnt--; | ||
548 | } | ||
549 | ##warn "line<$line>\nctx<$ctx>\nnext<$lines[$ctx_ln - 1]>"; | ||
550 | |||
551 | if ($ctx !~ /{\s*/ && $ctx_cnt > 0 && $lines[$ctx_ln - 1] =~ /^\+\s*{/) { | ||
552 | ERROR("That open brace { should be on the previous line\n" . | ||
553 | "$here\n$ctx\n$lines[$ctx_ln - 1]"); | ||
469 | } | 554 | } |
470 | } | 555 | } |
471 | 556 | ||
@@ -474,12 +559,16 @@ sub process { | |||
474 | 559 | ||
475 | # TEST: allow direct testing of the type matcher. | 560 | # TEST: allow direct testing of the type matcher. |
476 | if ($tst_type && $line =~ /^.$Declare$/) { | 561 | if ($tst_type && $line =~ /^.$Declare$/) { |
477 | print "TEST: is type $Declare\n"; | 562 | ERROR("TEST: is type $Declare\n" . $herecurr); |
478 | print "$herecurr"; | ||
479 | $clean = 0; | ||
480 | next; | 563 | next; |
481 | } | 564 | } |
482 | 565 | ||
566 | # check for initialisation to aggregates open brace on the next line | ||
567 | if ($prevline =~ /$Declare\s*$Ident\s*=\s*$/ && | ||
568 | $line =~ /^.\s*{/) { | ||
569 | ERROR("That open brace { should be on the previous line\n" . $hereprev); | ||
570 | } | ||
571 | |||
483 | # | 572 | # |
484 | # Checks which are anchored on the added line. | 573 | # Checks which are anchored on the added line. |
485 | # | 574 | # |
@@ -488,9 +577,8 @@ sub process { | |||
488 | if ($rawline =~ m{^.#\s*include\s+[<"](.*)[">]}) { | 577 | if ($rawline =~ m{^.#\s*include\s+[<"](.*)[">]}) { |
489 | my $path = $1; | 578 | my $path = $1; |
490 | if ($path =~ m{//}) { | 579 | if ($path =~ m{//}) { |
491 | print "malformed #include filename\n"; | 580 | ERROR("malformed #include filename\n" . |
492 | print "$herecurr"; | 581 | $herecurr); |
493 | $clean = 0; | ||
494 | } | 582 | } |
495 | # Sanitise this special form of string. | 583 | # Sanitise this special form of string. |
496 | $path = 'X' x length($path); | 584 | $path = 'X' x length($path); |
@@ -499,9 +587,7 @@ sub process { | |||
499 | 587 | ||
500 | # no C99 // comments | 588 | # no C99 // comments |
501 | if ($line =~ m{//}) { | 589 | if ($line =~ m{//}) { |
502 | print "do not use C99 // comments\n"; | 590 | ERROR("do not use C99 // comments\n" . $herecurr); |
503 | print "$herecurr"; | ||
504 | $clean = 0; | ||
505 | } | 591 | } |
506 | # Remove C99 comments. | 592 | # Remove C99 comments. |
507 | $line =~ s@//.*@@; | 593 | $line =~ s@//.*@@; |
@@ -514,49 +600,45 @@ sub process { | |||
514 | ($prevline !~ /^\+}/) && | 600 | ($prevline !~ /^\+}/) && |
515 | ($prevline !~ /^ }/) && | 601 | ($prevline !~ /^ }/) && |
516 | ($prevline !~ /\s$name(?:\s+$Attribute)?\s*(?:;|=)/)) { | 602 | ($prevline !~ /\s$name(?:\s+$Attribute)?\s*(?:;|=)/)) { |
517 | print "EXPORT_SYMBOL(foo); should immediately follow its function/variable\n"; | 603 | WARN("EXPORT_SYMBOL(foo); should immediately follow its function/variable\n" . $herecurr); |
518 | print "$herecurr"; | ||
519 | $clean = 0; | ||
520 | } | 604 | } |
521 | } | 605 | } |
522 | 606 | ||
607 | # check for external initialisers. | ||
608 | if ($line =~ /^.$Type\s*$Ident\s*=\s*(0|NULL);/) { | ||
609 | ERROR("do not initialise externals to 0 or NULL\n" . | ||
610 | $herecurr); | ||
611 | } | ||
523 | # check for static initialisers. | 612 | # check for static initialisers. |
524 | if ($line=~/\s*static\s.*=\s+(0|NULL);/) { | 613 | if ($line =~ /\s*static\s.*=\s*(0|NULL);/) { |
525 | print "do not initialise statics to 0 or NULL\n"; | 614 | ERROR("do not initialise statics to 0 or NULL\n" . |
526 | print "$herecurr"; | 615 | $herecurr); |
527 | $clean = 0; | ||
528 | } | 616 | } |
529 | 617 | ||
530 | # check for new typedefs, only function parameters and sparse annotations | 618 | # check for new typedefs, only function parameters and sparse annotations |
531 | # make sense. | 619 | # make sense. |
532 | if ($line =~ /\btypedef\s/ && | 620 | if ($line =~ /\btypedef\s/ && |
533 | $line !~ /\btypedef\s+$Type\s+\(\s*$Ident\s*\)\s*\(/ && | 621 | $line !~ /\btypedef\s+$Type\s+\(\s*\*$Ident\s*\)\s*\(/ && |
534 | $line !~ /\b__bitwise(?:__|)\b/) { | 622 | $line !~ /\b__bitwise(?:__|)\b/) { |
535 | print "do not add new typedefs\n"; | 623 | WARN("do not add new typedefs\n" . $herecurr); |
536 | print "$herecurr"; | ||
537 | $clean = 0; | ||
538 | } | 624 | } |
539 | 625 | ||
540 | # * goes on variable not on type | 626 | # * goes on variable not on type |
541 | if ($line =~ m{\($NonptrType(\*+)(?:\s+const)?\)}) { | 627 | if ($line =~ m{\($NonptrType(\*+)(?:\s+const)?\)}) { |
542 | print "\"(foo$1)\" should be \"(foo $1)\"\n"; | 628 | ERROR("\"(foo$1)\" should be \"(foo $1)\"\n" . |
543 | print "$herecurr"; | 629 | $herecurr); |
544 | $clean = 0; | ||
545 | 630 | ||
546 | } elsif ($line =~ m{\($NonptrType\s+(\*+)(?!\s+const)\s+\)}) { | 631 | } elsif ($line =~ m{\($NonptrType\s+(\*+)(?!\s+const)\s+\)}) { |
547 | print "\"(foo $1 )\" should be \"(foo $1)\"\n"; | 632 | ERROR("\"(foo $1 )\" should be \"(foo $1)\"\n" . |
548 | print "$herecurr"; | 633 | $herecurr); |
549 | $clean = 0; | ||
550 | 634 | ||
551 | } elsif ($line =~ m{$NonptrType(\*+)(?:\s+const)?\s+[A-Za-z\d_]+}) { | 635 | } elsif ($line =~ m{$NonptrType(\*+)(?:\s+$Attribute)?\s+[A-Za-z\d_]+}) { |
552 | print "\"foo$1 bar\" should be \"foo $1bar\"\n"; | 636 | ERROR("\"foo$1 bar\" should be \"foo $1bar\"\n" . |
553 | print "$herecurr"; | 637 | $herecurr); |
554 | $clean = 0; | ||
555 | 638 | ||
556 | } elsif ($line =~ m{$NonptrType\s+(\*+)(?!\s+const)\s+[A-Za-z\d_]+}) { | 639 | } elsif ($line =~ m{$NonptrType\s+(\*+)(?!\s+$Attribute)\s+[A-Za-z\d_]+}) { |
557 | print "\"foo $1 bar\" should be \"foo $1bar\"\n"; | 640 | ERROR("\"foo $1 bar\" should be \"foo $1bar\"\n" . |
558 | print "$herecurr"; | 641 | $herecurr); |
559 | $clean = 0; | ||
560 | } | 642 | } |
561 | 643 | ||
562 | # # no BUG() or BUG_ON() | 644 | # # no BUG() or BUG_ON() |
@@ -571,7 +653,7 @@ sub process { | |||
571 | # to try and find and validate the current printk. In summary the current | 653 | # to try and find and validate the current printk. In summary the current |
572 | # printk includes all preceeding printk's which have no newline on the end. | 654 | # printk includes all preceeding printk's which have no newline on the end. |
573 | # we assume the first bad printk is the one to report. | 655 | # we assume the first bad printk is the one to report. |
574 | if ($line =~ /\bprintk\((?!KERN_)/) { | 656 | if ($line =~ /\bprintk\((?!KERN_)\s*"/) { |
575 | my $ok = 0; | 657 | my $ok = 0; |
576 | for (my $ln = $linenr - 1; $ln >= $first_line; $ln--) { | 658 | for (my $ln = $linenr - 1; $ln >= $first_line; $ln--) { |
577 | #print "CHECK<$lines[$ln - 1]\n"; | 659 | #print "CHECK<$lines[$ln - 1]\n"; |
@@ -585,9 +667,7 @@ sub process { | |||
585 | } | 667 | } |
586 | } | 668 | } |
587 | if ($ok == 0) { | 669 | if ($ok == 0) { |
588 | print "printk() should include KERN_ facility level\n"; | 670 | WARN("printk() should include KERN_ facility level\n" . $herecurr); |
589 | print "$herecurr"; | ||
590 | $clean = 0; | ||
591 | } | 671 | } |
592 | } | 672 | } |
593 | 673 | ||
@@ -595,11 +675,15 @@ sub process { | |||
595 | # or if closed on same line | 675 | # or if closed on same line |
596 | if (($line=~/$Type\s*[A-Za-z\d_]+\(.*\).* {/) and | 676 | if (($line=~/$Type\s*[A-Za-z\d_]+\(.*\).* {/) and |
597 | !($line=~/\#define.*do\s{/) and !($line=~/}/)) { | 677 | !($line=~/\#define.*do\s{/) and !($line=~/}/)) { |
598 | print "braces following function declarations go on the next line\n"; | 678 | ERROR("open brace '{' following function declarations go on the next line\n" . $herecurr); |
599 | print "$herecurr"; | ||
600 | $clean = 0; | ||
601 | } | 679 | } |
602 | 680 | ||
681 | # check for spaces between functions and their parentheses. | ||
682 | if ($line =~ /($Ident)\s+\(/ && | ||
683 | $1 !~ /^(?:if|for|while|switch|return|volatile)$/ && | ||
684 | $line !~ /$Type\s+\(/ && $line !~ /^.\#\s*define\b/) { | ||
685 | ERROR("no space between function name and open parenthesis '('\n" . $herecurr); | ||
686 | } | ||
603 | # Check operator spacing. | 687 | # Check operator spacing. |
604 | # Note we expand the line with the leading + as the real | 688 | # Note we expand the line with the leading + as the real |
605 | # line will be displayed with the leading + and the tabs | 689 | # line will be displayed with the leading + and the tabs |
@@ -608,7 +692,7 @@ sub process { | |||
608 | $opline = expand_tabs($opline); | 692 | $opline = expand_tabs($opline); |
609 | $opline =~ s/^./ /; | 693 | $opline =~ s/^./ /; |
610 | if (!($line=~/\#\s*include/)) { | 694 | if (!($line=~/\#\s*include/)) { |
611 | my @elements = split(/(<<=|>>=|<=|>=|==|!=|\+=|-=|\*=|\/=|%=|\^=|\|=|&=|->|<<|>>|<|>|=|!|~|&&|\|\||,|\^|\+\+|--|;|&|\||\+|-|\*|\/\/|\/)/, $opline); | 695 | my @elements = split(/(<<=|>>=|<=|>=|==|!=|\+=|-=|\*=|\/=|%=|\^=|\|=|&=|=>|->|<<|>>|<|>|=|!|~|&&|\|\||,|\^|\+\+|--|;|&|\||\+|-|\*|\/\/|\/)/, $opline); |
612 | my $off = 0; | 696 | my $off = 0; |
613 | for (my $n = 0; $n < $#elements; $n += 2) { | 697 | for (my $n = 0; $n < $#elements; $n += 2) { |
614 | $off += length($elements[$n]); | 698 | $off += length($elements[$n]); |
@@ -633,27 +717,27 @@ sub process { | |||
633 | } | 717 | } |
634 | 718 | ||
635 | # Pick up the preceeding and succeeding characters. | 719 | # Pick up the preceeding and succeeding characters. |
636 | my $ca = substr($opline, $off - 1, 1); | 720 | my $ca = substr($opline, 0, $off); |
637 | my $cc = ''; | 721 | my $cc = ''; |
638 | if (length($opline) >= ($off + length($elements[$n + 1]))) { | 722 | if (length($opline) >= ($off + length($elements[$n + 1]))) { |
639 | $cc = substr($opline, $off + length($elements[$n + 1])); | 723 | $cc = substr($opline, $off + length($elements[$n + 1])); |
640 | } | 724 | } |
725 | my $cb = "$ca$;$cc"; | ||
641 | 726 | ||
642 | my $ctx = "${a}x${c}"; | 727 | my $ctx = "${a}x${c}"; |
643 | 728 | ||
644 | my $at = "(ctx:$ctx)"; | 729 | my $at = "(ctx:$ctx)"; |
645 | 730 | ||
646 | my $ptr = (" " x $off) . "^"; | 731 | my $ptr = (" " x $off) . "^"; |
647 | my $hereptr = "$hereline$ptr\n\n"; | 732 | my $hereptr = "$hereline$ptr\n"; |
648 | 733 | ||
649 | ##print "<$s1:$op:$s2> <$elements[$n]:$elements[$n + 1]:$elements[$n + 2]>\n"; | 734 | ##print "<$s1:$op:$s2> <$elements[$n]:$elements[$n + 1]:$elements[$n + 2]>\n"; |
650 | 735 | ||
651 | # ; should have either the end of line or a space or \ after it | 736 | # ; should have either the end of line or a space or \ after it |
652 | if ($op eq ';') { | 737 | if ($op eq ';') { |
653 | if ($ctx !~ /.x[WE]/ && $cc !~ /^\\/) { | 738 | if ($ctx !~ /.x[WEB]/ && $cc !~ /^\\/ && |
654 | print "need space after that '$op' $at\n"; | 739 | $cc !~ /^;/) { |
655 | print "$hereptr"; | 740 | ERROR("need space after that '$op' $at\n" . $hereptr); |
656 | $clean = 0; | ||
657 | } | 741 | } |
658 | 742 | ||
659 | # // is a comment | 743 | # // is a comment |
@@ -662,43 +746,31 @@ sub process { | |||
662 | # -> should have no spaces | 746 | # -> should have no spaces |
663 | } elsif ($op eq '->') { | 747 | } elsif ($op eq '->') { |
664 | if ($ctx =~ /Wx.|.xW/) { | 748 | if ($ctx =~ /Wx.|.xW/) { |
665 | print "no spaces around that '$op' $at\n"; | 749 | ERROR("no spaces around that '$op' $at\n" . $hereptr); |
666 | print "$hereptr"; | ||
667 | $clean = 0; | ||
668 | } | 750 | } |
669 | 751 | ||
670 | # , must have a space on the right. | 752 | # , must have a space on the right. |
671 | } elsif ($op eq ',') { | 753 | } elsif ($op eq ',') { |
672 | if ($ctx !~ /.xW|.xE/ && $cc !~ /^}/) { | 754 | if ($ctx !~ /.xW|.xE/ && $cc !~ /^}/) { |
673 | print "need space after that '$op' $at\n"; | 755 | ERROR("need space after that '$op' $at\n" . $hereptr); |
674 | print "$hereptr"; | ||
675 | $clean = 0; | ||
676 | } | 756 | } |
677 | 757 | ||
678 | # unary ! and unary ~ are allowed no space on the right | 758 | # unary ! and unary ~ are allowed no space on the right |
679 | } elsif ($op eq '!' or $op eq '~') { | 759 | } elsif ($op eq '!' or $op eq '~') { |
680 | if ($ctx !~ /[WOEB]x./) { | 760 | if ($ctx !~ /[WOEB]x./) { |
681 | print "need space before that '$op' $at\n"; | 761 | ERROR("need space before that '$op' $at\n" . $hereptr); |
682 | print "$hereptr"; | ||
683 | $clean = 0; | ||
684 | } | 762 | } |
685 | if ($ctx =~ /.xW/) { | 763 | if ($ctx =~ /.xW/) { |
686 | print "no space after that '$op' $at\n"; | 764 | ERROR("no space after that '$op' $at\n" . $hereptr); |
687 | print "$hereptr"; | ||
688 | $clean = 0; | ||
689 | } | 765 | } |
690 | 766 | ||
691 | # unary ++ and unary -- are allowed no space on one side. | 767 | # unary ++ and unary -- are allowed no space on one side. |
692 | } elsif ($op eq '++' or $op eq '--') { | 768 | } elsif ($op eq '++' or $op eq '--') { |
693 | if ($ctx !~ /[WOB]x[^W]/ && $ctx !~ /[^W]x[WOBE]/) { | 769 | if ($ctx !~ /[WOB]x[^W]/ && $ctx !~ /[^W]x[WOBE]/) { |
694 | print "need space one side of that '$op' $at\n"; | 770 | ERROR("need space one side of that '$op' $at\n" . $hereptr); |
695 | print "$hereptr"; | ||
696 | $clean = 0; | ||
697 | } | 771 | } |
698 | if ($ctx =~ /Wx./ && $cc =~ /^;/) { | 772 | if ($ctx =~ /Wx./ && $cc =~ /^;/) { |
699 | print "no space before that '$op' $at\n"; | 773 | ERROR("no space before that '$op' $at\n" . $hereptr); |
700 | print "$hereptr"; | ||
701 | $clean = 0; | ||
702 | } | 774 | } |
703 | 775 | ||
704 | # & is both unary and binary | 776 | # & is both unary and binary |
@@ -715,9 +787,7 @@ sub process { | |||
715 | # | 787 | # |
716 | } elsif ($op eq '&' or $op eq '-') { | 788 | } elsif ($op eq '&' or $op eq '-') { |
717 | if ($ctx !~ /VxV|[EW]x[WE]|[EWB]x[VO]/) { | 789 | if ($ctx !~ /VxV|[EW]x[WE]|[EWB]x[VO]/) { |
718 | print "need space before that '$op' $at\n"; | 790 | ERROR("need space before that '$op' $at\n" . $hereptr); |
719 | print "$hereptr"; | ||
720 | $clean = 0; | ||
721 | } | 791 | } |
722 | 792 | ||
723 | # * is the same as & only adding: | 793 | # * is the same as & only adding: |
@@ -726,16 +796,9 @@ sub process { | |||
726 | # (foo **) | 796 | # (foo **) |
727 | # | 797 | # |
728 | } elsif ($op eq '*') { | 798 | } elsif ($op eq '*') { |
729 | if ($ca eq '*') { | 799 | if ($ca !~ /$Type$/ && $cb !~ /(\*$;|$;\*)/ && |
730 | if ($cc =~ /^\s(?!\s*const)/) { | 800 | $ctx !~ /VxV|[EW]x[WE]|[EWB]x[VO]|OxV|WxB|BxB/) { |
731 | print "no space after that '$op' $at\n"; | 801 | ERROR("need space before that '$op' $at\n" . $hereptr); |
732 | print "$hereptr"; | ||
733 | $clean = 0; | ||
734 | } | ||
735 | } elsif ($ctx !~ /VxV|[EW]x[WE]|[EWB]x[VO]|OxV|WxB|BxB/) { | ||
736 | print "need space before that '$op' $at\n"; | ||
737 | print "$hereptr"; | ||
738 | $clean = 0; | ||
739 | } | 802 | } |
740 | 803 | ||
741 | # << and >> may either have or not have spaces both sides | 804 | # << and >> may either have or not have spaces both sides |
@@ -743,58 +806,63 @@ sub process { | |||
743 | $op eq '^' or $op eq '|') | 806 | $op eq '^' or $op eq '|') |
744 | { | 807 | { |
745 | if ($ctx !~ /VxV|WxW|VxE|WxE/) { | 808 | if ($ctx !~ /VxV|WxW|VxE|WxE/) { |
746 | print "need consistent spacing around '$op' $at\n"; | 809 | ERROR("need consistent spacing around '$op' $at\n" . |
747 | print "$hereptr"; | 810 | $hereptr); |
748 | $clean = 0; | ||
749 | } | 811 | } |
750 | 812 | ||
751 | # All the others need spaces both sides. | 813 | # All the others need spaces both sides. |
752 | } elsif ($ctx !~ /[EW]x[WE]/) { | 814 | } elsif ($ctx !~ /[EW]x[WE]/) { |
753 | print "need spaces around that '$op' $at\n"; | 815 | ERROR("need spaces around that '$op' $at\n" . $hereptr); |
754 | print "$hereptr"; | ||
755 | $clean = 0; | ||
756 | } | 816 | } |
757 | $off += length($elements[$n + 1]); | 817 | $off += length($elements[$n + 1]); |
758 | } | 818 | } |
759 | } | 819 | } |
760 | 820 | ||
821 | # check for multiple assignments | ||
822 | if ($line =~ /^.\s*$Lval\s*=\s*$Lval\s*=(?!=)/) { | ||
823 | WARN("multiple assignments should be avoided\n" . $herecurr); | ||
824 | } | ||
825 | |||
826 | # check for multiple declarations, allowing for a function declaration | ||
827 | # continuation. | ||
828 | if ($line =~ /^.\s*$Type\s+$Ident(?:\s*=[^,{]*)?\s*,\s*$Ident.*/ && | ||
829 | $line !~ /^.\s*$Type\s+$Ident(?:\s*=[^,{]*)?\s*,\s*$Type\s*$Ident.*/) { | ||
830 | WARN("declaring multiple variables together should be avoided\n" . $herecurr); | ||
831 | } | ||
832 | |||
761 | #need space before brace following if, while, etc | 833 | #need space before brace following if, while, etc |
762 | if ($line=~/\(.*\){/) { | 834 | if ($line =~ /\(.*\){/ || $line =~ /do{/) { |
763 | print "need a space before the brace\n"; | 835 | ERROR("need a space before the open brace '{'\n" . $herecurr); |
764 | print "$herecurr"; | 836 | } |
765 | $clean = 0; | 837 | |
838 | # closing brace should have a space following it when it has anything | ||
839 | # on the line | ||
840 | if ($line =~ /}(?!(?:,|;|\)))\S/) { | ||
841 | ERROR("need a space after that close brace '}'\n" . $herecurr); | ||
766 | } | 842 | } |
767 | 843 | ||
768 | #goto labels aren't indented, allow a single space however | 844 | #goto labels aren't indented, allow a single space however |
769 | if ($line=~/^.\s+[A-Za-z\d_]+:(?![0-9]+)/ and | 845 | if ($line=~/^.\s+[A-Za-z\d_]+:(?![0-9]+)/ and |
770 | !($line=~/^. [A-Za-z\d_]+:/) and !($line=~/^.\s+default:/)) { | 846 | !($line=~/^. [A-Za-z\d_]+:/) and !($line=~/^.\s+default:/)) { |
771 | print "labels should not be indented\n"; | 847 | WARN("labels should not be indented\n" . $herecurr); |
772 | print "$herecurr"; | ||
773 | $clean = 0; | ||
774 | } | 848 | } |
775 | 849 | ||
776 | # Need a space before open parenthesis after if, while etc | 850 | # Need a space before open parenthesis after if, while etc |
777 | if ($line=~/\b(if|while|for|switch)\(/) { | 851 | if ($line=~/\b(if|while|for|switch)\(/) { |
778 | print "need a space before the open parenthesis\n"; | 852 | ERROR("need a space before the open parenthesis '('\n" . $herecurr); |
779 | print "$herecurr"; | ||
780 | $clean = 0; | ||
781 | } | 853 | } |
782 | 854 | ||
783 | # Check for illegal assignment in if conditional. | 855 | # Check for illegal assignment in if conditional. |
784 | if ($line=~/\bif\s*\(.*[^<>!=]=[^=].*\)/) { | 856 | if ($line=~/\bif\s*\(.*[^<>!=]=[^=].*\)/) { |
785 | #next if ($line=~/\".*\Q$op\E.*\"/ or $line=~/\'\Q$op\E\'/); | 857 | #next if ($line=~/\".*\Q$op\E.*\"/ or $line=~/\'\Q$op\E\'/); |
786 | print "do not use assignment in if condition\n"; | 858 | ERROR("do not use assignment in if condition\n" . $herecurr); |
787 | print "$herecurr"; | ||
788 | $clean = 0; | ||
789 | } | 859 | } |
790 | 860 | ||
791 | # Check for }<nl>else {, these must be at the same | 861 | # Check for }<nl>else {, these must be at the same |
792 | # indent level to be relevant to each other. | 862 | # indent level to be relevant to each other. |
793 | if ($prevline=~/}\s*$/ and $line=~/^.\s*else\s*/ and | 863 | if ($prevline=~/}\s*$/ and $line=~/^.\s*else\s*/ and |
794 | $previndent == $indent) { | 864 | $previndent == $indent) { |
795 | print "else should follow close brace\n"; | 865 | ERROR("else should follow close brace '}'\n" . $hereprev); |
796 | print "$hereprev"; | ||
797 | $clean = 0; | ||
798 | } | 866 | } |
799 | 867 | ||
800 | #studly caps, commented out until figure out how to distinguish between use of existing and adding new | 868 | #studly caps, commented out until figure out how to distinguish between use of existing and adding new |
@@ -806,57 +874,22 @@ sub process { | |||
806 | 874 | ||
807 | #no spaces allowed after \ in define | 875 | #no spaces allowed after \ in define |
808 | if ($line=~/\#define.*\\\s$/) { | 876 | if ($line=~/\#define.*\\\s$/) { |
809 | print("Whitepspace after \\ makes next lines useless\n"); | 877 | WARN("Whitepspace after \\ makes next lines useless\n" . $herecurr); |
810 | print "$herecurr"; | ||
811 | $clean = 0; | ||
812 | } | 878 | } |
813 | 879 | ||
814 | #warn if <asm/foo.h> is #included and <linux/foo.h> is available (uses RAW line) | 880 | #warn if <asm/foo.h> is #included and <linux/foo.h> is available (uses RAW line) |
815 | if ($tree && $rawline =~ m{^.\#\s*include\s*\<asm\/(.*)\.h\>}) { | 881 | if ($tree && $rawline =~ m{^.\#\s*include\s*\<asm\/(.*)\.h\>}) { |
816 | my $checkfile = "include/linux/$1.h"; | 882 | my $checkfile = "include/linux/$1.h"; |
817 | if (-f $checkfile) { | 883 | if (-f $checkfile) { |
818 | print "Use #include <linux/$1.h> instead of <asm/$1.h>\n"; | 884 | CHK("Use #include <linux/$1.h> instead of <asm/$1.h>\n" . |
819 | print $herecurr; | 885 | $herecurr); |
820 | $clean = 0; | ||
821 | } | ||
822 | } | ||
823 | |||
824 | # if/while/etc brace do not go on next line, unless defining a do while loop, | ||
825 | # or if that brace on the next line is for something else | ||
826 | if ($prevline=~/\b(?:(if|while|for|switch)\s*\(|do\b|else\b)/) { | ||
827 | my @opened = $prevline=~/\(/g; | ||
828 | my @closed = $prevline=~/\)/g; | ||
829 | my $nr_line = $linenr; | ||
830 | my $remaining = $realcnt - 1; | ||
831 | my $next_line = $line; | ||
832 | my $extra_lines = 0; | ||
833 | my $display_segment = $prevline; | ||
834 | |||
835 | while ($remaining > 0 && scalar @opened > scalar @closed) { | ||
836 | $prevline .= $next_line; | ||
837 | $display_segment .= "\n" . $next_line; | ||
838 | $next_line = $lines[$nr_line]; | ||
839 | $nr_line++; | ||
840 | $remaining--; | ||
841 | |||
842 | @opened = $prevline=~/\(/g; | ||
843 | @closed = $prevline=~/\)/g; | ||
844 | } | ||
845 | |||
846 | if (($prevline=~/\b(?:(if|while|for|switch)\s*\(.*\)|do|else)\s*$/) and ($next_line=~/{/) and | ||
847 | !($next_line=~/\b(?:if|while|for|switch|do|else)\b/) and !($next_line=~/\#define.*do.*while/)) { | ||
848 | print "That { should be on the previous line\n"; | ||
849 | print "$here\n$display_segment\n$next_line\n\n"; | ||
850 | $clean = 0; | ||
851 | } | 886 | } |
852 | } | 887 | } |
853 | 888 | ||
854 | # if and else should not have general statements after it | 889 | # if and else should not have general statements after it |
855 | if ($line =~ /^.\s*(?:}\s*)?else\b(.*)/ && | 890 | if ($line =~ /^.\s*(?:}\s*)?else\b(.*)/ && |
856 | $1 !~ /^\s*(?:\sif|{|$)/) { | 891 | $1 !~ /^\s*(?:\sif|{|\\|$)/) { |
857 | print "trailing statements should be on next line\n"; | 892 | ERROR("trailing statements should be on next line\n" . $herecurr); |
858 | print "$herecurr"; | ||
859 | $clean = 0; | ||
860 | } | 893 | } |
861 | 894 | ||
862 | # multi-statement macros should be enclosed in a do while loop, grab the | 895 | # multi-statement macros should be enclosed in a do while loop, grab the |
@@ -871,55 +904,106 @@ sub process { | |||
871 | # or the one below. | 904 | # or the one below. |
872 | my $ln = $linenr; | 905 | my $ln = $linenr; |
873 | my $cnt = $realcnt; | 906 | my $cnt = $realcnt; |
907 | my $off = 0; | ||
874 | 908 | ||
875 | # If the macro starts on the define line start there. | 909 | # If the macro starts on the define line start |
876 | if ($prevline !~ m{^.#\s*define\s*$Ident(?:\([^\)]*\))?\s*\\\s*$}) { | 910 | # grabbing the statement after the identifier |
911 | $prevline =~ m{^(.#\s*define\s*$Ident(?:\([^\)]*\))?\s*)(.*)\\\s*$}; | ||
912 | ##print "1<$1> 2<$2>\n"; | ||
913 | if ($2 ne '') { | ||
914 | $off = length($1); | ||
877 | $ln--; | 915 | $ln--; |
878 | $cnt++; | 916 | $cnt++; |
879 | } | 917 | } |
880 | my $ctx = join('', ctx_statement($ln, $cnt)); | 918 | my @ctx = ctx_statement($ln, $cnt, $off); |
919 | my $ctx_ln = $ln + $#ctx + 1; | ||
920 | my $ctx = join("\n", @ctx); | ||
921 | |||
922 | # Pull in any empty extension lines. | ||
923 | while ($ctx =~ /\\$/ && | ||
924 | $lines[$ctx_ln - 1] =~ /^.\s*(?:\\)?$/) { | ||
925 | $ctx .= $lines[$ctx_ln - 1]; | ||
926 | $ctx_ln++; | ||
927 | } | ||
881 | 928 | ||
882 | if ($ctx =~ /\\$/) { | 929 | if ($ctx =~ /\\$/) { |
883 | if ($ctx =~ /;/) { | 930 | if ($ctx =~ /;/) { |
884 | print "Macros with multiple statements should be enclosed in a do - while loop\n"; | 931 | ERROR("Macros with multiple statements should be enclosed in a do - while loop\n" . "$here\n$ctx\n"); |
885 | } else { | 932 | } else { |
886 | print "Macros with complex values should be enclosed in parenthesis\n"; | 933 | ERROR("Macros with complex values should be enclosed in parenthesis\n" . "$here\n$ctx\n"); |
934 | } | ||
935 | } | ||
936 | } | ||
937 | |||
938 | # check for redundant bracing round if etc | ||
939 | if ($line =~ /\b(if|while|for|else)\b/) { | ||
940 | # Locate the end of the opening statement. | ||
941 | my @control = ctx_statement($linenr, $realcnt, 0); | ||
942 | my $nr = $linenr + (scalar(@control) - 1); | ||
943 | my $cnt = $realcnt - (scalar(@control) - 1); | ||
944 | |||
945 | my $off = $realcnt - $cnt; | ||
946 | #print "$off: line<$line>end<" . $lines[$nr - 1] . ">\n"; | ||
947 | |||
948 | # If this is is a braced statement group check it | ||
949 | if ($lines[$nr - 1] =~ /{\s*$/) { | ||
950 | my ($lvl, @block) = ctx_block_level($nr, $cnt); | ||
951 | |||
952 | my $stmt = join(' ', @block); | ||
953 | $stmt =~ s/^[^{]*{//; | ||
954 | $stmt =~ s/}[^}]*$//; | ||
955 | |||
956 | #print "block<" . join(' ', @block) . "><" . scalar(@block) . ">\n"; | ||
957 | #print "stmt<$stmt>\n\n"; | ||
958 | |||
959 | # Count the ;'s if there is fewer than two | ||
960 | # then there can only be one statement, | ||
961 | # if there is a brace inside we cannot | ||
962 | # trivially detect if its one statement. | ||
963 | # Also nested if's often require braces to | ||
964 | # disambiguate the else binding so shhh there. | ||
965 | my @semi = ($stmt =~ /;/g); | ||
966 | ##print "semi<" . scalar(@semi) . ">\n"; | ||
967 | if ($lvl == 0 && scalar(@semi) < 2 && | ||
968 | $stmt !~ /{/ && $stmt !~ /\bif\b/) { | ||
969 | my $herectx = "$here\n" . join("\n", @control, @block[1 .. $#block]) . "\n"; | ||
970 | shift(@block); | ||
971 | ERROR("braces {} are not necessary for single statement blocks\n" . $herectx); | ||
887 | } | 972 | } |
888 | print "$hereprev"; | ||
889 | $clean = 0; | ||
890 | } | 973 | } |
891 | } | 974 | } |
892 | 975 | ||
893 | # don't include deprecated include files (uses RAW line) | 976 | # don't include deprecated include files (uses RAW line) |
894 | for my $inc (@dep_includes) { | 977 | for my $inc (@dep_includes) { |
895 | if ($rawline =~ m@\#\s*include\s*\<$inc>@) { | 978 | if ($rawline =~ m@\#\s*include\s*\<$inc>@) { |
896 | print "Don't use <$inc>: see Documentation/feature-removal-schedule.txt\n"; | 979 | ERROR("Don't use <$inc>: see Documentation/feature-removal-schedule.txt\n" . $herecurr); |
897 | print "$herecurr"; | ||
898 | $clean = 0; | ||
899 | } | 980 | } |
900 | } | 981 | } |
901 | 982 | ||
902 | # don't use deprecated functions | 983 | # don't use deprecated functions |
903 | for my $func (@dep_functions) { | 984 | for my $func (@dep_functions) { |
904 | if ($line =~ /\b$func\b/) { | 985 | if ($line =~ /\b$func\b/) { |
905 | print "Don't use $func(): see Documentation/feature-removal-schedule.txt\n"; | 986 | ERROR("Don't use $func(): see Documentation/feature-removal-schedule.txt\n" . $herecurr); |
906 | print "$herecurr"; | ||
907 | $clean = 0; | ||
908 | } | 987 | } |
909 | } | 988 | } |
910 | 989 | ||
911 | # no volatiles please | 990 | # no volatiles please |
912 | if ($line =~ /\bvolatile\b/ && $line !~ /\basm\s+volatile\b/) { | 991 | if ($line =~ /\bvolatile\b/ && $line !~ /\basm\s+volatile\b/) { |
913 | print "Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt\n"; | 992 | WARN("Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt\n" . $herecurr); |
914 | print "$herecurr"; | ||
915 | $clean = 0; | ||
916 | } | 993 | } |
917 | 994 | ||
918 | # warn about #if 0 | 995 | # warn about #if 0 |
919 | if ($line =~ /^.#\s*if\s+0\b/) { | 996 | if ($line =~ /^.#\s*if\s+0\b/) { |
920 | print "#if 0 -- if this code redundant remove it\n"; | 997 | CHK("if this code is redundant consider removing it\n" . |
921 | print "$herecurr"; | 998 | $herecurr); |
922 | $clean = 0; | 999 | } |
1000 | |||
1001 | # check for needless kfree() checks | ||
1002 | if ($prevline =~ /\bif\s*\(([^\)]*)\)/) { | ||
1003 | my $expr = $1; | ||
1004 | if ($line =~ /\bkfree\(\Q$expr\E\);/) { | ||
1005 | WARN("kfree(NULL) is safe this check is probabally not required\n" . $hereprev); | ||
1006 | } | ||
923 | } | 1007 | } |
924 | 1008 | ||
925 | # warn about #ifdefs in C files | 1009 | # warn about #ifdefs in C files |
@@ -933,43 +1017,52 @@ sub process { | |||
933 | if ($line =~ /^.\s*(struct\s+mutex|spinlock_t)\s+\S+;/) { | 1017 | if ($line =~ /^.\s*(struct\s+mutex|spinlock_t)\s+\S+;/) { |
934 | my $which = $1; | 1018 | my $which = $1; |
935 | if (!ctx_has_comment($first_line, $linenr)) { | 1019 | if (!ctx_has_comment($first_line, $linenr)) { |
936 | print "$1 definition without comment\n"; | 1020 | CHK("$1 definition without comment\n" . $herecurr); |
937 | print "$herecurr"; | ||
938 | $clean = 0; | ||
939 | } | 1021 | } |
940 | } | 1022 | } |
941 | # check for memory barriers without a comment. | 1023 | # check for memory barriers without a comment. |
942 | if ($line =~ /\b(mb|rmb|wmb|read_barrier_depends|smp_mb|smp_rmb|smp_wmb|smp_read_barrier_depends)\(/) { | 1024 | if ($line =~ /\b(mb|rmb|wmb|read_barrier_depends|smp_mb|smp_rmb|smp_wmb|smp_read_barrier_depends)\(/) { |
943 | if (!ctx_has_comment($first_line, $linenr)) { | 1025 | if (!ctx_has_comment($first_line, $linenr)) { |
944 | print "memory barrier without comment\n"; | 1026 | CHK("memory barrier without comment\n" . $herecurr); |
945 | print "$herecurr"; | ||
946 | $clean = 0; | ||
947 | } | 1027 | } |
948 | } | 1028 | } |
949 | # check of hardware specific defines | 1029 | # check of hardware specific defines |
950 | if ($line =~ m@^.#\s*if.*\b(__i386__|__powerpc64__|__sun__|__s390x__)\b@) { | 1030 | if ($line =~ m@^.#\s*if.*\b(__i386__|__powerpc64__|__sun__|__s390x__)\b@) { |
951 | print "architecture specific defines should be avoided\n"; | 1031 | CHK("architecture specific defines should be avoided\n" . $herecurr); |
952 | print "$herecurr"; | ||
953 | $clean = 0; | ||
954 | } | 1032 | } |
955 | 1033 | ||
1034 | # check the location of the inline attribute, that it is between | ||
1035 | # storage class and type. | ||
956 | if ($line =~ /$Type\s+(?:inline|__always_inline)\b/ || | 1036 | if ($line =~ /$Type\s+(?:inline|__always_inline)\b/ || |
957 | $line =~ /\b(?:inline|always_inline)\s+$Storage/) { | 1037 | $line =~ /\b(?:inline|always_inline)\s+$Storage/) { |
958 | print "inline keyword should sit between storage class and type\n"; | 1038 | ERROR("inline keyword should sit between storage class and type\n" . $herecurr); |
959 | print "$herecurr"; | 1039 | } |
960 | $clean = 0; | 1040 | |
1041 | # check for new externs in .c files. | ||
1042 | if ($line =~ /^.\s*extern\s/ && ($realfile =~ /\.c$/)) { | ||
1043 | WARN("externs should be avoided in .c files\n" . $herecurr); | ||
1044 | } | ||
1045 | |||
1046 | # checks for new __setup's | ||
1047 | if ($rawline =~ /\b__setup\("([^"]*)"/) { | ||
1048 | my $name = $1; | ||
1049 | |||
1050 | if (!grep(/$name/, @setup_docs)) { | ||
1051 | CHK("__setup appears un-documented -- check Documentation/kernel-parameters.txt\n" . $herecurr); | ||
1052 | } | ||
961 | } | 1053 | } |
962 | } | 1054 | } |
963 | 1055 | ||
964 | if ($chk_patch && !$is_patch) { | 1056 | if ($chk_patch && !$is_patch) { |
965 | $clean = 0; | 1057 | ERROR("Does not appear to be a unified-diff format patch\n"); |
966 | print "Does not appear to be a unified-diff format patch\n"; | ||
967 | } | 1058 | } |
968 | if ($is_patch && $chk_signoff && $signoff == 0) { | 1059 | if ($is_patch && $chk_signoff && $signoff == 0) { |
969 | $clean = 0; | 1060 | ERROR("Missing Signed-off-by: line(s)\n"); |
970 | print "Missing Signed-off-by: line(s)\n"; | ||
971 | } | 1061 | } |
972 | 1062 | ||
1063 | if ($clean == 0 && ($chk_patch || $is_patch)) { | ||
1064 | print report_dump(); | ||
1065 | } | ||
973 | if ($clean == 1 && $quiet == 0) { | 1066 | if ($clean == 1 && $quiet == 0) { |
974 | print "Your patch has no obvious style problems and is ready for submission.\n" | 1067 | print "Your patch has no obvious style problems and is ready for submission.\n" |
975 | } | 1068 | } |
diff --git a/scripts/cleanfile b/scripts/cleanfile index f1ba8aa58a40..cefd29e52298 100755 --- a/scripts/cleanfile +++ b/scripts/cleanfile | |||
@@ -7,7 +7,9 @@ | |||
7 | use bytes; | 7 | use bytes; |
8 | use File::Basename; | 8 | use File::Basename; |
9 | 9 | ||
10 | # | 10 | # Default options |
11 | $max_width = 79; | ||
12 | |||
11 | # Clean up space-tab sequences, either by removing spaces or | 13 | # Clean up space-tab sequences, either by removing spaces or |
12 | # replacing them with tabs. | 14 | # replacing them with tabs. |
13 | sub clean_space_tabs($) | 15 | sub clean_space_tabs($) |
@@ -48,9 +50,49 @@ sub clean_space_tabs($) | |||
48 | return $lo; | 50 | return $lo; |
49 | } | 51 | } |
50 | 52 | ||
53 | # Compute the visual width of a string | ||
54 | sub strwidth($) { | ||
55 | no bytes; # Tab alignment depends on characters | ||
56 | |||
57 | my($li) = @_; | ||
58 | my($c, $i); | ||
59 | my $pos = 0; | ||
60 | my $mlen = 0; | ||
61 | |||
62 | for ($i = 0; $i < length($li); $i++) { | ||
63 | $c = substr($li,$i,1); | ||
64 | if ($c eq "\t") { | ||
65 | $pos = ($pos+8) & ~7; | ||
66 | } elsif ($c eq "\n") { | ||
67 | $mlen = $pos if ($pos > $mlen); | ||
68 | $pos = 0; | ||
69 | } else { | ||
70 | $pos++; | ||
71 | } | ||
72 | } | ||
73 | |||
74 | $mlen = $pos if ($pos > $mlen); | ||
75 | return $mlen; | ||
76 | } | ||
77 | |||
51 | $name = basename($0); | 78 | $name = basename($0); |
52 | 79 | ||
53 | foreach $f ( @ARGV ) { | 80 | @files = (); |
81 | |||
82 | while (defined($a = shift(@ARGV))) { | ||
83 | if ($a =~ /^-/) { | ||
84 | if ($a eq '-width' || $a eq '-w') { | ||
85 | $max_width = shift(@ARGV)+0; | ||
86 | } else { | ||
87 | print STDERR "Usage: $name [-width #] files...\n"; | ||
88 | exit 1; | ||
89 | } | ||
90 | } else { | ||
91 | push(@files, $a); | ||
92 | } | ||
93 | } | ||
94 | |||
95 | foreach $f ( @files ) { | ||
54 | print STDERR "$name: $f\n"; | 96 | print STDERR "$name: $f\n"; |
55 | 97 | ||
56 | if (! -f $f) { | 98 | if (! -f $f) { |
@@ -90,8 +132,10 @@ foreach $f ( @ARGV ) { | |||
90 | 132 | ||
91 | @blanks = (); | 133 | @blanks = (); |
92 | @lines = (); | 134 | @lines = (); |
135 | $lineno = 0; | ||
93 | 136 | ||
94 | while ( defined($line = <FILE>) ) { | 137 | while ( defined($line = <FILE>) ) { |
138 | $lineno++; | ||
95 | $in_bytes += length($line); | 139 | $in_bytes += length($line); |
96 | $line =~ s/[ \t\r]*$//; # Remove trailing spaces | 140 | $line =~ s/[ \t\r]*$//; # Remove trailing spaces |
97 | $line = clean_space_tabs($line); | 141 | $line = clean_space_tabs($line); |
@@ -107,6 +151,12 @@ foreach $f ( @ARGV ) { | |||
107 | @blanks = (); | 151 | @blanks = (); |
108 | $blank_bytes = 0; | 152 | $blank_bytes = 0; |
109 | } | 153 | } |
154 | |||
155 | $l_width = strwidth($line); | ||
156 | if ($max_width && $l_width > $max_width) { | ||
157 | print STDERR | ||
158 | "$f:$lineno: line exceeds $max_width characters ($l_width)\n"; | ||
159 | } | ||
110 | } | 160 | } |
111 | 161 | ||
112 | # Any blanks at the end of the file are discarded | 162 | # Any blanks at the end of the file are discarded |
diff --git a/scripts/cleanpatch b/scripts/cleanpatch index a53f987708f5..9680d03ad2b8 100755 --- a/scripts/cleanpatch +++ b/scripts/cleanpatch | |||
@@ -7,7 +7,9 @@ | |||
7 | use bytes; | 7 | use bytes; |
8 | use File::Basename; | 8 | use File::Basename; |
9 | 9 | ||
10 | # | 10 | # Default options |
11 | $max_width = 79; | ||
12 | |||
11 | # Clean up space-tab sequences, either by removing spaces or | 13 | # Clean up space-tab sequences, either by removing spaces or |
12 | # replacing them with tabs. | 14 | # replacing them with tabs. |
13 | sub clean_space_tabs($) | 15 | sub clean_space_tabs($) |
@@ -48,9 +50,49 @@ sub clean_space_tabs($) | |||
48 | return $lo; | 50 | return $lo; |
49 | } | 51 | } |
50 | 52 | ||
53 | # Compute the visual width of a string | ||
54 | sub strwidth($) { | ||
55 | no bytes; # Tab alignment depends on characters | ||
56 | |||
57 | my($li) = @_; | ||
58 | my($c, $i); | ||
59 | my $pos = 0; | ||
60 | my $mlen = 0; | ||
61 | |||
62 | for ($i = 0; $i < length($li); $i++) { | ||
63 | $c = substr($li,$i,1); | ||
64 | if ($c eq "\t") { | ||
65 | $pos = ($pos+8) & ~7; | ||
66 | } elsif ($c eq "\n") { | ||
67 | $mlen = $pos if ($pos > $mlen); | ||
68 | $pos = 0; | ||
69 | } else { | ||
70 | $pos++; | ||
71 | } | ||
72 | } | ||
73 | |||
74 | $mlen = $pos if ($pos > $mlen); | ||
75 | return $mlen; | ||
76 | } | ||
77 | |||
51 | $name = basename($0); | 78 | $name = basename($0); |
52 | 79 | ||
53 | foreach $f ( @ARGV ) { | 80 | @files = (); |
81 | |||
82 | while (defined($a = shift(@ARGV))) { | ||
83 | if ($a =~ /^-/) { | ||
84 | if ($a eq '-width' || $a eq '-w') { | ||
85 | $max_width = shift(@ARGV)+0; | ||
86 | } else { | ||
87 | print STDERR "Usage: $name [-width #] files...\n"; | ||
88 | exit 1; | ||
89 | } | ||
90 | } else { | ||
91 | push(@files, $a); | ||
92 | } | ||
93 | } | ||
94 | |||
95 | foreach $f ( @files ) { | ||
54 | print STDERR "$name: $f\n"; | 96 | print STDERR "$name: $f\n"; |
55 | 97 | ||
56 | if (! -f $f) { | 98 | if (! -f $f) { |
@@ -86,6 +128,7 @@ foreach $f ( @ARGV ) { | |||
86 | 128 | ||
87 | $in_bytes = 0; | 129 | $in_bytes = 0; |
88 | $out_bytes = 0; | 130 | $out_bytes = 0; |
131 | $lineno = 0; | ||
89 | 132 | ||
90 | @lines = (); | 133 | @lines = (); |
91 | 134 | ||
@@ -93,10 +136,12 @@ foreach $f ( @ARGV ) { | |||
93 | $err = 0; | 136 | $err = 0; |
94 | 137 | ||
95 | while ( defined($line = <FILE>) ) { | 138 | while ( defined($line = <FILE>) ) { |
139 | $lineno++; | ||
96 | $in_bytes += length($line); | 140 | $in_bytes += length($line); |
97 | 141 | ||
98 | if (!$in_hunk) { | 142 | if (!$in_hunk) { |
99 | if ($line =~ /^\@\@\s+\-([0-9]+),([0-9]+)\s+\+([0-9]+),([0-9]+)\s\@\@/) { | 143 | if ($line =~ |
144 | /^\@\@\s+\-([0-9]+),([0-9]+)\s+\+([0-9]+),([0-9]+)\s\@\@/) { | ||
100 | $minus_lines = $2; | 145 | $minus_lines = $2; |
101 | $plus_lines = $4; | 146 | $plus_lines = $4; |
102 | if ($minus_lines || $plus_lines) { | 147 | if ($minus_lines || $plus_lines) { |
@@ -117,6 +162,13 @@ foreach $f ( @ARGV ) { | |||
117 | $text =~ s/[ \t\r]*$//; # Remove trailing spaces | 162 | $text =~ s/[ \t\r]*$//; # Remove trailing spaces |
118 | $text = clean_space_tabs($text); | 163 | $text = clean_space_tabs($text); |
119 | 164 | ||
165 | $l_width = strwidth($text); | ||
166 | if ($max_width && $l_width > $max_width) { | ||
167 | print STDERR | ||
168 | "$f:$lineno: adds line exceeds $max_width ", | ||
169 | "characters ($l_width)\n"; | ||
170 | } | ||
171 | |||
120 | push(@hunk_lines, '+'.$text); | 172 | push(@hunk_lines, '+'.$text); |
121 | } elsif ($line =~ /^\-/) { | 173 | } elsif ($line =~ /^\-/) { |
122 | $minus_lines--; | 174 | $minus_lines--; |
diff --git a/scripts/decodecode b/scripts/decodecode new file mode 100644 index 000000000000..1e1a8f620c47 --- /dev/null +++ b/scripts/decodecode | |||
@@ -0,0 +1,51 @@ | |||
1 | #!/bin/sh | ||
2 | # Disassemble the Code: line in Linux oopses | ||
3 | # usage: decodecode < oops.file | ||
4 | # | ||
5 | # options: set env. variable AFLAGS=options to pass options to "as"; | ||
6 | # e.g., to decode an i386 oops on an x86_64 system, use: | ||
7 | # AFLAGS=--32 decodecode < 386.oops | ||
8 | |||
9 | T=`mktemp` | ||
10 | code= | ||
11 | |||
12 | while read i ; do | ||
13 | |||
14 | case "$i" in | ||
15 | *Code:*) | ||
16 | code=$i | ||
17 | ;; | ||
18 | esac | ||
19 | |||
20 | done | ||
21 | |||
22 | if [ -z "$code" ]; then | ||
23 | exit | ||
24 | fi | ||
25 | |||
26 | echo $code | ||
27 | code=`echo $code | sed -e 's/.*Code: //'` | ||
28 | |||
29 | marker=`expr index "$code" "\<"` | ||
30 | if [ $marker -eq 0 ]; then | ||
31 | marker=`expr index "$code" "\("` | ||
32 | fi | ||
33 | |||
34 | if [ $marker -ne 0 ]; then | ||
35 | beforemark=`echo "$code" | cut -c-$((${marker} - 1))` | ||
36 | echo -n " .byte 0x" > $T.s | ||
37 | echo $beforemark | sed -e 's/ /,0x/g' >> $T.s | ||
38 | as $AFLAGS -o $T.o $T.s | ||
39 | objdump -S $T.o | ||
40 | rm $T.o $T.s | ||
41 | |||
42 | # and fix code at-and-after marker | ||
43 | code=`echo "$code" | cut -c$((${marker} + 1))-` | ||
44 | fi | ||
45 | |||
46 | code=`echo $code | sed -e 's/ [<(]/ /;s/[>)] / /;s/ /,0x/g'` | ||
47 | echo -n " .byte 0x" > $T.s | ||
48 | echo $code >> $T.s | ||
49 | as $AFLAGS -o $T.o $T.s | ||
50 | objdump -S $T.o | ||
51 | rm $T.o $T.s | ||
diff --git a/scripts/gcc-version.sh b/scripts/gcc-version.sh index bb4fbeab8320..8a1d1879c7ad 100644 --- a/scripts/gcc-version.sh +++ b/scripts/gcc-version.sh | |||
@@ -1,14 +1,23 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | # | 2 | # |
3 | # gcc-version gcc-command | 3 | # gcc-version [-p] gcc-command |
4 | # | 4 | # |
5 | # Prints the gcc version of `gcc-command' in a canonical 4-digit form | 5 | # Prints the gcc version of `gcc-command' in a canonical 4-digit form |
6 | # such as `0295' for gcc-2.95, `0303' for gcc-3.3, etc. | 6 | # such as `0295' for gcc-2.95, `0303' for gcc-3.3, etc. |
7 | # | 7 | # |
8 | # With the -p option, prints the patchlevel as well, for example `029503' for | ||
9 | # gcc-2.95.3, `030301' for gcc-3.3.1, etc. | ||
10 | # | ||
11 | |||
12 | if [ $1 = "-p" ] ; then with_patchlevel=1; shift; fi | ||
8 | 13 | ||
9 | compiler="$*" | 14 | compiler="$*" |
10 | 15 | ||
11 | MAJOR=$(echo __GNUC__ | $compiler -E -xc - | tail -n 1) | 16 | MAJOR=$(echo __GNUC__ | $compiler -E -xc - | tail -n 1) |
12 | MINOR=$(echo __GNUC_MINOR__ | $compiler -E -xc - | tail -n 1) | 17 | MINOR=$(echo __GNUC_MINOR__ | $compiler -E -xc - | tail -n 1) |
13 | printf "%02d%02d\\n" $MAJOR $MINOR | 18 | if [ "x$with_patchlevel" != "x" ] ; then |
14 | 19 | PATCHLEVEL=$(echo __GNUC_PATCHLEVEL__ | $compiler -E -xc - | tail -n 1) | |
20 | printf "%02d%02d%02d\\n" $MAJOR $MINOR $PATCHLEVEL | ||
21 | else | ||
22 | printf "%02d%02d\\n" $MAJOR $MINOR | ||
23 | fi | ||
diff --git a/scripts/gen_initramfs_list.sh b/scripts/gen_initramfs_list.sh index 683eb12babbb..684fb9cdc055 100644 --- a/scripts/gen_initramfs_list.sh +++ b/scripts/gen_initramfs_list.sh | |||
@@ -19,11 +19,11 @@ $0 [-o <file>] [-u <uid>] [-g <gid>] {-d | <cpio_source>} ... | |||
19 | -o <file> Create gzipped initramfs file named <file> using | 19 | -o <file> Create gzipped initramfs file named <file> using |
20 | gen_init_cpio and gzip | 20 | gen_init_cpio and gzip |
21 | -u <uid> User ID to map to user ID 0 (root). | 21 | -u <uid> User ID to map to user ID 0 (root). |
22 | <uid> is only meaningful if <cpio_source> | 22 | <uid> is only meaningful if <cpio_source> is a |
23 | is a directory. | 23 | directory. "squash" forces all files to uid 0. |
24 | -g <gid> Group ID to map to group ID 0 (root). | 24 | -g <gid> Group ID to map to group ID 0 (root). |
25 | <gid> is only meaningful if <cpio_source> | 25 | <gid> is only meaningful if <cpio_source> is a |
26 | is a directory. | 26 | directory. "squash" forces all files to gid 0. |
27 | <cpio_source> File list or directory for cpio archive. | 27 | <cpio_source> File list or directory for cpio archive. |
28 | If <cpio_source> is a .cpio file it will be used | 28 | If <cpio_source> is a .cpio file it will be used |
29 | as direct input to initramfs. | 29 | as direct input to initramfs. |
@@ -113,8 +113,8 @@ parse() { | |||
113 | local gid="$4" | 113 | local gid="$4" |
114 | local ftype=$(filetype "${location}") | 114 | local ftype=$(filetype "${location}") |
115 | # remap uid/gid to 0 if necessary | 115 | # remap uid/gid to 0 if necessary |
116 | [ "$uid" -eq "$root_uid" ] && uid=0 | 116 | [ "$root_uid" = "squash" ] && uid=0 || [ "$uid" -eq "$root_uid" ] && uid=0 |
117 | [ "$gid" -eq "$root_gid" ] && gid=0 | 117 | [ "$root_gid" = "squash" ] && gid=0 || [ "$gid" -eq "$root_gid" ] && gid=0 |
118 | local str="${mode} ${uid} ${gid}" | 118 | local str="${mode} ${uid} ${gid}" |
119 | 119 | ||
120 | [ "${ftype}" == "invalid" ] && return 0 | 120 | [ "${ftype}" == "invalid" ] && return 0 |
diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 8b809b264d18..1f11d848532a 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c | |||
@@ -24,14 +24,12 @@ | |||
24 | * | 24 | * |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #define _GNU_SOURCE | ||
28 | |||
29 | #include <stdio.h> | 27 | #include <stdio.h> |
30 | #include <stdlib.h> | 28 | #include <stdlib.h> |
31 | #include <string.h> | 29 | #include <string.h> |
32 | #include <ctype.h> | 30 | #include <ctype.h> |
33 | 31 | ||
34 | #define KSYM_NAME_LEN 127 | 32 | #define KSYM_NAME_LEN 128 |
35 | 33 | ||
36 | 34 | ||
37 | struct sym_entry { | 35 | struct sym_entry { |
@@ -254,7 +252,7 @@ static void write_src(void) | |||
254 | unsigned int i, k, off; | 252 | unsigned int i, k, off; |
255 | unsigned int best_idx[256]; | 253 | unsigned int best_idx[256]; |
256 | unsigned int *markers; | 254 | unsigned int *markers; |
257 | char buf[KSYM_NAME_LEN+1]; | 255 | char buf[KSYM_NAME_LEN]; |
258 | 256 | ||
259 | printf("#include <asm/types.h>\n"); | 257 | printf("#include <asm/types.h>\n"); |
260 | printf("#if BITS_PER_LONG == 64\n"); | 258 | printf("#if BITS_PER_LONG == 64\n"); |
@@ -378,6 +376,17 @@ static void build_initial_tok_table(void) | |||
378 | table_cnt = pos; | 376 | table_cnt = pos; |
379 | } | 377 | } |
380 | 378 | ||
379 | static void *find_token(unsigned char *str, int len, unsigned char *token) | ||
380 | { | ||
381 | int i; | ||
382 | |||
383 | for (i = 0; i < len - 1; i++) { | ||
384 | if (str[i] == token[0] && str[i+1] == token[1]) | ||
385 | return &str[i]; | ||
386 | } | ||
387 | return NULL; | ||
388 | } | ||
389 | |||
381 | /* replace a given token in all the valid symbols. Use the sampled symbols | 390 | /* replace a given token in all the valid symbols. Use the sampled symbols |
382 | * to update the counts */ | 391 | * to update the counts */ |
383 | static void compress_symbols(unsigned char *str, int idx) | 392 | static void compress_symbols(unsigned char *str, int idx) |
@@ -391,7 +400,7 @@ static void compress_symbols(unsigned char *str, int idx) | |||
391 | p1 = table[i].sym; | 400 | p1 = table[i].sym; |
392 | 401 | ||
393 | /* find the token on the symbol */ | 402 | /* find the token on the symbol */ |
394 | p2 = memmem(p1, len, str, 2); | 403 | p2 = find_token(p1, len, str); |
395 | if (!p2) continue; | 404 | if (!p2) continue; |
396 | 405 | ||
397 | /* decrease the counts for this symbol's tokens */ | 406 | /* decrease the counts for this symbol's tokens */ |
@@ -410,7 +419,7 @@ static void compress_symbols(unsigned char *str, int idx) | |||
410 | if (size < 2) break; | 419 | if (size < 2) break; |
411 | 420 | ||
412 | /* find the token on the symbol */ | 421 | /* find the token on the symbol */ |
413 | p2 = memmem(p1, size, str, 2); | 422 | p2 = find_token(p1, size, str); |
414 | 423 | ||
415 | } while (p2); | 424 | } while (p2); |
416 | 425 | ||
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index fb2bb3099dd9..8986a48c8c49 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile | |||
@@ -22,24 +22,25 @@ oldconfig: $(obj)/conf | |||
22 | silentoldconfig: $(obj)/conf | 22 | silentoldconfig: $(obj)/conf |
23 | $< -s arch/$(ARCH)/Kconfig | 23 | $< -s arch/$(ARCH)/Kconfig |
24 | 24 | ||
25 | # Create new linux.po file | ||
26 | # Adjust charset to UTF-8 in .po file to accept UTF-8 in Kconfig files | ||
27 | # The symlink is used to repair a deficiency in arch/um | ||
25 | update-po-config: $(obj)/kxgettext | 28 | update-po-config: $(obj)/kxgettext |
26 | xgettext --default-domain=linux \ | 29 | xgettext --default-domain=linux \ |
27 | --add-comments --keyword=_ --keyword=N_ \ | 30 | --add-comments --keyword=_ --keyword=N_ \ |
28 | --files-from=scripts/kconfig/POTFILES.in \ | 31 | --from-code=UTF-8 \ |
29 | --output scripts/kconfig/config.pot | 32 | --files-from=scripts/kconfig/POTFILES.in \ |
30 | $(Q)ln -fs Kconfig_i386 arch/um/Kconfig_arch | 33 | --output $(obj)/config.pot |
31 | $(Q)for i in `ls arch/`; \ | 34 | $(Q)sed -i s/CHARSET/UTF-8/ $(obj)/config.pot |
32 | do \ | 35 | $(Q)ln -fs Kconfig.i386 arch/um/Kconfig.arch |
33 | scripts/kconfig/kxgettext arch/$$i/Kconfig \ | 36 | (for i in `ls arch/`; \ |
34 | | msguniq -o scripts/kconfig/linux_$${i}.pot; \ | 37 | do \ |
35 | done | 38 | $(obj)/kxgettext arch/$$i/Kconfig; \ |
36 | $(Q)msgcat scripts/kconfig/config.pot \ | 39 | done ) >> $(obj)/config.pot |
37 | `find scripts/kconfig/ -type f -name linux_*.pot` \ | 40 | msguniq --sort-by-file --to-code=UTF-8 $(obj)/config.pot \ |
38 | --output scripts/kconfig/linux_raw.pot | 41 | --output $(obj)/linux.pot |
39 | $(Q)msguniq --sort-by-file scripts/kconfig/linux_raw.pot \ | 42 | $(Q)rm -f arch/um/Kconfig.arch |
40 | --output scripts/kconfig/linux.pot | 43 | $(Q)rm -f $(obj)/config.pot |
41 | $(Q)rm -f arch/um/Kconfig_arch | ||
42 | $(Q)rm -f scripts/kconfig/linux_*.pot scripts/kconfig/config.pot | ||
43 | 44 | ||
44 | PHONY += randconfig allyesconfig allnoconfig allmodconfig defconfig | 45 | PHONY += randconfig allyesconfig allnoconfig allmodconfig defconfig |
45 | 46 | ||
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 664fe29dacef..b2913e9da495 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c | |||
@@ -341,27 +341,42 @@ int conf_read(const char *name) | |||
341 | conf_unsaved++; | 341 | conf_unsaved++; |
342 | /* maybe print value in verbose mode... */ | 342 | /* maybe print value in verbose mode... */ |
343 | sym_ok: | 343 | sym_ok: |
344 | if (!sym_is_choice(sym)) | ||
345 | continue; | ||
346 | /* The choice symbol only has a set value (and thus is not new) | ||
347 | * if all its visible childs have values. | ||
348 | */ | ||
349 | prop = sym_get_choice_prop(sym); | ||
350 | flags = sym->flags; | ||
351 | for (e = prop->expr; e; e = e->left.expr) | ||
352 | if (e->right.sym->visible != no) | ||
353 | flags &= e->right.sym->flags; | ||
354 | sym->flags &= flags | ~SYMBOL_DEF_USER; | ||
355 | } | ||
356 | |||
357 | for_all_symbols(i, sym) { | ||
344 | if (sym_has_value(sym) && !sym_is_choice_value(sym)) { | 358 | if (sym_has_value(sym) && !sym_is_choice_value(sym)) { |
345 | if (sym->visible == no) | 359 | /* Reset values of generates values, so they'll appear |
360 | * as new, if they should become visible, but that | ||
361 | * doesn't quite work if the Kconfig and the saved | ||
362 | * configuration disagree. | ||
363 | */ | ||
364 | if (sym->visible == no && !conf_unsaved) | ||
346 | sym->flags &= ~SYMBOL_DEF_USER; | 365 | sym->flags &= ~SYMBOL_DEF_USER; |
347 | switch (sym->type) { | 366 | switch (sym->type) { |
348 | case S_STRING: | 367 | case S_STRING: |
349 | case S_INT: | 368 | case S_INT: |
350 | case S_HEX: | 369 | case S_HEX: |
351 | if (!sym_string_within_range(sym, sym->def[S_DEF_USER].val)) | 370 | /* Reset a string value if it's out of range */ |
352 | sym->flags &= ~(SYMBOL_VALID|SYMBOL_DEF_USER); | 371 | if (sym_string_within_range(sym, sym->def[S_DEF_USER].val)) |
372 | break; | ||
373 | sym->flags &= ~(SYMBOL_VALID|SYMBOL_DEF_USER); | ||
374 | conf_unsaved++; | ||
375 | break; | ||
353 | default: | 376 | default: |
354 | break; | 377 | break; |
355 | } | 378 | } |
356 | } | 379 | } |
357 | if (!sym_is_choice(sym)) | ||
358 | continue; | ||
359 | prop = sym_get_choice_prop(sym); | ||
360 | flags = sym->flags; | ||
361 | for (e = prop->expr; e; e = e->left.expr) | ||
362 | if (e->right.sym->visible != no) | ||
363 | flags &= e->right.sym->flags; | ||
364 | sym->flags &= flags | ~SYMBOL_DEF_USER; | ||
365 | } | 380 | } |
366 | 381 | ||
367 | sym_add_change_count(conf_warnings || conf_unsaved); | 382 | sym_add_change_count(conf_warnings || conf_unsaved); |
diff --git a/scripts/kconfig/kxgettext.c b/scripts/kconfig/kxgettext.c index abee55ca6174..11f7dab94715 100644 --- a/scripts/kconfig/kxgettext.c +++ b/scripts/kconfig/kxgettext.c | |||
@@ -212,7 +212,9 @@ void menu__xgettext(void) | |||
212 | struct message *m = message__list; | 212 | struct message *m = message__list; |
213 | 213 | ||
214 | while (m != NULL) { | 214 | while (m != NULL) { |
215 | message__print_gettext_msgid_msgstr(m); | 215 | /* skip empty lines ("") */ |
216 | if (strlen(m->msg) > sizeof("\"\"")) | ||
217 | message__print_gettext_msgid_msgstr(m); | ||
216 | m = m->next; | 218 | m = m->next; |
217 | } | 219 | } |
218 | } | 220 | } |
diff --git a/scripts/kconfig/lxdialog/check-lxdialog.sh b/scripts/kconfig/lxdialog/check-lxdialog.sh index cdca7388e0f1..9681476b96e7 100644 --- a/scripts/kconfig/lxdialog/check-lxdialog.sh +++ b/scripts/kconfig/lxdialog/check-lxdialog.sh | |||
@@ -51,7 +51,7 @@ usage() { | |||
51 | printf "Usage: $0 [-check compiler options|-header|-library]\n" | 51 | printf "Usage: $0 [-check compiler options|-header|-library]\n" |
52 | } | 52 | } |
53 | 53 | ||
54 | if [ $# == 0 ]; then | 54 | if [ $# -eq 0 ]; then |
55 | usage | 55 | usage |
56 | exit 1 | 56 | exit 1 |
57 | fi | 57 | fi |
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index d0e4fa594fc7..d2c2a429887b 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c | |||
@@ -419,11 +419,13 @@ static void search_conf(void) | |||
419 | { | 419 | { |
420 | struct symbol **sym_arr; | 420 | struct symbol **sym_arr; |
421 | struct gstr res; | 421 | struct gstr res; |
422 | char *dialog_input; | ||
422 | int dres; | 423 | int dres; |
423 | again: | 424 | again: |
424 | dialog_clear(); | 425 | dialog_clear(); |
425 | dres = dialog_inputbox(_("Search Configuration Parameter"), | 426 | dres = dialog_inputbox(_("Search Configuration Parameter"), |
426 | _("Enter CONFIG_ (sub)string to search for (omit CONFIG_)"), | 427 | _("Enter CONFIG_ (sub)string to search for " |
428 | "(with or without \"CONFIG\")"), | ||
427 | 10, 75, ""); | 429 | 10, 75, ""); |
428 | switch (dres) { | 430 | switch (dres) { |
429 | case 0: | 431 | case 0: |
@@ -435,7 +437,12 @@ again: | |||
435 | return; | 437 | return; |
436 | } | 438 | } |
437 | 439 | ||
438 | sym_arr = sym_re_search(dialog_input_result); | 440 | /* strip CONFIG_ if necessary */ |
441 | dialog_input = dialog_input_result; | ||
442 | if (strncasecmp(dialog_input_result, "CONFIG_", 7) == 0) | ||
443 | dialog_input += 7; | ||
444 | |||
445 | sym_arr = sym_re_search(dialog_input); | ||
439 | res = get_relations_str(sym_arr); | 446 | res = get_relations_str(sym_arr); |
440 | free(sym_arr); | 447 | free(sym_arr); |
441 | show_textbox(_("Search Results"), str_get(&res), 0, 0); | 448 | show_textbox(_("Search Results"), str_get(&res), 0, 0); |
diff --git a/scripts/kernel-doc b/scripts/kernel-doc index e5bf649e516a..1f5835115cad 100755 --- a/scripts/kernel-doc +++ b/scripts/kernel-doc | |||
@@ -154,6 +154,7 @@ use strict; | |||
154 | 154 | ||
155 | my $errors = 0; | 155 | my $errors = 0; |
156 | my $warnings = 0; | 156 | my $warnings = 0; |
157 | my $anon_struct_union = 0; | ||
157 | 158 | ||
158 | # match expressions used to find embedded type information | 159 | # match expressions used to find embedded type information |
159 | my $type_constant = '\%([-_\w]+)'; | 160 | my $type_constant = '\%([-_\w]+)'; |
@@ -403,7 +404,11 @@ sub output_highlight { | |||
403 | print $lineprefix, $blankline; | 404 | print $lineprefix, $blankline; |
404 | } else { | 405 | } else { |
405 | $line =~ s/\\\\\\/\&/g; | 406 | $line =~ s/\\\\\\/\&/g; |
406 | print $lineprefix, $line; | 407 | if ($output_mode eq "man" && substr($line, 0, 1) eq ".") { |
408 | print "\\&$line"; | ||
409 | } else { | ||
410 | print $lineprefix, $line; | ||
411 | } | ||
407 | } | 412 | } |
408 | print "\n"; | 413 | print "\n"; |
409 | } | 414 | } |
@@ -718,6 +723,7 @@ sub output_struct_xml(%) { | |||
718 | # pointer-to-function | 723 | # pointer-to-function |
719 | print " $1 $parameter) ($2);\n"; | 724 | print " $1 $parameter) ($2);\n"; |
720 | } elsif ($type =~ m/^(.*?)\s*(:.*)/) { | 725 | } elsif ($type =~ m/^(.*?)\s*(:.*)/) { |
726 | # bitfield | ||
721 | print " $1 $parameter$2;\n"; | 727 | print " $1 $parameter$2;\n"; |
722 | } else { | 728 | } else { |
723 | print " ".$type." ".$parameter.";\n"; | 729 | print " ".$type." ".$parameter.";\n"; |
@@ -1260,6 +1266,7 @@ sub output_struct_text(%) { | |||
1260 | # pointer-to-function | 1266 | # pointer-to-function |
1261 | print "\t$1 $parameter) ($2);\n"; | 1267 | print "\t$1 $parameter) ($2);\n"; |
1262 | } elsif ($type =~ m/^(.*?)\s*(:.*)/) { | 1268 | } elsif ($type =~ m/^(.*?)\s*(:.*)/) { |
1269 | # bitfield | ||
1263 | print "\t$1 $parameter$2;\n"; | 1270 | print "\t$1 $parameter$2;\n"; |
1264 | } else { | 1271 | } else { |
1265 | print "\t".$type." ".$parameter.";\n"; | 1272 | print "\t".$type." ".$parameter.";\n"; |
@@ -1510,8 +1517,13 @@ sub push_parameter($$$) { | |||
1510 | my $param = shift; | 1517 | my $param = shift; |
1511 | my $type = shift; | 1518 | my $type = shift; |
1512 | my $file = shift; | 1519 | my $file = shift; |
1513 | my $anon = 0; | ||
1514 | 1520 | ||
1521 | if (($anon_struct_union == 1) && ($type eq "") && | ||
1522 | ($param eq "}")) { | ||
1523 | return; # ignore the ending }; from anon. struct/union | ||
1524 | } | ||
1525 | |||
1526 | $anon_struct_union = 0; | ||
1515 | my $param_name = $param; | 1527 | my $param_name = $param; |
1516 | $param_name =~ s/\[.*//; | 1528 | $param_name =~ s/\[.*//; |
1517 | 1529 | ||
@@ -1530,16 +1542,16 @@ sub push_parameter($$$) { | |||
1530 | # handle unnamed (anonymous) union or struct: | 1542 | # handle unnamed (anonymous) union or struct: |
1531 | { | 1543 | { |
1532 | $type = $param; | 1544 | $type = $param; |
1533 | $param = "{unnamed_" . $param. "}"; | 1545 | $param = "{unnamed_" . $param . "}"; |
1534 | $parameterdescs{$param} = "anonymous\n"; | 1546 | $parameterdescs{$param} = "anonymous\n"; |
1535 | $anon = 1; | 1547 | $anon_struct_union = 1; |
1536 | } | 1548 | } |
1537 | 1549 | ||
1538 | # warn if parameter has no description | 1550 | # warn if parameter has no description |
1539 | # (but ignore ones starting with # as these are not parameters | 1551 | # (but ignore ones starting with # as these are not parameters |
1540 | # but inline preprocessor statements); | 1552 | # but inline preprocessor statements); |
1541 | # also ignore unnamed structs/unions; | 1553 | # also ignore unnamed structs/unions; |
1542 | if (!$anon) { | 1554 | if (!$anon_struct_union) { |
1543 | if (!defined $parameterdescs{$param_name} && $param_name !~ /^#/) { | 1555 | if (!defined $parameterdescs{$param_name} && $param_name !~ /^#/) { |
1544 | 1556 | ||
1545 | $parameterdescs{$param_name} = $undescribed; | 1557 | $parameterdescs{$param_name} = $undescribed; |
@@ -1691,6 +1703,8 @@ sub process_state3_function($$) { | |||
1691 | my $x = shift; | 1703 | my $x = shift; |
1692 | my $file = shift; | 1704 | my $file = shift; |
1693 | 1705 | ||
1706 | $x =~ s@\/\/.*$@@gos; # strip C99-style comments to end of line | ||
1707 | |||
1694 | if ($x =~ m#\s*/\*\s+MACDOC\s*#io || ($x =~ /^#/ && $x !~ /^#define/)) { | 1708 | if ($x =~ m#\s*/\*\s+MACDOC\s*#io || ($x =~ /^#/ && $x !~ /^#define/)) { |
1695 | # do nothing | 1709 | # do nothing |
1696 | } | 1710 | } |
@@ -1713,6 +1727,8 @@ sub process_state3_type($$) { | |||
1713 | $x =~ s@[\r\n]+@ @gos; # strip newlines/cr's. | 1727 | $x =~ s@[\r\n]+@ @gos; # strip newlines/cr's. |
1714 | $x =~ s@^\s+@@gos; # strip leading spaces | 1728 | $x =~ s@^\s+@@gos; # strip leading spaces |
1715 | $x =~ s@\s+$@@gos; # strip trailing spaces | 1729 | $x =~ s@\s+$@@gos; # strip trailing spaces |
1730 | $x =~ s@\/\/.*$@@gos; # strip C99-style comments to end of line | ||
1731 | |||
1716 | if ($x =~ /^#/) { | 1732 | if ($x =~ /^#/) { |
1717 | # To distinguish preprocessor directive from regular declaration later. | 1733 | # To distinguish preprocessor directive from regular declaration later. |
1718 | $x .= ";"; | 1734 | $x .= ";"; |
@@ -1796,7 +1812,7 @@ sub process_file($) { | |||
1796 | 1812 | ||
1797 | $state = 2; | 1813 | $state = 2; |
1798 | if (/-(.*)/) { | 1814 | if (/-(.*)/) { |
1799 | # strip leading/trailing/multiple spaces #RDD:T: | 1815 | # strip leading/trailing/multiple spaces |
1800 | $descr= $1; | 1816 | $descr= $1; |
1801 | $descr =~ s/^\s*//; | 1817 | $descr =~ s/^\s*//; |
1802 | $descr =~ s/\s*$//; | 1818 | $descr =~ s/\s*$//; |
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 3645e980da71..5ab7914d30ef 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c | |||
@@ -75,7 +75,8 @@ static int is_vmlinux(const char *modname) | |||
75 | else | 75 | else |
76 | myname = modname; | 76 | myname = modname; |
77 | 77 | ||
78 | return strcmp(myname, "vmlinux") == 0; | 78 | return (strcmp(myname, "vmlinux") == 0) || |
79 | (strcmp(myname, "vmlinux.o") == 0); | ||
79 | } | 80 | } |
80 | 81 | ||
81 | void *do_nofail(void *ptr, const char *expr) | 82 | void *do_nofail(void *ptr, const char *expr) |
@@ -374,6 +375,7 @@ static int parse_elf(struct elf_info *info, const char *filename) | |||
374 | hdr->e_shstrndx = TO_NATIVE(hdr->e_shstrndx); | 375 | hdr->e_shstrndx = TO_NATIVE(hdr->e_shstrndx); |
375 | hdr->e_shnum = TO_NATIVE(hdr->e_shnum); | 376 | hdr->e_shnum = TO_NATIVE(hdr->e_shnum); |
376 | hdr->e_machine = TO_NATIVE(hdr->e_machine); | 377 | hdr->e_machine = TO_NATIVE(hdr->e_machine); |
378 | hdr->e_type = TO_NATIVE(hdr->e_type); | ||
377 | sechdrs = (void *)hdr + hdr->e_shoff; | 379 | sechdrs = (void *)hdr + hdr->e_shoff; |
378 | info->sechdrs = sechdrs; | 380 | info->sechdrs = sechdrs; |
379 | 381 | ||
@@ -384,6 +386,8 @@ static int parse_elf(struct elf_info *info, const char *filename) | |||
384 | sechdrs[i].sh_size = TO_NATIVE(sechdrs[i].sh_size); | 386 | sechdrs[i].sh_size = TO_NATIVE(sechdrs[i].sh_size); |
385 | sechdrs[i].sh_link = TO_NATIVE(sechdrs[i].sh_link); | 387 | sechdrs[i].sh_link = TO_NATIVE(sechdrs[i].sh_link); |
386 | sechdrs[i].sh_name = TO_NATIVE(sechdrs[i].sh_name); | 388 | sechdrs[i].sh_name = TO_NATIVE(sechdrs[i].sh_name); |
389 | sechdrs[i].sh_info = TO_NATIVE(sechdrs[i].sh_info); | ||
390 | sechdrs[i].sh_addr = TO_NATIVE(sechdrs[i].sh_addr); | ||
387 | } | 391 | } |
388 | /* Find symbol table. */ | 392 | /* Find symbol table. */ |
389 | for (i = 1; i < hdr->e_shnum; i++) { | 393 | for (i = 1; i < hdr->e_shnum; i++) { |
@@ -605,18 +609,14 @@ static int strrcmp(const char *s, const char *sub) | |||
605 | * warn here. | 609 | * warn here. |
606 | * the pattern is identified by: | 610 | * the pattern is identified by: |
607 | * tosec = .init.text | .exit.text | .init.data | 611 | * tosec = .init.text | .exit.text | .init.data |
608 | * fromsec = .data | 612 | * fromsec = .data | .data.rel | .data.rel.* |
609 | * atsym = *driver, *_template, *_sht, *_ops, *_probe, *probe_one, *_console | 613 | * atsym = *driver, *_template, *_sht, *_ops, *_probe, *probe_one, *_console, *_timer |
610 | * | 614 | * |
611 | * Pattern 3: | 615 | * Pattern 3: |
612 | * Whitelist all references from .pci_fixup* section to .init.text | ||
613 | * This is part of the PCI init when built-in | ||
614 | * | ||
615 | * Pattern 4: | ||
616 | * Whitelist all refereces from .text.head to .init.data | 616 | * Whitelist all refereces from .text.head to .init.data |
617 | * Whitelist all refereces from .text.head to .init.text | 617 | * Whitelist all refereces from .text.head to .init.text |
618 | * | 618 | * |
619 | * Pattern 5: | 619 | * Pattern 4: |
620 | * Some symbols belong to init section but still it is ok to reference | 620 | * Some symbols belong to init section but still it is ok to reference |
621 | * these from non-init sections as these symbols don't have any memory | 621 | * these from non-init sections as these symbols don't have any memory |
622 | * allocated for them and symbol address and value are same. So even | 622 | * allocated for them and symbol address and value are same. So even |
@@ -625,26 +625,6 @@ static int strrcmp(const char *s, const char *sub) | |||
625 | * This pattern is identified by | 625 | * This pattern is identified by |
626 | * refsymname = __init_begin, _sinittext, _einittext | 626 | * refsymname = __init_begin, _sinittext, _einittext |
627 | * | 627 | * |
628 | * Pattern 7: | ||
629 | * Logos used in drivers/video/logo reside in __initdata but the | ||
630 | * funtion that references them are EXPORT_SYMBOL() so cannot be | ||
631 | * marker __init. So we whitelist them here. | ||
632 | * The pattern is: | ||
633 | * tosec = .init.data | ||
634 | * fromsec = .text* | ||
635 | * refsymname = logo_ | ||
636 | * | ||
637 | * Pattern 8: | ||
638 | * Symbols contained in .paravirtprobe may safely reference .init.text. | ||
639 | * The pattern is: | ||
640 | * tosec = .init.text | ||
641 | * fromsec = .paravirtprobe | ||
642 | * | ||
643 | * Pattern 10: | ||
644 | * ia64 has machvec table for each platform and | ||
645 | * powerpc has a machine desc table for each platform. | ||
646 | * It is mixture of function pointers of .init.text and .text. | ||
647 | * fromsec = .machvec | .machine.desc | ||
648 | **/ | 628 | **/ |
649 | static int secref_whitelist(const char *modname, const char *tosec, | 629 | static int secref_whitelist(const char *modname, const char *tosec, |
650 | const char *fromsec, const char *atsym, | 630 | const char *fromsec, const char *atsym, |
@@ -655,12 +635,12 @@ static int secref_whitelist(const char *modname, const char *tosec, | |||
655 | const char *pat2sym[] = { | 635 | const char *pat2sym[] = { |
656 | "driver", | 636 | "driver", |
657 | "_template", /* scsi uses *_template a lot */ | 637 | "_template", /* scsi uses *_template a lot */ |
638 | "_timer", /* arm uses ops structures named _timer a lot */ | ||
658 | "_sht", /* scsi also used *_sht to some extent */ | 639 | "_sht", /* scsi also used *_sht to some extent */ |
659 | "_ops", | 640 | "_ops", |
660 | "_probe", | 641 | "_probe", |
661 | "_probe_one", | 642 | "_probe_one", |
662 | "_console", | 643 | "_console", |
663 | "apic_es7000", | ||
664 | NULL | 644 | NULL |
665 | }; | 645 | }; |
666 | 646 | ||
@@ -692,7 +672,9 @@ static int secref_whitelist(const char *modname, const char *tosec, | |||
692 | (strcmp(tosec, ".exit.text") != 0) && | 672 | (strcmp(tosec, ".exit.text") != 0) && |
693 | (strcmp(tosec, ".init.data") != 0)) | 673 | (strcmp(tosec, ".init.data") != 0)) |
694 | f2 = 0; | 674 | f2 = 0; |
695 | if (strcmp(fromsec, ".data") != 0) | 675 | if ((strcmp(fromsec, ".data") != 0) && |
676 | (strcmp(fromsec, ".data.rel") != 0) && | ||
677 | (strncmp(fromsec, ".data.rel.", strlen(".data.rel.")) != 0)) | ||
696 | f2 = 0; | 678 | f2 = 0; |
697 | 679 | ||
698 | for (s = pat2sym; *s; s++) | 680 | for (s = pat2sym; *s; s++) |
@@ -702,37 +684,16 @@ static int secref_whitelist(const char *modname, const char *tosec, | |||
702 | return 1; | 684 | return 1; |
703 | 685 | ||
704 | /* Check for pattern 3 */ | 686 | /* Check for pattern 3 */ |
705 | if ((strncmp(fromsec, ".pci_fixup", strlen(".pci_fixup")) == 0) && | ||
706 | (strcmp(tosec, ".init.text") == 0)) | ||
707 | return 1; | ||
708 | |||
709 | /* Check for pattern 4 */ | ||
710 | if ((strcmp(fromsec, ".text.head") == 0) && | 687 | if ((strcmp(fromsec, ".text.head") == 0) && |
711 | ((strcmp(tosec, ".init.data") == 0) || | 688 | ((strcmp(tosec, ".init.data") == 0) || |
712 | (strcmp(tosec, ".init.text") == 0))) | 689 | (strcmp(tosec, ".init.text") == 0))) |
713 | return 1; | 690 | return 1; |
714 | 691 | ||
715 | /* Check for pattern 5 */ | 692 | /* Check for pattern 4 */ |
716 | for (s = pat3refsym; *s; s++) | 693 | for (s = pat3refsym; *s; s++) |
717 | if (strcmp(refsymname, *s) == 0) | 694 | if (strcmp(refsymname, *s) == 0) |
718 | return 1; | 695 | return 1; |
719 | 696 | ||
720 | /* Check for pattern 7 */ | ||
721 | if ((strcmp(tosec, ".init.data") == 0) && | ||
722 | (strncmp(fromsec, ".text", strlen(".text")) == 0) && | ||
723 | (strncmp(refsymname, "logo_", strlen("logo_")) == 0)) | ||
724 | return 1; | ||
725 | |||
726 | /* Check for pattern 8 */ | ||
727 | if ((strcmp(tosec, ".init.text") == 0) && | ||
728 | (strcmp(fromsec, ".paravirtprobe") == 0)) | ||
729 | return 1; | ||
730 | |||
731 | /* Check for pattern 10 */ | ||
732 | if ((strcmp(fromsec, ".machvec") == 0) || | ||
733 | (strcmp(fromsec, ".machine.desc") == 0)) | ||
734 | return 1; | ||
735 | |||
736 | return 0; | 697 | return 0; |
737 | } | 698 | } |
738 | 699 | ||
@@ -753,6 +714,8 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf_Addr addr, | |||
753 | for (sym = elf->symtab_start; sym < elf->symtab_stop; sym++) { | 714 | for (sym = elf->symtab_start; sym < elf->symtab_stop; sym++) { |
754 | if (sym->st_shndx != relsym->st_shndx) | 715 | if (sym->st_shndx != relsym->st_shndx) |
755 | continue; | 716 | continue; |
717 | if (ELF_ST_TYPE(sym->st_info) == STT_SECTION) | ||
718 | continue; | ||
756 | if (sym->st_value == addr) | 719 | if (sym->st_value == addr) |
757 | return sym; | 720 | return sym; |
758 | } | 721 | } |
@@ -864,11 +827,6 @@ static void warn_sec_mismatch(const char *modname, const char *fromsec, | |||
864 | elf->strtab + before->st_name, refsymname)) | 827 | elf->strtab + before->st_name, refsymname)) |
865 | return; | 828 | return; |
866 | 829 | ||
867 | /* fromsec whitelist - without a valid 'before' | ||
868 | * powerpc has a GOT table in .got2 section */ | ||
869 | if (strcmp(fromsec, ".got2") == 0) | ||
870 | return; | ||
871 | |||
872 | if (before && after) { | 830 | if (before && after) { |
873 | warn("%s(%s+0x%llx): Section mismatch: reference to %s:%s " | 831 | warn("%s(%s+0x%llx): Section mismatch: reference to %s:%s " |
874 | "(between '%s' and '%s')\n", | 832 | "(between '%s' and '%s')\n", |
@@ -895,6 +853,78 @@ static void warn_sec_mismatch(const char *modname, const char *fromsec, | |||
895 | } | 853 | } |
896 | } | 854 | } |
897 | 855 | ||
856 | static unsigned int *reloc_location(struct elf_info *elf, | ||
857 | int rsection, Elf_Rela *r) | ||
858 | { | ||
859 | Elf_Shdr *sechdrs = elf->sechdrs; | ||
860 | int section = sechdrs[rsection].sh_info; | ||
861 | |||
862 | return (void *)elf->hdr + sechdrs[section].sh_offset + | ||
863 | (r->r_offset - sechdrs[section].sh_addr); | ||
864 | } | ||
865 | |||
866 | static int addend_386_rel(struct elf_info *elf, int rsection, Elf_Rela *r) | ||
867 | { | ||
868 | unsigned int r_typ = ELF_R_TYPE(r->r_info); | ||
869 | unsigned int *location = reloc_location(elf, rsection, r); | ||
870 | |||
871 | switch (r_typ) { | ||
872 | case R_386_32: | ||
873 | r->r_addend = TO_NATIVE(*location); | ||
874 | break; | ||
875 | case R_386_PC32: | ||
876 | r->r_addend = TO_NATIVE(*location) + 4; | ||
877 | /* For CONFIG_RELOCATABLE=y */ | ||
878 | if (elf->hdr->e_type == ET_EXEC) | ||
879 | r->r_addend += r->r_offset; | ||
880 | break; | ||
881 | } | ||
882 | return 0; | ||
883 | } | ||
884 | |||
885 | static int addend_arm_rel(struct elf_info *elf, int rsection, Elf_Rela *r) | ||
886 | { | ||
887 | unsigned int r_typ = ELF_R_TYPE(r->r_info); | ||
888 | |||
889 | switch (r_typ) { | ||
890 | case R_ARM_ABS32: | ||
891 | /* From ARM ABI: (S + A) | T */ | ||
892 | r->r_addend = (int)(long)(elf->symtab_start + ELF_R_SYM(r->r_info)); | ||
893 | break; | ||
894 | case R_ARM_PC24: | ||
895 | /* From ARM ABI: ((S + A) | T) - P */ | ||
896 | r->r_addend = (int)(long)(elf->hdr + elf->sechdrs[rsection].sh_offset + | ||
897 | (r->r_offset - elf->sechdrs[rsection].sh_addr)); | ||
898 | break; | ||
899 | default: | ||
900 | return 1; | ||
901 | } | ||
902 | return 0; | ||
903 | } | ||
904 | |||
905 | static int addend_mips_rel(struct elf_info *elf, int rsection, Elf_Rela *r) | ||
906 | { | ||
907 | unsigned int r_typ = ELF_R_TYPE(r->r_info); | ||
908 | unsigned int *location = reloc_location(elf, rsection, r); | ||
909 | unsigned int inst; | ||
910 | |||
911 | if (r_typ == R_MIPS_HI16) | ||
912 | return 1; /* skip this */ | ||
913 | inst = TO_NATIVE(*location); | ||
914 | switch (r_typ) { | ||
915 | case R_MIPS_LO16: | ||
916 | r->r_addend = inst & 0xffff; | ||
917 | break; | ||
918 | case R_MIPS_26: | ||
919 | r->r_addend = (inst & 0x03ffffff) << 2; | ||
920 | break; | ||
921 | case R_MIPS_32: | ||
922 | r->r_addend = inst; | ||
923 | break; | ||
924 | } | ||
925 | return 0; | ||
926 | } | ||
927 | |||
898 | /** | 928 | /** |
899 | * A module includes a number of sections that are discarded | 929 | * A module includes a number of sections that are discarded |
900 | * either when loaded or when used as built-in. | 930 | * either when loaded or when used as built-in. |
@@ -938,8 +968,11 @@ static void check_sec_ref(struct module *mod, const char *modname, | |||
938 | r.r_offset = TO_NATIVE(rela->r_offset); | 968 | r.r_offset = TO_NATIVE(rela->r_offset); |
939 | #if KERNEL_ELFCLASS == ELFCLASS64 | 969 | #if KERNEL_ELFCLASS == ELFCLASS64 |
940 | if (hdr->e_machine == EM_MIPS) { | 970 | if (hdr->e_machine == EM_MIPS) { |
971 | unsigned int r_typ; | ||
941 | r_sym = ELF64_MIPS_R_SYM(rela->r_info); | 972 | r_sym = ELF64_MIPS_R_SYM(rela->r_info); |
942 | r_sym = TO_NATIVE(r_sym); | 973 | r_sym = TO_NATIVE(r_sym); |
974 | r_typ = ELF64_MIPS_R_TYPE(rela->r_info); | ||
975 | r.r_info = ELF64_R_INFO(r_sym, r_typ); | ||
943 | } else { | 976 | } else { |
944 | r.r_info = TO_NATIVE(rela->r_info); | 977 | r.r_info = TO_NATIVE(rela->r_info); |
945 | r_sym = ELF_R_SYM(r.r_info); | 978 | r_sym = ELF_R_SYM(r.r_info); |
@@ -972,8 +1005,11 @@ static void check_sec_ref(struct module *mod, const char *modname, | |||
972 | r.r_offset = TO_NATIVE(rel->r_offset); | 1005 | r.r_offset = TO_NATIVE(rel->r_offset); |
973 | #if KERNEL_ELFCLASS == ELFCLASS64 | 1006 | #if KERNEL_ELFCLASS == ELFCLASS64 |
974 | if (hdr->e_machine == EM_MIPS) { | 1007 | if (hdr->e_machine == EM_MIPS) { |
1008 | unsigned int r_typ; | ||
975 | r_sym = ELF64_MIPS_R_SYM(rel->r_info); | 1009 | r_sym = ELF64_MIPS_R_SYM(rel->r_info); |
976 | r_sym = TO_NATIVE(r_sym); | 1010 | r_sym = TO_NATIVE(r_sym); |
1011 | r_typ = ELF64_MIPS_R_TYPE(rel->r_info); | ||
1012 | r.r_info = ELF64_R_INFO(r_sym, r_typ); | ||
977 | } else { | 1013 | } else { |
978 | r.r_info = TO_NATIVE(rel->r_info); | 1014 | r.r_info = TO_NATIVE(rel->r_info); |
979 | r_sym = ELF_R_SYM(r.r_info); | 1015 | r_sym = ELF_R_SYM(r.r_info); |
@@ -983,6 +1019,20 @@ static void check_sec_ref(struct module *mod, const char *modname, | |||
983 | r_sym = ELF_R_SYM(r.r_info); | 1019 | r_sym = ELF_R_SYM(r.r_info); |
984 | #endif | 1020 | #endif |
985 | r.r_addend = 0; | 1021 | r.r_addend = 0; |
1022 | switch (hdr->e_machine) { | ||
1023 | case EM_386: | ||
1024 | if (addend_386_rel(elf, i, &r)) | ||
1025 | continue; | ||
1026 | break; | ||
1027 | case EM_ARM: | ||
1028 | if(addend_arm_rel(elf, i, &r)) | ||
1029 | continue; | ||
1030 | break; | ||
1031 | case EM_MIPS: | ||
1032 | if (addend_mips_rel(elf, i, &r)) | ||
1033 | continue; | ||
1034 | break; | ||
1035 | } | ||
986 | sym = elf->symtab_start + r_sym; | 1036 | sym = elf->symtab_start + r_sym; |
987 | /* Skip special sections */ | 1037 | /* Skip special sections */ |
988 | if (sym->st_shndx >= SHN_LORESERVE) | 1038 | if (sym->st_shndx >= SHN_LORESERVE) |
@@ -998,6 +1048,64 @@ static void check_sec_ref(struct module *mod, const char *modname, | |||
998 | } | 1048 | } |
999 | } | 1049 | } |
1000 | 1050 | ||
1051 | /* | ||
1052 | * Identify sections from which references to either a | ||
1053 | * .init or a .exit section is OK. | ||
1054 | * | ||
1055 | * [OPD] Keith Ownes <kaos@sgi.com> commented: | ||
1056 | * For our future {in}sanity, add a comment that this is the ppc .opd | ||
1057 | * section, not the ia64 .opd section. | ||
1058 | * ia64 .opd should not point to discarded sections. | ||
1059 | * [.rodata] like for .init.text we ignore .rodata references -same reason | ||
1060 | */ | ||
1061 | static int initexit_section_ref_ok(const char *name) | ||
1062 | { | ||
1063 | const char **s; | ||
1064 | /* Absolute section names */ | ||
1065 | const char *namelist1[] = { | ||
1066 | "__bug_table", /* used by powerpc for BUG() */ | ||
1067 | "__ex_table", | ||
1068 | ".altinstructions", | ||
1069 | ".cranges", /* used by sh64 */ | ||
1070 | ".fixup", | ||
1071 | ".machvec", /* ia64 + powerpc uses these */ | ||
1072 | ".machine.desc", | ||
1073 | ".opd", /* See comment [OPD] */ | ||
1074 | ".parainstructions", | ||
1075 | ".pdr", | ||
1076 | ".plt", /* seen on ARCH=um build on x86_64. Harmless */ | ||
1077 | ".smp_locks", | ||
1078 | ".stab", | ||
1079 | ".m68k_fixup", | ||
1080 | NULL | ||
1081 | }; | ||
1082 | /* Start of section names */ | ||
1083 | const char *namelist2[] = { | ||
1084 | ".debug", | ||
1085 | ".eh_frame", | ||
1086 | ".note", /* ignore ELF notes - may contain anything */ | ||
1087 | ".got", /* powerpc - global offset table */ | ||
1088 | ".toc", /* powerpc - table of contents */ | ||
1089 | NULL | ||
1090 | }; | ||
1091 | /* part of section name */ | ||
1092 | const char *namelist3 [] = { | ||
1093 | ".unwind", /* Sample: IA_64.unwind.exit.text */ | ||
1094 | NULL | ||
1095 | }; | ||
1096 | |||
1097 | for (s = namelist1; *s; s++) | ||
1098 | if (strcmp(*s, name) == 0) | ||
1099 | return 1; | ||
1100 | for (s = namelist2; *s; s++) | ||
1101 | if (strncmp(*s, name, strlen(*s)) == 0) | ||
1102 | return 1; | ||
1103 | for (s = namelist3; *s; s++) | ||
1104 | if (strstr(name, *s) != NULL) | ||
1105 | return 1; | ||
1106 | return 0; | ||
1107 | } | ||
1108 | |||
1001 | /** | 1109 | /** |
1002 | * Functions used only during module init is marked __init and is stored in | 1110 | * Functions used only during module init is marked __init and is stored in |
1003 | * a .init.text section. Likewise data is marked __initdata and stored in | 1111 | * a .init.text section. Likewise data is marked __initdata and stored in |
@@ -1014,7 +1122,7 @@ static int init_section(const char *name) | |||
1014 | return 0; | 1122 | return 0; |
1015 | } | 1123 | } |
1016 | 1124 | ||
1017 | /** | 1125 | /* |
1018 | * Identify sections from which references to a .init section is OK. | 1126 | * Identify sections from which references to a .init section is OK. |
1019 | * | 1127 | * |
1020 | * Unfortunately references to read only data that referenced .init | 1128 | * Unfortunately references to read only data that referenced .init |
@@ -1028,48 +1136,31 @@ static int init_section(const char *name) | |||
1028 | * | 1136 | * |
1029 | * where vgacon_startup is __init. If you want to wade through the false | 1137 | * where vgacon_startup is __init. If you want to wade through the false |
1030 | * positives, take out the check for rodata. | 1138 | * positives, take out the check for rodata. |
1031 | **/ | 1139 | */ |
1032 | static int init_section_ref_ok(const char *name) | 1140 | static int init_section_ref_ok(const char *name) |
1033 | { | 1141 | { |
1034 | const char **s; | 1142 | const char **s; |
1035 | /* Absolute section names */ | 1143 | /* Absolute section names */ |
1036 | const char *namelist1[] = { | 1144 | const char *namelist1[] = { |
1037 | ".init", | 1145 | "__dbe_table", /* MIPS generate these */ |
1038 | ".opd", /* see comment [OPD] at exit_section_ref_ok() */ | ||
1039 | ".toc1", /* used by ppc64 */ | ||
1040 | ".stab", | ||
1041 | ".data.rel.ro", /* used by parisc64 */ | ||
1042 | ".parainstructions", | ||
1043 | ".text.lock", | ||
1044 | "__bug_table", /* used by powerpc for BUG() */ | ||
1045 | ".pci_fixup_header", | ||
1046 | ".pci_fixup_final", | ||
1047 | ".pdr", | ||
1048 | "__param", | ||
1049 | "__ex_table", | ||
1050 | ".fixup", | ||
1051 | ".smp_locks", | ||
1052 | ".plt", /* seen on ARCH=um build on x86_64. Harmless */ | ||
1053 | "__ftr_fixup", /* powerpc cpu feature fixup */ | 1146 | "__ftr_fixup", /* powerpc cpu feature fixup */ |
1054 | "__fw_ftr_fixup", /* powerpc firmware feature fixup */ | 1147 | "__fw_ftr_fixup", /* powerpc firmware feature fixup */ |
1055 | ".cranges", /* used by sh64 */ | 1148 | "__param", |
1149 | ".data.rel.ro", /* used by parisc64 */ | ||
1150 | ".init", | ||
1151 | ".text.lock", | ||
1056 | NULL | 1152 | NULL |
1057 | }; | 1153 | }; |
1058 | /* Start of section names */ | 1154 | /* Start of section names */ |
1059 | const char *namelist2[] = { | 1155 | const char *namelist2[] = { |
1060 | ".init.", | 1156 | ".init.", |
1061 | ".altinstructions", | 1157 | ".pci_fixup", |
1062 | ".eh_frame", | ||
1063 | ".debug", | ||
1064 | ".parainstructions", | ||
1065 | ".rodata", | 1158 | ".rodata", |
1066 | NULL | 1159 | NULL |
1067 | }; | 1160 | }; |
1068 | /* part of section name */ | 1161 | |
1069 | const char *namelist3 [] = { | 1162 | if (initexit_section_ref_ok(name)) |
1070 | ".unwind", /* sample: IA_64.unwind.init.text */ | 1163 | return 1; |
1071 | NULL | ||
1072 | }; | ||
1073 | 1164 | ||
1074 | for (s = namelist1; *s; s++) | 1165 | for (s = namelist1; *s; s++) |
1075 | if (strcmp(*s, name) == 0) | 1166 | if (strcmp(*s, name) == 0) |
@@ -1077,9 +1168,10 @@ static int init_section_ref_ok(const char *name) | |||
1077 | for (s = namelist2; *s; s++) | 1168 | for (s = namelist2; *s; s++) |
1078 | if (strncmp(*s, name, strlen(*s)) == 0) | 1169 | if (strncmp(*s, name, strlen(*s)) == 0) |
1079 | return 1; | 1170 | return 1; |
1080 | for (s = namelist3; *s; s++) | 1171 | |
1081 | if (strstr(name, *s) != NULL) | 1172 | /* If section name ends with ".init" we allow references |
1082 | return 1; | 1173 | * as is the case with .initcallN.init, .early_param.init, .taglist.init etc |
1174 | */ | ||
1083 | if (strrcmp(name, ".init") == 0) | 1175 | if (strrcmp(name, ".init") == 0) |
1084 | return 1; | 1176 | return 1; |
1085 | return 0; | 1177 | return 0; |
@@ -1104,58 +1196,25 @@ static int exit_section(const char *name) | |||
1104 | 1196 | ||
1105 | /* | 1197 | /* |
1106 | * Identify sections from which references to a .exit section is OK. | 1198 | * Identify sections from which references to a .exit section is OK. |
1107 | * | 1199 | */ |
1108 | * [OPD] Keith Ownes <kaos@sgi.com> commented: | ||
1109 | * For our future {in}sanity, add a comment that this is the ppc .opd | ||
1110 | * section, not the ia64 .opd section. | ||
1111 | * ia64 .opd should not point to discarded sections. | ||
1112 | * [.rodata] like for .init.text we ignore .rodata references -same reason | ||
1113 | **/ | ||
1114 | static int exit_section_ref_ok(const char *name) | 1200 | static int exit_section_ref_ok(const char *name) |
1115 | { | 1201 | { |
1116 | const char **s; | 1202 | const char **s; |
1117 | /* Absolute section names */ | 1203 | /* Absolute section names */ |
1118 | const char *namelist1[] = { | 1204 | const char *namelist1[] = { |
1119 | ".exit.text", | ||
1120 | ".exit.data", | 1205 | ".exit.data", |
1121 | ".init.text", | 1206 | ".exit.text", |
1122 | ".rodata", | ||
1123 | ".opd", /* See comment [OPD] */ | ||
1124 | ".toc1", /* used by ppc64 */ | ||
1125 | ".altinstructions", | ||
1126 | ".pdr", | ||
1127 | "__bug_table", /* used by powerpc for BUG() */ | ||
1128 | ".exitcall.exit", | 1207 | ".exitcall.exit", |
1129 | ".eh_frame", | 1208 | ".rodata", |
1130 | ".parainstructions", | ||
1131 | ".stab", | ||
1132 | "__ex_table", | ||
1133 | ".fixup", | ||
1134 | ".smp_locks", | ||
1135 | ".plt", /* seen on ARCH=um build on x86_64. Harmless */ | ||
1136 | ".cranges", /* used by sh64 */ | ||
1137 | NULL | ||
1138 | }; | ||
1139 | /* Start of section names */ | ||
1140 | const char *namelist2[] = { | ||
1141 | ".debug", | ||
1142 | NULL | ||
1143 | }; | ||
1144 | /* part of section name */ | ||
1145 | const char *namelist3 [] = { | ||
1146 | ".unwind", /* Sample: IA_64.unwind.exit.text */ | ||
1147 | NULL | 1209 | NULL |
1148 | }; | 1210 | }; |
1149 | 1211 | ||
1212 | if (initexit_section_ref_ok(name)) | ||
1213 | return 1; | ||
1214 | |||
1150 | for (s = namelist1; *s; s++) | 1215 | for (s = namelist1; *s; s++) |
1151 | if (strcmp(*s, name) == 0) | 1216 | if (strcmp(*s, name) == 0) |
1152 | return 1; | 1217 | return 1; |
1153 | for (s = namelist2; *s; s++) | ||
1154 | if (strncmp(*s, name, strlen(*s)) == 0) | ||
1155 | return 1; | ||
1156 | for (s = namelist3; *s; s++) | ||
1157 | if (strstr(name, *s) != NULL) | ||
1158 | return 1; | ||
1159 | return 0; | 1218 | return 0; |
1160 | } | 1219 | } |
1161 | 1220 | ||
diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h index 0858caa9c03f..4156dd34c5de 100644 --- a/scripts/mod/modpost.h +++ b/scripts/mod/modpost.h | |||
@@ -60,6 +60,9 @@ typedef union | |||
60 | #define ELF64_MIPS_R_SYM(i) \ | 60 | #define ELF64_MIPS_R_SYM(i) \ |
61 | ((__extension__ (_Elf64_Mips_R_Info_union)(i)).r_info_fields.r_sym) | 61 | ((__extension__ (_Elf64_Mips_R_Info_union)(i)).r_info_fields.r_sym) |
62 | 62 | ||
63 | #define ELF64_MIPS_R_TYPE(i) \ | ||
64 | ((__extension__ (_Elf64_Mips_R_Info_union)(i)).r_info_fields.r_type1) | ||
65 | |||
63 | #if KERNEL_ELFDATA != HOST_ELFDATA | 66 | #if KERNEL_ELFDATA != HOST_ELFDATA |
64 | 67 | ||
65 | static inline void __endian(const void *src, void *dest, unsigned int size) | 68 | static inline void __endian(const void *src, void *dest, unsigned int size) |