aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorSteve French <sfrench@us.ibm.com>2007-07-18 20:38:57 -0400
committerSteve French <sfrench@us.ibm.com>2007-07-18 20:38:57 -0400
commit1ff8392c32a2645d2665ca779ecb91bb29361c13 (patch)
tree860b95e9a499ade4060848740fc6ce1fbb4e4e8d /scripts
parent70b315b0dd3879cb3ab8aadffb14f10b2d19b9c3 (diff)
parent5bae7ac9feba925fd0099057f6b23d7be80b7b41 (diff)
Merge branch 'master' of /pub/scm/linux/kernel/git/torvalds/linux-2.6
Conflicts: fs/cifs/export.c
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Makefile.headersinst2
-rwxr-xr-xscripts/checkpatch.pl552
-rwxr-xr-xscripts/checksyscalls.sh5
-rw-r--r--scripts/decodecode51
-rw-r--r--scripts/kallsyms.c4
5 files changed, 383 insertions, 231 deletions
diff --git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst
index 8cd63014a0d1..f98d772aac80 100644
--- a/scripts/Makefile.headersinst
+++ b/scripts/Makefile.headersinst
@@ -108,7 +108,7 @@ quiet_cmd_mkdir = MKDIR $(patsubst $(INSTALL_HDR_PATH)/%,%,$@)
108 108
109quiet_cmd_gen = GEN $(patsubst $(INSTALL_HDR_PATH)/%,%,$@) 109quiet_cmd_gen = GEN $(patsubst $(INSTALL_HDR_PATH)/%,%,$@)
110 cmd_gen = \ 110 cmd_gen = \
111FNAME=$(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,%,$@) \ 111FNAME=$(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,%,$@); \
112STUBDEF=__ASM_STUB_`echo $$FNAME | tr a-z.- A-Z__`; \ 112STUBDEF=__ASM_STUB_`echo $$FNAME | tr a-z.- A-Z__`; \
113(echo "/* File autogenerated by 'make headers_install' */" ; \ 113(echo "/* File autogenerated by 'make headers_install' */" ; \
114echo "\#ifndef $$STUBDEF" ; \ 114echo "\#ifndef $$STUBDEF" ; \
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index aea90d30d229..25e20a27fc59 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -9,7 +9,7 @@ use strict;
9my $P = $0; 9my $P = $0;
10$P =~ s@.*/@@g; 10$P =~ s@.*/@@g;
11 11
12my $V = '0.04'; 12my $V = '0.07';
13 13
14use Getopt::Long qw(:config no_auto_abbrev); 14use Getopt::Long qw(:config no_auto_abbrev);
15 15
@@ -17,11 +17,13 @@ my $quiet = 0;
17my $tree = 1; 17my $tree = 1;
18my $chk_signoff = 1; 18my $chk_signoff = 1;
19my $chk_patch = 1; 19my $chk_patch = 1;
20my $tst_type = 0;
20GetOptions( 21GetOptions(
21 'q|quiet' => \$quiet, 22 'q|quiet' => \$quiet,
22 'tree!' => \$tree, 23 'tree!' => \$tree,
23 'signoff!' => \$chk_signoff, 24 'signoff!' => \$chk_signoff,
24 'patch!' => \$chk_patch, 25 'patch!' => \$chk_patch,
26 'test-type!' => \$tst_type,
25) or exit; 27) or exit;
26 28
27my $exit = 0; 29my $exit = 0;
@@ -151,7 +153,7 @@ sub sanitise_line {
151} 153}
152 154
153sub ctx_block_get { 155sub ctx_block_get {
154 my ($linenr, $remain, $outer) = @_; 156 my ($linenr, $remain, $outer, $open, $close) = @_;
155 my $line; 157 my $line;
156 my $start = $linenr - 1; 158 my $start = $linenr - 1;
157 my $blk = ''; 159 my $blk = '';
@@ -165,8 +167,8 @@ sub ctx_block_get {
165 167
166 $blk .= $rawlines[$line]; 168 $blk .= $rawlines[$line];
167 169
168 @o = ($blk =~ /\{/g); 170 @o = ($blk =~ /$open/g);
169 @c = ($blk =~ /\}/g); 171 @c = ($blk =~ /$close/g);
170 172
171 if (!$outer || (scalar(@o) - scalar(@c)) == 1) { 173 if (!$outer || (scalar(@o) - scalar(@c)) == 1) {
172 push(@res, $rawlines[$line]); 174 push(@res, $rawlines[$line]);
@@ -180,12 +182,17 @@ sub ctx_block_get {
180sub ctx_block_outer { 182sub ctx_block_outer {
181 my ($linenr, $remain) = @_; 183 my ($linenr, $remain) = @_;
182 184
183 return ctx_block_get($linenr, $remain, 1); 185 return ctx_block_get($linenr, $remain, 1, '\{', '\}');
184} 186}
185sub ctx_block { 187sub ctx_block {
186 my ($linenr, $remain) = @_; 188 my ($linenr, $remain) = @_;
187 189
188 return ctx_block_get($linenr, $remain, 0); 190 return ctx_block_get($linenr, $remain, 0, '\{', '\}');
191}
192sub ctx_statement {
193 my ($linenr, $remain) = @_;
194
195 return ctx_block_get($linenr, $remain, 0, '\(', '\)');
189} 196}
190 197
191sub ctx_locate_comment { 198sub ctx_locate_comment {
@@ -239,6 +246,19 @@ sub cat_vet {
239 return $vet; 246 return $vet;
240} 247}
241 248
249sub ERROR {
250 print "ERROR: $_[0]\n";
251 our $clean = 0;
252}
253sub WARN {
254 print "WARNING: $_[0]\n";
255 our $clean = 0;
256}
257sub CHK {
258 print "CHECK: $_[0]\n";
259 our $clean = 0;
260}
261
242sub process { 262sub process {
243 my $filename = shift; 263 my $filename = shift;
244 my @lines = @_; 264 my @lines = @_;
@@ -252,7 +272,7 @@ sub process {
252 my $previndent=0; 272 my $previndent=0;
253 my $stashindent=0; 273 my $stashindent=0;
254 274
255 my $clean = 1; 275 our $clean = 1;
256 my $signoff = 0; 276 my $signoff = 0;
257 my $is_patch = 0; 277 my $is_patch = 0;
258 278
@@ -264,9 +284,64 @@ sub process {
264 my $in_comment = 0; 284 my $in_comment = 0;
265 my $first_line = 0; 285 my $first_line = 0;
266 286
287 my $Ident = qr{[A-Za-z\d_]+};
288 my $Storage = qr{extern|static};
289 my $Sparse = qr{__user|__kernel|__force|__iomem};
290 my $NonptrType = qr{
291 \b
292 (?:const\s+)?
293 (?:unsigned\s+)?
294 (?:
295 void|
296 char|
297 short|
298 int|
299 long|
300 unsigned|
301 float|
302 double|
303 long\s+int|
304 long\s+long|
305 long\s+long\s+int|
306 u8|u16|u32|u64|
307 s8|s16|s32|s64|
308 struct\s+$Ident|
309 union\s+$Ident|
310 enum\s+$Ident|
311 ${Ident}_t
312 )
313 (?:\s+$Sparse)*
314 \b
315 }x;
316 my $Type = qr{
317 \b$NonptrType\b
318 (?:\s*\*+\s*const|\s*\*+)?
319 }x;
320 my $Declare = qr{(?:$Storage\s+)?$Type};
321 my $Attribute = qr{__read_mostly|__init|__initdata};
322
323 # Pre-scan the patch looking for any __setup documentation.
324 my @setup_docs = ();
325 my $setup_docs = 0;
326 foreach my $line (@lines) {
327 if ($line=~/^\+\+\+\s+(\S+)/) {
328 $setup_docs = 0;
329 if ($1 =~ m@Documentation/kernel-parameters.txt$@) {
330 $setup_docs = 1;
331 }
332 next;
333 }
334
335 if ($setup_docs && $line =~ /^\+/) {
336 push(@setup_docs, $line);
337 }
338 }
339
267 foreach my $line (@lines) { 340 foreach my $line (@lines) {
268 $linenr++; 341 $linenr++;
269 342
343 my $rawline = $line;
344
270#extract the filename as it passes 345#extract the filename as it passes
271 if ($line=~/^\+\+\+\s+(\S+)/) { 346 if ($line=~/^\+\+\+\s+(\S+)/) {
272 $realfile=$1; 347 $realfile=$1;
@@ -293,6 +368,7 @@ sub process {
293# blank context lines so we need to count that too. 368# blank context lines so we need to count that too.
294 if ($line =~ /^( |\+|$)/) { 369 if ($line =~ /^( |\+|$)/) {
295 $realline++; 370 $realline++;
371 $realcnt-- if ($realcnt != 0);
296 372
297 # track any sort of multi-line comment. Obviously if 373 # track any sort of multi-line comment. Obviously if
298 # the added text or context do not include the whole 374 # the added text or context do not include the whole
@@ -317,41 +393,51 @@ sub process {
317 # Track the previous line. 393 # Track the previous line.
318 ($prevline, $stashline) = ($stashline, $line); 394 ($prevline, $stashline) = ($stashline, $line);
319 ($previndent, $stashindent) = ($stashindent, $indent); 395 ($previndent, $stashindent) = ($stashindent, $indent);
396 } elsif ($realcnt == 1) {
397 $realcnt--;
320 } 398 }
321 $realcnt-- if ($realcnt != 0);
322 399
323#make up the handle for any error we report on this line 400#make up the handle for any error we report on this line
324 $here = "#$linenr: "; 401 $here = "#$linenr: ";
325 $here .= "FILE: $realfile:$realline:" if ($realcnt != 0); 402 $here .= "FILE: $realfile:$realline:" if ($realcnt != 0);
326 403
327 my $hereline = "$here\n$line\n"; 404 my $hereline = "$here\n$line\n";
328 my $herecurr = "$here\n$line\n\n"; 405 my $herecurr = "$here\n$line\n";
329 my $hereprev = "$here\n$prevline\n$line\n\n"; 406 my $hereprev = "$here\n$prevline\n$line\n";
330 407
331#check the patch for a signoff: 408#check the patch for a signoff:
332 if ($line =~ /^\s*Signed-off-by:\s/) { 409 if ($line =~ /^\s*signed-off-by:/i) {
333 $signoff++;
334
335 } elsif ($line =~ /^\s*signed-off-by:/i) {
336 # This is a signoff, if ugly, so do not double report. 410 # This is a signoff, if ugly, so do not double report.
337 $signoff++; 411 $signoff++;
338 if (!($line =~ /^\s*Signed-off-by:/)) { 412 if (!($line =~ /^\s*Signed-off-by:/)) {
339 print "use Signed-off-by:\n"; 413 WARN("Signed-off-by: is the preferred form\n" .
340 print "$herecurr"; 414 $herecurr);
341 $clean = 0;
342 } 415 }
343 if ($line =~ /^\s*signed-off-by:\S/i) { 416 if ($line =~ /^\s*signed-off-by:\S/i) {
344 print "need space after Signed-off-by:\n"; 417 WARN("need space after Signed-off-by:\n" .
345 print "$herecurr"; 418 $herecurr);
346 $clean = 0;
347 } 419 }
348 } 420 }
349 421
350# Check for wrappage within a valid hunk of the file 422# Check for wrappage within a valid hunk of the file
351 if ($realcnt != 0 && $line !~ m{^(?:\+|-| |$)}) { 423 if ($realcnt != 0 && $line !~ m{^(?:\+|-| |$)}) {
352 print "patch seems to be corrupt (line wrapped?) [$realcnt]\n"; 424 ERROR("patch seems to be corrupt (line wrapped?)\n" .
353 print "$herecurr"; 425 $herecurr);
354 $clean = 0; 426 }
427
428# UTF-8 regex found at http://www.w3.org/International/questions/qa-forms-utf-8.en.php
429 if (($realfile =~ /^$/ || $line =~ /^\+/) &&
430 !($line =~ m/^(
431 [\x09\x0A\x0D\x20-\x7E] # ASCII
432 | [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte
433 | \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs
434 | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte
435 | \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates
436 | \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3
437 | [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15
438 | \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16
439 )*$/x )) {
440 ERROR("Invalid UTF-8\n" . $herecurr);
355 } 441 }
356 442
357#ignore lines being removed 443#ignore lines being removed
@@ -361,17 +447,13 @@ sub process {
361 next if ($realfile !~ /\.(h|c|s|S|pl|sh)$/); 447 next if ($realfile !~ /\.(h|c|s|S|pl|sh)$/);
362 448
363#trailing whitespace 449#trailing whitespace
364 if ($line=~/\+.*\S\s+$/) { 450 if ($line =~ /^\+.*\S\s+$/ || $line =~ /^\+\s+$/) {
365 my $herevet = "$here\n" . cat_vet($line) . "\n\n"; 451 my $herevet = "$here\n" . cat_vet($line) . "\n";
366 print "trailing whitespace\n"; 452 ERROR("trailing whitespace\n" . $herevet);
367 print "$herevet";
368 $clean = 0;
369 } 453 }
370#80 column limit 454#80 column limit
371 if ($line =~ /^\+/ && !($prevline=~/\/\*\*/) && $length > 80) { 455 if ($line =~ /^\+/ && !($prevline=~/\/\*\*/) && $length > 80) {
372 print "line over 80 characters\n"; 456 WARN("line over 80 characters\n" . $herecurr);
373 print "$herecurr";
374 $clean = 0;
375 } 457 }
376 458
377# check we are in a valid source file *.[hc] if not then ignore this hunk 459# check we are in a valid source file *.[hc] if not then ignore this hunk
@@ -380,10 +462,8 @@ sub process {
380# at the beginning of a line any tabs must come first and anything 462# at the beginning of a line any tabs must come first and anything
381# more than 8 must use tabs. 463# more than 8 must use tabs.
382 if ($line=~/^\+\s* \t\s*\S/ or $line=~/^\+\s* \s*/) { 464 if ($line=~/^\+\s* \t\s*\S/ or $line=~/^\+\s* \s*/) {
383 my $herevet = "$here\n" . cat_vet($line) . "\n\n"; 465 my $herevet = "$here\n" . cat_vet($line) . "\n";
384 print "use tabs not spaces\n"; 466 ERROR("use tabs not spaces\n" . $herevet);
385 print "$herevet";
386 $clean = 0;
387 } 467 }
388 468
389 # 469 #
@@ -392,17 +472,20 @@ sub process {
392 # 472 #
393 next if ($in_comment); 473 next if ($in_comment);
394 474
395 # Remove comments from the line before processing. 475# Remove comments from the line before processing.
396 $line =~ s@/\*.*\*/@@g; 476 $line =~ s@/\*.*\*/@@g;
397 $line =~ s@/\*.*@@; 477 $line =~ s@/\*.*@@;
398 $line =~ s@.*\*/@@; 478 $line =~ s@.*\*/@@;
399 479
400 # 480# Standardise the strings and chars within the input to simplify matching.
401 # Checks which may be anchored in the context. 481 $line = sanitise_line($line);
402 # 482
483#
484# Checks which may be anchored in the context.
485#
403 486
404 # Check for switch () and associated case and default 487# Check for switch () and associated case and default
405 # statements should be at the same indent. 488# statements should be at the same indent.
406 if ($line=~/\bswitch\s*\(.*\)/) { 489 if ($line=~/\bswitch\s*\(.*\)/) {
407 my $err = ''; 490 my $err = '';
408 my $sep = ''; 491 my $sep = '';
@@ -419,83 +502,104 @@ sub process {
419 } 502 }
420 } 503 }
421 if ($err ne '') { 504 if ($err ne '') {
422 print "switch and case should be at the same indent\n"; 505 ERROR("switch and case should be at the same indent\n$hereline\n$err\n");
423 print "$here\n$line\n$err\n"; 506 }
424 $clean = 0; 507 }
508
509# if/while/etc brace do not go on next line, unless defining a do while loop,
510# or if that brace on the next line is for something else
511 if ($line =~ /\b(?:(if|while|for|switch)\s*\(|do\b|else\b)/ && $line !~ /^.#/) {
512 my @ctx = ctx_statement($linenr, $realcnt);
513 my $ctx_ln = $linenr + $#ctx + 1;
514 my $ctx_cnt = $realcnt - $#ctx - 1;
515 my $ctx = join("\n", @ctx);
516
517 while ($ctx_cnt > 0 && $lines[$ctx_ln - 1] =~ /^-/) {
518 $ctx_ln++;
519 $ctx_cnt--;
520 }
521 ##warn "line<$line>\nctx<$ctx>\nnext<$lines[$ctx_ln - 1]>";
522
523 if ($ctx !~ /{\s*/ && $ctx_cnt > 0 && $lines[$ctx_ln - 1] =~ /^\+\s*{/) {
524 ERROR("That { should be on the previous line\n" .
525 "$here\n$ctx\n$lines[$ctx_ln - 1]");
425 } 526 }
426 } 527 }
427 528
428#ignore lines not being added 529#ignore lines not being added
429 if ($line=~/^[^\+]/) {next;} 530 if ($line=~/^[^\+]/) {next;}
430 531
431 # 532# TEST: allow direct testing of the type matcher.
432 # Checks which are anchored on the added line. 533 if ($tst_type && $line =~ /^.$Declare$/) {
433 # 534 ERROR("TEST: is type $Declare\n" . $herecurr);
535 next;
536 }
537
538#
539# Checks which are anchored on the added line.
540#
541
542# check for malformed paths in #include statements (uses RAW line)
543 if ($rawline =~ m{^.#\s*include\s+[<"](.*)[">]}) {
544 my $path = $1;
545 if ($path =~ m{//}) {
546 ERROR("malformed #include filename\n" .
547 $herecurr);
548 }
549 # Sanitise this special form of string.
550 $path = 'X' x length($path);
551 $line =~ s{\<.*\>}{<$path>};
552 }
434 553
435# no C99 // comments 554# no C99 // comments
436 if ($line =~ m{//}) { 555 if ($line =~ m{//}) {
437 print "do not use C99 // comments\n"; 556 ERROR("do not use C99 // comments\n" . $herecurr);
438 print "$herecurr";
439 $clean = 0;
440 } 557 }
441 # Remove C99 comments. 558 # Remove C99 comments.
442 $line =~ s@//.*@@; 559 $line =~ s@//.*@@;
443 560
444 # Standardise the strings and chars within the input
445 # to simplify matching.
446 $line = sanitise_line($line);
447
448#EXPORT_SYMBOL should immediately follow its function closing }. 561#EXPORT_SYMBOL should immediately follow its function closing }.
449 if (($line =~ /EXPORT_SYMBOL.*\(.*\)/) || 562 if (($line =~ /EXPORT_SYMBOL.*\((.*)\)/) ||
450 ($line =~ /EXPORT_UNUSED_SYMBOL.*\(.*\)/)) { 563 ($line =~ /EXPORT_UNUSED_SYMBOL.*\((.*)\)/)) {
564 my $name = $1;
451 if (($prevline !~ /^}/) && 565 if (($prevline !~ /^}/) &&
452 ($prevline !~ /^\+}/) && 566 ($prevline !~ /^\+}/) &&
453 ($prevline !~ /^ }/)) { 567 ($prevline !~ /^ }/) &&
454 print "EXPORT_SYMBOL(func); should immediately follow its function\n"; 568 ($prevline !~ /\s$name(?:\s+$Attribute)?\s*(?:;|=)/)) {
455 print "$herecurr"; 569 WARN("EXPORT_SYMBOL(foo); should immediately follow its function/variable\n" . $herecurr);
456 $clean = 0;
457 } 570 }
458 } 571 }
459 572
460 # check for static initialisers. 573# check for static initialisers.
461 if ($line=~/\s*static\s.*=\s+(0|NULL);/) { 574 if ($line=~/\s*static\s.*=\s+(0|NULL);/) {
462 print "do not initialise statics to 0 or NULL\n"; 575 ERROR("do not initialise statics to 0 or NULL\n" .
463 print "$herecurr"; 576 $herecurr);
464 $clean = 0;
465 } 577 }
466 578
467 # check for new typedefs. 579# check for new typedefs, only function parameters and sparse annotations
468 if ($line=~/\s*typedef\s/) { 580# make sense.
469 print "do not add new typedefs\n"; 581 if ($line =~ /\btypedef\s/ &&
470 print "$herecurr"; 582 $line !~ /\btypedef\s+$Type\s+\(\s*\*$Ident\s*\)\s*\(/ &&
471 $clean = 0; 583 $line !~ /\b__bitwise(?:__|)\b/) {
584 WARN("do not add new typedefs\n" . $herecurr);
472 } 585 }
473 586
474# * goes on variable not on type 587# * goes on variable not on type
475 my $type = '(?:char|short|int|long|unsigned|float|double|' . 588 if ($line =~ m{\($NonptrType(\*+)(?:\s+const)?\)}) {
476 'struct\s+[A-Za-z\d_]+|' . 589 ERROR("\"(foo$1)\" should be \"(foo $1)\"\n" .
477 'union\s+[A-Za-z\d_]+)'; 590 $herecurr);
478 591
479 if ($line =~ m{[A-Za-z\d_]+(\*+) [A-Za-z\d_]+}) { 592 } elsif ($line =~ m{\($NonptrType\s+(\*+)(?!\s+const)\s+\)}) {
480 print "\"foo$1 bar\" should be \"foo $1bar\"\n"; 593 ERROR("\"(foo $1 )\" should be \"(foo $1)\"\n" .
481 print "$herecurr"; 594 $herecurr);
482 $clean = 0; 595
483 } 596 } elsif ($line =~ m{$NonptrType(\*+)(?:\s+const)?\s+[A-Za-z\d_]+}) {
484 if ($line =~ m{$type (\*) [A-Za-z\d_]+} || 597 ERROR("\"foo$1 bar\" should be \"foo $1bar\"\n" .
485 $line =~ m{[A-Za-z\d_]+ (\*\*+) [A-Za-z\d_]+}) { 598 $herecurr);
486 print "\"foo $1 bar\" should be \"foo $1bar\"\n"; 599
487 print "$herecurr"; 600 } elsif ($line =~ m{$NonptrType\s+(\*+)(?!\s+const)\s+[A-Za-z\d_]+}) {
488 $clean = 0; 601 ERROR("\"foo $1 bar\" should be \"foo $1bar\"\n" .
489 } 602 $herecurr);
490 if ($line =~ m{\([A-Za-z\d_\s]+[A-Za-z\d_](\*+)\)}) {
491 print "\"(foo$1)\" should be \"(foo $1)\"\n";
492 print "$herecurr";
493 $clean = 0;
494 }
495 if ($line =~ m{\([A-Za-z\d_\s]+[A-Za-z\d_]\s+(\*+)\s+\)}) {
496 print "\"(foo $1 )\" should be \"(foo $1)\"\n";
497 print "$herecurr";
498 $clean = 0;
499 } 603 }
500 604
501# # no BUG() or BUG_ON() 605# # no BUG() or BUG_ON()
@@ -524,19 +628,18 @@ sub process {
524 } 628 }
525 } 629 }
526 if ($ok == 0) { 630 if ($ok == 0) {
527 print "printk() should include KERN_ facility level\n"; 631 WARN("printk() should include KERN_ facility level\n" . $herecurr);
528 print "$herecurr";
529 $clean = 0;
530 } 632 }
531 } 633 }
532 634
533#function brace can't be on same line, except for #defines of do while, or if closed on same line 635# function brace can't be on same line, except for #defines of do while,
534 if (($line=~/[A-Za-z\d_]+\**\s+\**[A-Za-z\d_]+\(.*\).* {/) and 636# or if closed on same line
637 if (($line=~/$Type\s*[A-Za-z\d_]+\(.*\).* {/) and
535 !($line=~/\#define.*do\s{/) and !($line=~/}/)) { 638 !($line=~/\#define.*do\s{/) and !($line=~/}/)) {
536 print "braces following function declarations go on the next line\n"; 639 ERROR("open brace '{' following function declarations go on the next line\n" . $herecurr);
537 print "$herecurr";
538 $clean = 0;
539 } 640 }
641
642# Check operator spacing.
540 # Note we expand the line with the leading + as the real 643 # Note we expand the line with the leading + as the real
541 # line will be displayed with the leading + and the tabs 644 # line will be displayed with the leading + and the tabs
542 # will therefore also expand that way. 645 # will therefore also expand that way.
@@ -544,7 +647,6 @@ sub process {
544 $opline = expand_tabs($opline); 647 $opline = expand_tabs($opline);
545 $opline =~ s/^./ /; 648 $opline =~ s/^./ /;
546 if (!($line=~/\#\s*include/)) { 649 if (!($line=~/\#\s*include/)) {
547 # Check operator spacing.
548 my @elements = split(/(<<=|>>=|<=|>=|==|!=|\+=|-=|\*=|\/=|%=|\^=|\|=|&=|->|<<|>>|<|>|=|!|~|&&|\|\||,|\^|\+\+|--|;|&|\||\+|-|\*|\/\/|\/)/, $opline); 650 my @elements = split(/(<<=|>>=|<=|>=|==|!=|\+=|-=|\*=|\/=|%=|\^=|\|=|&=|->|<<|>>|<|>|=|!|~|&&|\|\||,|\^|\+\+|--|;|&|\||\+|-|\*|\/\/|\/)/, $opline);
549 my $off = 0; 651 my $off = 0;
550 for (my $n = 0; $n < $#elements; $n += 2) { 652 for (my $n = 0; $n < $#elements; $n += 2) {
@@ -570,59 +672,60 @@ sub process {
570 } 672 }
571 673
572 # Pick up the preceeding and succeeding characters. 674 # Pick up the preceeding and succeeding characters.
573 my $ca = substr($opline, $off - 1, 1); 675 my $ca = substr($opline, 0, $off);
574 my $cc = ''; 676 my $cc = '';
575 if (length($opline) > ($off + length($elements[$n]))) { 677 if (length($opline) >= ($off + length($elements[$n + 1]))) {
576 $cc = substr($opline, $off + 1 + length($elements[$n]), 1); 678 $cc = substr($opline, $off + length($elements[$n + 1]));
577 } 679 }
680 my $cb = "$ca$;$cc";
578 681
579 my $ctx = "${a}x${c}"; 682 my $ctx = "${a}x${c}";
580 683
581 my $at = "(ctx:$ctx)"; 684 my $at = "(ctx:$ctx)";
582 685
583 my $ptr = (" " x $off) . "^"; 686 my $ptr = (" " x $off) . "^";
584 my $hereptr = "$hereline$ptr\n\n"; 687 my $hereptr = "$hereline$ptr\n";
585 688
586 ##print "<$s1:$op:$s2> <$elements[$n]:$elements[$n + 1]:$elements[$n + 2]>\n"; 689 ##print "<$s1:$op:$s2> <$elements[$n]:$elements[$n + 1]:$elements[$n + 2]>\n";
587 690
588 # We need ; as an operator. // is a comment. 691 # ; should have either the end of line or a space or \ after it
589 if ($op eq ';' or $op eq '//') { 692 if ($op eq ';') {
693 if ($ctx !~ /.x[WEB]/ && $cc !~ /^\\/ &&
694 $cc !~ /^;/) {
695 ERROR("need space after that '$op' $at\n" . $hereptr);
696 }
697
698 # // is a comment
699 } elsif ($op eq '//') {
590 700
591 # -> should have no spaces 701 # -> should have no spaces
592 } elsif ($op eq '->') { 702 } elsif ($op eq '->') {
593 if ($ctx =~ /Wx.|.xW/) { 703 if ($ctx =~ /Wx.|.xW/) {
594 print "no spaces around that '$op' $at\n"; 704 ERROR("no spaces around that '$op' $at\n" . $hereptr);
595 print "$hereptr";
596 $clean = 0;
597 } 705 }
598 706
599 # , must have a space on the right. 707 # , must have a space on the right.
600 } elsif ($op eq ',') { 708 } elsif ($op eq ',') {
601 if ($ctx !~ /.xW|.xE/) { 709 if ($ctx !~ /.xW|.xE/ && $cc !~ /^}/) {
602 print "need space after that '$op' $at\n"; 710 ERROR("need space after that '$op' $at\n" . $hereptr);
603 print "$hereptr";
604 $clean = 0;
605 } 711 }
606 712
607 # unary ! and unary ~ are allowed no space on the right 713 # unary ! and unary ~ are allowed no space on the right
608 } elsif ($op eq '!' or $op eq '~') { 714 } elsif ($op eq '!' or $op eq '~') {
609 if ($ctx !~ /[WOEB]x./) { 715 if ($ctx !~ /[WOEB]x./) {
610 print "need space before that '$op' $at\n"; 716 ERROR("need space before that '$op' $at\n" . $hereptr);
611 print "$hereptr";
612 $clean = 0;
613 } 717 }
614 if ($ctx =~ /.xW/) { 718 if ($ctx =~ /.xW/) {
615 print "no space after that '$op' $at\n"; 719 ERROR("no space after that '$op' $at\n" . $hereptr);
616 print "$hereptr";
617 $clean = 0;
618 } 720 }
619 721
620 # unary ++ and unary -- are allowed no space on one side. 722 # unary ++ and unary -- are allowed no space on one side.
621 } elsif ($op eq '++' or $op eq '--') { 723 } elsif ($op eq '++' or $op eq '--') {
622 if ($ctx !~ /[WOB]x[^W]|[^W]x[WOB]/) { 724 if ($ctx !~ /[WOB]x[^W]/ && $ctx !~ /[^W]x[WOBE]/) {
623 print "need space one side of that '$op' $at\n"; 725 ERROR("need space one side of that '$op' $at\n" . $hereptr);
624 print "$hereptr"; 726 }
625 $clean = 0; 727 if ($ctx =~ /Wx./ && $cc =~ /^;/) {
728 ERROR("no space before that '$op' $at\n" . $hereptr);
626 } 729 }
627 730
628 # & is both unary and binary 731 # & is both unary and binary
@@ -639,9 +742,7 @@ sub process {
639 # 742 #
640 } elsif ($op eq '&' or $op eq '-') { 743 } elsif ($op eq '&' or $op eq '-') {
641 if ($ctx !~ /VxV|[EW]x[WE]|[EWB]x[VO]/) { 744 if ($ctx !~ /VxV|[EW]x[WE]|[EWB]x[VO]/) {
642 print "need space before that '$op' $at\n"; 745 ERROR("need space before that '$op' $at\n" . $hereptr);
643 print "$hereptr";
644 $clean = 0;
645 } 746 }
646 747
647 # * is the same as & only adding: 748 # * is the same as & only adding:
@@ -650,16 +751,9 @@ sub process {
650 # (foo **) 751 # (foo **)
651 # 752 #
652 } elsif ($op eq '*') { 753 } elsif ($op eq '*') {
653 if ($ca eq '*') { 754 if ($ca !~ /$Type$/ && $cb !~ /(\*$;|$;\*)/ &&
654 if ($cc =~ /\s/) { 755 $ctx !~ /VxV|[EW]x[WE]|[EWB]x[VO]|OxV|WxB|BxB/) {
655 print "no space after that '$op' $at\n"; 756 ERROR("need space before that '$op' $at\n" . $hereptr);
656 print "$hereptr";
657 $clean = 0;
658 }
659 } elsif ($ctx !~ /VxV|[EW]x[WE]|[EWB]x[VO]|OxV|WxB/) {
660 print "need space before that '$op' $at\n";
661 print "$hereptr";
662 $clean = 0;
663 } 757 }
664 758
665 # << and >> may either have or not have spaces both sides 759 # << and >> may either have or not have spaces both sides
@@ -667,58 +761,51 @@ sub process {
667 $op eq '^' or $op eq '|') 761 $op eq '^' or $op eq '|')
668 { 762 {
669 if ($ctx !~ /VxV|WxW|VxE|WxE/) { 763 if ($ctx !~ /VxV|WxW|VxE|WxE/) {
670 print "need consistent spacing around '$op' $at\n"; 764 ERROR("need consistent spacing around '$op' $at\n" .
671 print "$hereptr"; 765 $hereptr);
672 $clean = 0;
673 } 766 }
674 767
675 # All the others need spaces both sides. 768 # All the others need spaces both sides.
676 } elsif ($ctx !~ /[EW]x[WE]/) { 769 } elsif ($ctx !~ /[EW]x[WE]/) {
677 print "need spaces around that '$op' $at\n"; 770 ERROR("need spaces around that '$op' $at\n" . $hereptr);
678 print "$hereptr";
679 $clean = 0;
680 } 771 }
681 $off += length($elements[$n + 1]); 772 $off += length($elements[$n + 1]);
682 } 773 }
683 } 774 }
684 775
685#need space before brace following if, while, etc 776#need space before brace following if, while, etc
686 if ($line=~/\(.*\){/) { 777 if ($line =~ /\(.*\){/ || $line =~ /do{/) {
687 print "need a space before the brace\n"; 778 ERROR("need a space before the open brace '{'\n" . $herecurr);
688 print "$herecurr"; 779 }
689 $clean = 0; 780
781# closing brace should have a space following it when it has anything
782# on the line
783 if ($line =~ /}(?!(?:,|;|\)))\S/) {
784 ERROR("need a space after that close brace '}'\n" . $herecurr);
690 } 785 }
691 786
692#goto labels aren't indented, allow a single space however 787#goto labels aren't indented, allow a single space however
693 if ($line=~/^.\s+[A-Za-z\d_]+:(?![0-9]+)/ and 788 if ($line=~/^.\s+[A-Za-z\d_]+:(?![0-9]+)/ and
694 !($line=~/^. [A-Za-z\d_]+:/) and !($line=~/^.\s+default:/)) { 789 !($line=~/^. [A-Za-z\d_]+:/) and !($line=~/^.\s+default:/)) {
695 print "labels should not be indented\n"; 790 WARN("labels should not be indented\n" . $herecurr);
696 print "$herecurr";
697 $clean = 0;
698 } 791 }
699 792
700# Need a space before open parenthesis after if, while etc 793# Need a space before open parenthesis after if, while etc
701 if ($line=~/\b(if|while|for|switch)\(/) { 794 if ($line=~/\b(if|while|for|switch)\(/) {
702 print "need a space before the open parenthesis\n"; 795 ERROR("need a space before the open parenthesis '('\n" . $herecurr);
703 print "$herecurr";
704 $clean = 0;
705 } 796 }
706 797
707# Check for illegal assignment in if conditional. 798# Check for illegal assignment in if conditional.
708 if ($line=~/\b(if|while)\s*\(.*[^<>!=]=[^=].*\)/) { 799 if ($line=~/\bif\s*\(.*[^<>!=]=[^=].*\)/) {
709 #next if ($line=~/\".*\Q$op\E.*\"/ or $line=~/\'\Q$op\E\'/); 800 #next if ($line=~/\".*\Q$op\E.*\"/ or $line=~/\'\Q$op\E\'/);
710 print "do not use assignment in condition\n"; 801 ERROR("do not use assignment in if condition\n" . $herecurr);
711 print "$herecurr";
712 $clean = 0;
713 } 802 }
714 803
715 # Check for }<nl>else {, these must be at the same 804 # Check for }<nl>else {, these must be at the same
716 # indent level to be relevant to each other. 805 # indent level to be relevant to each other.
717 if ($prevline=~/}\s*$/ and $line=~/^.\s*else\s*/ and 806 if ($prevline=~/}\s*$/ and $line=~/^.\s*else\s*/ and
718 $previndent == $indent) { 807 $previndent == $indent) {
719 print "else should follow close brace\n"; 808 ERROR("else should follow close brace '}'\n" . $hereprev);
720 print "$hereprev";
721 $clean = 0;
722 } 809 }
723 810
724#studly caps, commented out until figure out how to distinguish between use of existing and adding new 811#studly caps, commented out until figure out how to distinguish between use of existing and adding new
@@ -730,89 +817,85 @@ sub process {
730 817
731#no spaces allowed after \ in define 818#no spaces allowed after \ in define
732 if ($line=~/\#define.*\\\s$/) { 819 if ($line=~/\#define.*\\\s$/) {
733 print("Whitepspace after \\ makes next lines useless\n"); 820 WARN("Whitepspace after \\ makes next lines useless\n" . $herecurr);
734 print "$herecurr";
735 $clean = 0;
736 } 821 }
737 822
738#warn if <asm/foo.h> is #included and <linux/foo.h> is available. 823#warn if <asm/foo.h> is #included and <linux/foo.h> is available (uses RAW line)
739 if ($tree && $line =~ qr|\s*\#\s*include\s*\<asm\/(.*)\.h\>|) { 824 if ($tree && $rawline =~ m{^.\#\s*include\s*\<asm\/(.*)\.h\>}) {
740 my $checkfile = "include/linux/$1.h"; 825 my $checkfile = "include/linux/$1.h";
741 if (-f $checkfile) { 826 if (-f $checkfile) {
742 print "Use #include <linux/$1.h> instead of <asm/$1.h>\n"; 827 CHK("Use #include <linux/$1.h> instead of <asm/$1.h>\n" .
743 print $herecurr; 828 $herecurr);
744 $clean = 0;
745 } 829 }
746 } 830 }
747 831
748#if/while/etc brace do not go on next line, unless #defining a do while loop, or if that brace on the next line is for something else 832# if and else should not have general statements after it
749 if ($prevline=~/\b(if|while|for|switch)\s*\(/) { 833 if ($line =~ /^.\s*(?:}\s*)?else\b(.*)/ &&
750 my @opened = $prevline=~/\(/g; 834 $1 !~ /^\s*(?:\sif|{|\\|$)/) {
751 my @closed = $prevline=~/\)/g; 835 ERROR("trailing statements should be on next line\n" . $herecurr);
752 my $nr_line = $linenr; 836 }
753 my $remaining = $realcnt - 1; 837
754 my $next_line = $line; 838# multi-statement macros should be enclosed in a do while loop, grab the
755 my $extra_lines = 0; 839# first statement and ensure its the whole macro if its not enclosed
756 my $display_segment = $prevline; 840# in a known goot container
757 841 if (($prevline=~/\#define.*\\/) and
758 while ($remaining > 0 && scalar @opened > scalar @closed) { 842 !($prevline=~/do\s+{/) and !($prevline=~/\(\{/) and
759 $prevline .= $next_line; 843 !($line=~/do.*{/) and !($line=~/\(\{/) and
760 $display_segment .= "\n" . $next_line; 844 !($line=~/^.\s*$Declare\s/)) {
761 $next_line = $lines[$nr_line]; 845 # Grab the first statement, if that is the entire macro
762 $nr_line++; 846 # its ok. This may start either on the #define line
763 $remaining--; 847 # or the one below.
764 848 my $ln = $linenr;
765 @opened = $prevline=~/\(/g; 849 my $cnt = $realcnt;
766 @closed = $prevline=~/\)/g; 850
851 # If the macro starts on the define line start there.
852 if ($prevline !~ m{^.#\s*define\s*$Ident(?:\([^\)]*\))?\s*\\\s*$}) {
853 $ln--;
854 $cnt++;
767 } 855 }
768 856 my @ctx = ctx_statement($ln, $cnt);
769 if (($prevline=~/\b(if|while|for|switch)\s*\(.*\)\s*$/) and ($next_line=~/{/) and 857 my $ctx_ln = $ln + $#ctx + 1;
770 !($next_line=~/\b(if|while|for)/) and !($next_line=~/\#define.*do.*while/)) { 858 my $ctx = join("\n", @ctx);
771 print "That { should be on the previous line\n"; 859
772 print "$here\n$display_segment\n$next_line\n\n"; 860 # Pull in any empty extension lines.
773 $clean = 0; 861 while ($ctx =~ /\\$/ &&
862 $lines[$ctx_ln - 1] =~ /^.\s*(?:\\)?$/) {
863 $ctx .= $lines[$ctx_ln - 1];
864 $ctx_ln++;
774 } 865 }
775 }
776 866
777#multiline macros should be enclosed in a do while loop 867 if ($ctx =~ /\\$/) {
778 if (($prevline=~/\#define.*\\/) and !($prevline=~/do\s+{/) and 868 if ($ctx =~ /;/) {
779 !($prevline=~/\(\{/) and ($line=~/;\s*\\/) and 869 ERROR("Macros with multiple statements should be enclosed in a do - while loop\n" . "$here\n$ctx\n");
780 !($line=~/do.*{/) and !($line=~/\(\{/)) { 870 } else {
781 print "Macros with multiple statements should be enclosed in a do - while loop\n"; 871 ERROR("Macros with complex values should be enclosed in parenthesis\n" . "$here\n$ctx\n");
782 print "$hereprev"; 872 }
783 $clean = 0; 873 }
784 } 874 }
785 875
786# don't include deprecated include files 876# don't include deprecated include files (uses RAW line)
787 for my $inc (@dep_includes) { 877 for my $inc (@dep_includes) {
788 if ($line =~ m@\#\s*include\s*\<$inc>@) { 878 if ($rawline =~ m@\#\s*include\s*\<$inc>@) {
789 print "Don't use <$inc>: see Documentation/feature-removal-schedule.txt\n"; 879 ERROR("Don't use <$inc>: see Documentation/feature-removal-schedule.txt\n" . $herecurr);
790 print "$herecurr";
791 $clean = 0;
792 } 880 }
793 } 881 }
794 882
795# don't use deprecated functions 883# don't use deprecated functions
796 for my $func (@dep_functions) { 884 for my $func (@dep_functions) {
797 if ($line =~ /\b$func\b/) { 885 if ($line =~ /\b$func\b/) {
798 print "Don't use $func(): see Documentation/feature-removal-schedule.txt\n"; 886 ERROR("Don't use $func(): see Documentation/feature-removal-schedule.txt\n" . $herecurr);
799 print "$herecurr";
800 $clean = 0;
801 } 887 }
802 } 888 }
803 889
804# no volatiles please 890# no volatiles please
805 if ($line =~ /\bvolatile\b/ && $line !~ /\basm\s+volatile\b/) { 891 if ($line =~ /\bvolatile\b/ && $line !~ /\basm\s+volatile\b/) {
806 print "Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt\n"; 892 WARN("Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt\n" . $herecurr);
807 print "$herecurr";
808 $clean = 0;
809 } 893 }
810 894
811# warn about #if 0 895# warn about #if 0
812 if ($line =~ /^.#\s*if\s+0\b/) { 896 if ($line =~ /^.#\s*if\s+0\b/) {
813 print "#if 0 -- if this code redundant remove it\n"; 897 CHK("if this code is redundant consider removing it\n" .
814 print "$herecurr"; 898 $herecurr);
815 $clean = 0;
816 } 899 }
817 900
818# warn about #ifdefs in C files 901# warn about #ifdefs in C files
@@ -826,34 +909,47 @@ sub process {
826 if ($line =~ /^.\s*(struct\s+mutex|spinlock_t)\s+\S+;/) { 909 if ($line =~ /^.\s*(struct\s+mutex|spinlock_t)\s+\S+;/) {
827 my $which = $1; 910 my $which = $1;
828 if (!ctx_has_comment($first_line, $linenr)) { 911 if (!ctx_has_comment($first_line, $linenr)) {
829 print "$1 definition without comment\n"; 912 CHK("$1 definition without comment\n" . $herecurr);
830 print "$herecurr";
831 $clean = 0;
832 } 913 }
833 } 914 }
834# check for memory barriers without a comment. 915# check for memory barriers without a comment.
835 if ($line =~ /\b(mb|rmb|wmb|read_barrier_depends|smp_mb|smp_rmb|smp_wmb|smp_read_barrier_depends)\(/) { 916 if ($line =~ /\b(mb|rmb|wmb|read_barrier_depends|smp_mb|smp_rmb|smp_wmb|smp_read_barrier_depends)\(/) {
836 if (!ctx_has_comment($first_line, $linenr)) { 917 if (!ctx_has_comment($first_line, $linenr)) {
837 print "memory barrier without comment\n"; 918 CHK("memory barrier without comment\n" . $herecurr);
838 print "$herecurr";
839 $clean = 0;
840 } 919 }
841 } 920 }
842# check of hardware specific defines 921# check of hardware specific defines
843 if ($line =~ m@^.#\s*if.*\b(__i386__|__powerpc64__|__sun__|__s390x__)\b@) { 922 if ($line =~ m@^.#\s*if.*\b(__i386__|__powerpc64__|__sun__|__s390x__)\b@) {
844 print "architecture specific defines should be avoided\n"; 923 CHK("architecture specific defines should be avoided\n" . $herecurr);
845 print "$herecurr"; 924 }
846 $clean = 0; 925
926# check the location of the inline attribute, that it is between
927# storage class and type.
928 if ($line =~ /$Type\s+(?:inline|__always_inline)\b/ ||
929 $line =~ /\b(?:inline|always_inline)\s+$Storage/) {
930 ERROR("inline keyword should sit between storage class and type\n" . $herecurr);
931 }
932
933# check for new externs in .c files.
934 if ($line =~ /^.\s*extern\s/ && ($realfile =~ /\.c$/)) {
935 WARN("externs should be avoided in .c files\n" . $herecurr);
936 }
937
938# checks for new __setup's
939 if ($rawline =~ /\b__setup\("([^"]*)"/) {
940 my $name = $1;
941
942 if (!grep(/$name/, @setup_docs)) {
943 CHK("__setup appears un-documented -- check Documentation/kernel-parameters.txt\n" . $herecurr);
944 }
847 } 945 }
848 } 946 }
849 947
850 if ($chk_patch && !$is_patch) { 948 if ($chk_patch && !$is_patch) {
851 $clean = 0; 949 ERROR("Does not appear to be a unified-diff format patch\n");
852 print "Does not appear to be a unified-diff format patch\n";
853 } 950 }
854 if ($is_patch && $chk_signoff && $signoff == 0) { 951 if ($is_patch && $chk_signoff && $signoff == 0) {
855 $clean = 0; 952 ERROR("Missing Signed-off-by: line(s)\n");
856 print "Missing Signed-off-by: line(s)\n";
857 } 953 }
858 954
859 if ($clean == 1 && $quiet == 0) { 955 if ($clean == 1 && $quiet == 0) {
diff --git a/scripts/checksyscalls.sh b/scripts/checksyscalls.sh
index f98171f5a3df..0dcc01ce45a6 100755
--- a/scripts/checksyscalls.sh
+++ b/scripts/checksyscalls.sh
@@ -99,6 +99,11 @@ cat << EOF
99#define __IGNORE_setfsuid32 99#define __IGNORE_setfsuid32
100#define __IGNORE_setfsgid32 100#define __IGNORE_setfsgid32
101 101
102/* sync_file_range had a stupid ABI. Allow sync_file_range2 instead */
103#ifdef __NR_sync_file_range2
104#define __IGNORE_sync_file_range
105#endif
106
102/* Unmerged syscalls for AFS, STREAMS, etc. */ 107/* Unmerged syscalls for AFS, STREAMS, etc. */
103#define __IGNORE_afs_syscall 108#define __IGNORE_afs_syscall
104#define __IGNORE_getpmsg 109#define __IGNORE_getpmsg
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
9T=`mktemp`
10code=
11
12while read i ; do
13
14case "$i" in
15*Code:*)
16 code=$i
17 ;;
18esac
19
20done
21
22if [ -z "$code" ]; then
23 exit
24fi
25
26echo $code
27code=`echo $code | sed -e 's/.*Code: //'`
28
29marker=`expr index "$code" "\<"`
30if [ $marker -eq 0 ]; then
31 marker=`expr index "$code" "\("`
32fi
33
34if [ $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))-`
44fi
45
46code=`echo $code | sed -e 's/ [<(]/ /;s/[>)] / /;s/ /,0x/g'`
47echo -n " .byte 0x" > $T.s
48echo $code >> $T.s
49as $AFLAGS -o $T.o $T.s
50objdump -S $T.o
51rm $T.o $T.s
diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c
index 8b809b264d18..10b006694e5d 100644
--- a/scripts/kallsyms.c
+++ b/scripts/kallsyms.c
@@ -31,7 +31,7 @@
31#include <string.h> 31#include <string.h>
32#include <ctype.h> 32#include <ctype.h>
33 33
34#define KSYM_NAME_LEN 127 34#define KSYM_NAME_LEN 128
35 35
36 36
37struct sym_entry { 37struct sym_entry {
@@ -254,7 +254,7 @@ static void write_src(void)
254 unsigned int i, k, off; 254 unsigned int i, k, off;
255 unsigned int best_idx[256]; 255 unsigned int best_idx[256];
256 unsigned int *markers; 256 unsigned int *markers;
257 char buf[KSYM_NAME_LEN+1]; 257 char buf[KSYM_NAME_LEN];
258 258
259 printf("#include <asm/types.h>\n"); 259 printf("#include <asm/types.h>\n");
260 printf("#if BITS_PER_LONG == 64\n"); 260 printf("#if BITS_PER_LONG == 64\n");