aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xscripts/checkpatch.pl274
1 files changed, 193 insertions, 81 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 39339529b99b..aea90d30d229 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1,14 +1,15 @@
1#!/usr/bin/perl -w 1#!/usr/bin/perl -w
2# (c) 2001, Dave Jones. <davej@codemonkey.org.uk> (the file handling bit) 2# (c) 2001, Dave Jones. <davej@codemonkey.org.uk> (the file handling bit)
3# (c) 2005, Joel Scohpp <jschopp@austin.ibm.com> (the ugly bit) 3# (c) 2005, Joel Schopp <jschopp@austin.ibm.com> (the ugly bit)
4# (c) 2007, Andy Whitcroft <apw@uk.ibm.com> (new conditions, test suite, etc) 4# (c) 2007, Andy Whitcroft <apw@uk.ibm.com> (new conditions, test suite, etc)
5# Licensed under the terms of the GNU GPL License version 2 5# Licensed under the terms of the GNU GPL License version 2
6 6
7use strict; 7use strict;
8 8
9my $P = $0; 9my $P = $0;
10$P =~ s@.*/@@g;
10 11
11my $V = '0.03'; 12my $V = '0.04';
12 13
13use Getopt::Long qw(:config no_auto_abbrev); 14use Getopt::Long qw(:config no_auto_abbrev);
14 15
@@ -26,7 +27,7 @@ GetOptions(
26my $exit = 0; 27my $exit = 0;
27 28
28if ($#ARGV < 0) { 29if ($#ARGV < 0) {
29 print "usage: patchstylecheckemail.pl [options] patchfile\n"; 30 print "usage: $P [options] patchfile\n";
30 print "version: $V\n"; 31 print "version: $V\n";
31 print "options: -q => quiet\n"; 32 print "options: -q => quiet\n";
32 print " --no-tree => run without a kernel tree\n"; 33 print " --no-tree => run without a kernel tree\n";
@@ -59,15 +60,15 @@ if ($tree && -f $removal) {
59 } 60 }
60} 61}
61 62
62my @lines = (); 63my @rawlines = ();
63while (<>) { 64while (<>) {
64 chomp; 65 chomp;
65 push(@lines, $_); 66 push(@rawlines, $_);
66 if (eof(ARGV)) { 67 if (eof(ARGV)) {
67 if (!process($ARGV, @lines)) { 68 if (!process($ARGV, @rawlines)) {
68 $exit = 1; 69 $exit = 1;
69 } 70 }
70 @lines = (); 71 @rawlines = ();
71 } 72 }
72} 73}
73 74
@@ -118,24 +119,57 @@ sub line_stats {
118 return (length($line), length($white)); 119 return (length($line), length($white));
119} 120}
120 121
122sub sanitise_line {
123 my ($line) = @_;
124
125 my $res = '';
126 my $l = '';
127
128 my $quote = '';
129
130 foreach my $c (split(//, $line)) {
131 if ($l ne "\\" && ($c eq "'" || $c eq '"')) {
132 if ($quote eq '') {
133 $quote = $c;
134 $res .= $c;
135 $l = $c;
136 next;
137 } elsif ($quote eq $c) {
138 $quote = '';
139 }
140 }
141 if ($quote && $c ne "\t") {
142 $res .= "X";
143 } else {
144 $res .= $c;
145 }
146
147 $l = $c;
148 }
149
150 return $res;
151}
152
121sub ctx_block_get { 153sub ctx_block_get {
122 my ($linenr, $remain, $outer) = @_; 154 my ($linenr, $remain, $outer) = @_;
123 my $line; 155 my $line;
124 my $start = $linenr - 1; 156 my $start = $linenr - 1;
125 my $end = $linenr - 1 + $remain;
126 my $blk = ''; 157 my $blk = '';
127 my @o; 158 my @o;
128 my @c; 159 my @c;
129 my @res = (); 160 my @res = ();
130 161
131 for ($line = $start; $line < $end; $line++) { 162 for ($line = $start; $remain > 0; $line++) {
132 $blk .= $lines[$line]; 163 next if ($rawlines[$line] =~ /^-/);
164 $remain--;
165
166 $blk .= $rawlines[$line];
133 167
134 @o = ($blk =~ /\{/g); 168 @o = ($blk =~ /\{/g);
135 @c = ($blk =~ /\}/g); 169 @c = ($blk =~ /\}/g);
136 170
137 if (!$outer || (scalar(@o) - scalar(@c)) == 1) { 171 if (!$outer || (scalar(@o) - scalar(@c)) == 1) {
138 push(@res, $lines[$line]); 172 push(@res, $rawlines[$line]);
139 } 173 }
140 174
141 last if (scalar(@o) == scalar(@c)); 175 last if (scalar(@o) == scalar(@c));
@@ -158,7 +192,7 @@ sub ctx_locate_comment {
158 my ($first_line, $end_line) = @_; 192 my ($first_line, $end_line) = @_;
159 193
160 # Catch a comment on the end of the line itself. 194 # Catch a comment on the end of the line itself.
161 my ($current_comment) = ($lines[$end_line - 1] =~ m@.*(/\*.*\*/)\s*$@); 195 my ($current_comment) = ($rawlines[$end_line - 1] =~ m@.*(/\*.*\*/)\s*$@);
162 return $current_comment if (defined $current_comment); 196 return $current_comment if (defined $current_comment);
163 197
164 # Look through the context and try and figure out if there is a 198 # Look through the context and try and figure out if there is a
@@ -166,8 +200,8 @@ sub ctx_locate_comment {
166 my $in_comment = 0; 200 my $in_comment = 0;
167 $current_comment = ''; 201 $current_comment = '';
168 for (my $linenr = $first_line; $linenr < $end_line; $linenr++) { 202 for (my $linenr = $first_line; $linenr < $end_line; $linenr++) {
169 my $line = $lines[$linenr - 1]; 203 my $line = $rawlines[$linenr - 1];
170 ##warn " $line\n"; 204 #warn " $line\n";
171 if ($linenr == $first_line and $line =~ m@^.\s*\*@) { 205 if ($linenr == $first_line and $line =~ m@^.\s*\*@) {
172 $in_comment = 1; 206 $in_comment = 1;
173 } 207 }
@@ -190,7 +224,7 @@ sub ctx_has_comment {
190 my ($first_line, $end_line) = @_; 224 my ($first_line, $end_line) = @_;
191 my $cmt = ctx_locate_comment($first_line, $end_line); 225 my $cmt = ctx_locate_comment($first_line, $end_line);
192 226
193 ##print "LINE: $lines[$end_line - 1 ]\n"; 227 ##print "LINE: $rawlines[$end_line - 1 ]\n";
194 ##print "CMMT: $cmt\n"; 228 ##print "CMMT: $cmt\n";
195 229
196 return ($cmt ne ''); 230 return ($cmt ne '');
@@ -205,10 +239,6 @@ sub cat_vet {
205 return $vet; 239 return $vet;
206} 240}
207 241
208sub has_non_quoted {
209 return ($_[0] =~ m{$_[1]} and $_[0] !~ m{\".*$_[1].*\"});
210}
211
212sub process { 242sub process {
213 my $filename = shift; 243 my $filename = shift;
214 my @lines = @_; 244 my @lines = @_;
@@ -240,6 +270,7 @@ sub process {
240#extract the filename as it passes 270#extract the filename as it passes
241 if ($line=~/^\+\+\+\s+(\S+)/) { 271 if ($line=~/^\+\+\+\s+(\S+)/) {
242 $realfile=$1; 272 $realfile=$1;
273 $realfile =~ s@^[^/]*/@@;
243 $in_comment = 0; 274 $in_comment = 0;
244 next; 275 next;
245 } 276 }
@@ -262,7 +293,6 @@ sub process {
262# blank context lines so we need to count that too. 293# blank context lines so we need to count that too.
263 if ($line =~ /^( |\+|$)/) { 294 if ($line =~ /^( |\+|$)/) {
264 $realline++; 295 $realline++;
265 $realcnt-- if ($realcnt != 0);
266 296
267 # track any sort of multi-line comment. Obviously if 297 # track any sort of multi-line comment. Obviously if
268 # the added text or context do not include the whole 298 # the added text or context do not include the whole
@@ -288,11 +318,13 @@ sub process {
288 ($prevline, $stashline) = ($stashline, $line); 318 ($prevline, $stashline) = ($stashline, $line);
289 ($previndent, $stashindent) = ($stashindent, $indent); 319 ($previndent, $stashindent) = ($stashindent, $indent);
290 } 320 }
321 $realcnt-- if ($realcnt != 0);
291 322
292#make up the handle for any error we report on this line 323#make up the handle for any error we report on this line
293 $here = "#$linenr: "; 324 $here = "#$linenr: ";
294 $here .= "FILE: $realfile:$realline:" if ($realcnt != 0); 325 $here .= "FILE: $realfile:$realline:" if ($realcnt != 0);
295 326
327 my $hereline = "$here\n$line\n";
296 my $herecurr = "$here\n$line\n\n"; 328 my $herecurr = "$here\n$line\n\n";
297 my $hereprev = "$here\n$prevline\n$line\n\n"; 329 my $hereprev = "$here\n$prevline\n$line\n\n";
298 330
@@ -315,21 +347,28 @@ sub process {
315 } 347 }
316 } 348 }
317 349
318#ignore lines not being added 350# Check for wrappage within a valid hunk of the file
319 if ($line=~/^[^\+]/) {next;} 351 if ($realcnt != 0 && $line !~ m{^(?:\+|-| |$)}) {
352 print "patch seems to be corrupt (line wrapped?) [$realcnt]\n";
353 print "$herecurr";
354 $clean = 0;
355 }
356
357#ignore lines being removed
358 if ($line=~/^-/) {next;}
320 359
321# check we are in a valid source file *.[hcsS] if not then ignore this hunk 360# check we are in a valid source file if not then ignore this hunk
322 next if ($realfile !~ /\.[hcsS]$/); 361 next if ($realfile !~ /\.(h|c|s|S|pl|sh)$/);
323 362
324#trailing whitespace 363#trailing whitespace
325 if ($line=~/\S\s+$/) { 364 if ($line=~/\+.*\S\s+$/) {
326 my $herevet = "$here\n" . cat_vet($line) . "\n\n"; 365 my $herevet = "$here\n" . cat_vet($line) . "\n\n";
327 print "trailing whitespace\n"; 366 print "trailing whitespace\n";
328 print "$herevet"; 367 print "$herevet";
329 $clean = 0; 368 $clean = 0;
330 } 369 }
331#80 column limit 370#80 column limit
332 if (!($prevline=~/\/\*\*/) && $length > 80) { 371 if ($line =~ /^\+/ && !($prevline=~/\/\*\*/) && $length > 80) {
333 print "line over 80 characters\n"; 372 print "line over 80 characters\n";
334 print "$herecurr"; 373 print "$herecurr";
335 $clean = 0; 374 $clean = 0;
@@ -353,19 +392,59 @@ sub process {
353 # 392 #
354 next if ($in_comment); 393 next if ($in_comment);
355 394
395 # Remove comments from the line before processing.
396 $line =~ s@/\*.*\*/@@g;
397 $line =~ s@/\*.*@@;
398 $line =~ s@.*\*/@@;
399
400 #
401 # Checks which may be anchored in the context.
402 #
403
404 # Check for switch () and associated case and default
405 # statements should be at the same indent.
406 if ($line=~/\bswitch\s*\(.*\)/) {
407 my $err = '';
408 my $sep = '';
409 my @ctx = ctx_block_outer($linenr, $realcnt);
410 shift(@ctx);
411 for my $ctx (@ctx) {
412 my ($clen, $cindent) = line_stats($ctx);
413 if ($ctx =~ /^\+\s*(case\s+|default:)/ &&
414 $indent != $cindent) {
415 $err .= "$sep$ctx\n";
416 $sep = '';
417 } else {
418 $sep = "[...]\n";
419 }
420 }
421 if ($err ne '') {
422 print "switch and case should be at the same indent\n";
423 print "$here\n$line\n$err\n";
424 $clean = 0;
425 }
426 }
427
428#ignore lines not being added
429 if ($line=~/^[^\+]/) {next;}
430
431 #
432 # Checks which are anchored on the added line.
433 #
434
356# no C99 // comments 435# no C99 // comments
357 if (has_non_quoted($line, '//')) { 436 if ($line =~ m{//}) {
358 print "do not use C99 // comments\n"; 437 print "do not use C99 // comments\n";
359 print "$herecurr"; 438 print "$herecurr";
360 $clean = 0; 439 $clean = 0;
361 } 440 }
362 441 # Remove C99 comments.
363 # Remove comments from the line before processing.
364 $line =~ s@/\*.*\*/@@g;
365 $line =~ s@/\*.*@@;
366 $line =~ s@.*\*/@@;
367 $line =~ s@//.*@@; 442 $line =~ s@//.*@@;
368 443
444 # Standardise the strings and chars within the input
445 # to simplify matching.
446 $line = sanitise_line($line);
447
369#EXPORT_SYMBOL should immediately follow its function closing }. 448#EXPORT_SYMBOL should immediately follow its function closing }.
370 if (($line =~ /EXPORT_SYMBOL.*\(.*\)/) || 449 if (($line =~ /EXPORT_SYMBOL.*\(.*\)/) ||
371 ($line =~ /EXPORT_UNUSED_SYMBOL.*\(.*\)/)) { 450 ($line =~ /EXPORT_UNUSED_SYMBOL.*\(.*\)/)) {
@@ -393,8 +472,28 @@ sub process {
393 } 472 }
394 473
395# * goes on variable not on type 474# * goes on variable not on type
396 if ($line=~/[A-Za-z\d_]+\* [A-Za-z\d_]+/) { 475 my $type = '(?:char|short|int|long|unsigned|float|double|' .
397 print "\"foo* bar\" should be \"foo *bar\"\n"; 476 'struct\s+[A-Za-z\d_]+|' .
477 'union\s+[A-Za-z\d_]+)';
478
479 if ($line =~ m{[A-Za-z\d_]+(\*+) [A-Za-z\d_]+}) {
480 print "\"foo$1 bar\" should be \"foo $1bar\"\n";
481 print "$herecurr";
482 $clean = 0;
483 }
484 if ($line =~ m{$type (\*) [A-Za-z\d_]+} ||
485 $line =~ m{[A-Za-z\d_]+ (\*\*+) [A-Za-z\d_]+}) {
486 print "\"foo $1 bar\" should be \"foo $1bar\"\n";
487 print "$herecurr";
488 $clean = 0;
489 }
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";
398 print "$herecurr"; 497 print "$herecurr";
399 $clean = 0; 498 $clean = 0;
400 } 499 }
@@ -406,11 +505,29 @@ sub process {
406# $clean = 0; 505# $clean = 0;
407# } 506# }
408 507
409# printk should use KERN_* levels 508# printk should use KERN_* levels. Note that follow on printk's on the
509# same line do not need a level, so we use the current block context
510# to try and find and validate the current printk. In summary the current
511# printk includes all preceeding printk's which have no newline on the end.
512# we assume the first bad printk is the one to report.
410 if ($line =~ /\bprintk\((?!KERN_)/) { 513 if ($line =~ /\bprintk\((?!KERN_)/) {
411 print "printk() should include KERN_ facility level\n"; 514 my $ok = 0;
412 print "$herecurr"; 515 for (my $ln = $linenr - 1; $ln >= $first_line; $ln--) {
413 $clean = 0; 516 #print "CHECK<$lines[$ln - 1]\n";
517 # we have a preceeding printk if it ends
518 # with "\n" ignore it, else it is to blame
519 if ($lines[$ln - 1] =~ m{\bprintk\(}) {
520 if ($rawlines[$ln - 1] !~ m{\\n"}) {
521 $ok = 1;
522 }
523 last;
524 }
525 }
526 if ($ok == 0) {
527 print "printk() should include KERN_ facility level\n";
528 print "$herecurr";
529 $clean = 0;
530 }
414 } 531 }
415 532
416#function brace can't be on same line, except for #defines of do while, or if closed on same line 533#function brace can't be on same line, except for #defines of do while, or if closed on same line
@@ -425,11 +542,11 @@ sub process {
425 # will therefore also expand that way. 542 # will therefore also expand that way.
426 my $opline = $line; 543 my $opline = $line;
427 $opline = expand_tabs($opline); 544 $opline = expand_tabs($opline);
428 $opline =~ s/^.//; 545 $opline =~ s/^./ /;
429 if (!($line=~/\#\s*include/)) { 546 if (!($line=~/\#\s*include/)) {
430 # Check operator spacing. 547 # Check operator spacing.
431 my @elements = split(/(<<=|>>=|<=|>=|==|!=|\+=|-=|\*=|\/=|%=|\^=|\|=|&=|->|<<|>>|<|>|=|!|~|&&|\|\||,|\^|\+\+|--|;|&|\||\+|-|\*|\/\/|\/)/, $opline); 548 my @elements = split(/(<<=|>>=|<=|>=|==|!=|\+=|-=|\*=|\/=|%=|\^=|\|=|&=|->|<<|>>|<|>|=|!|~|&&|\|\||,|\^|\+\+|--|;|&|\||\+|-|\*|\/\/|\/)/, $opline);
432 my $off = 1; 549 my $off = 0;
433 for (my $n = 0; $n < $#elements; $n += 2) { 550 for (my $n = 0; $n < $#elements; $n += 2) {
434 $off += length($elements[$n]); 551 $off += length($elements[$n]);
435 552
@@ -452,16 +569,21 @@ sub process {
452 $c = 'E'; 569 $c = 'E';
453 } 570 }
454 571
572 # Pick up the preceeding and succeeding characters.
573 my $ca = substr($opline, $off - 1, 1);
574 my $cc = '';
575 if (length($opline) > ($off + length($elements[$n]))) {
576 $cc = substr($opline, $off + 1 + length($elements[$n]), 1);
577 }
578
455 my $ctx = "${a}x${c}"; 579 my $ctx = "${a}x${c}";
456 580
457 my $at = "(ctx:$ctx)"; 581 my $at = "(ctx:$ctx)";
458 582
459 my $ptr = (" " x $off) . "^"; 583 my $ptr = (" " x $off) . "^";
460 my $hereptr = "$here\n$line\n$ptr\n\n"; 584 my $hereptr = "$hereline$ptr\n\n";
461 585
462 ##print "<$s1:$op:$s2> <$elements[$n]:$elements[$n + 1]:$elements[$n + 2]>\n"; 586 ##print "<$s1:$op:$s2> <$elements[$n]:$elements[$n + 1]:$elements[$n + 2]>\n";
463 # Skip things apparently in quotes.
464 next if ($line=~/\".*\Q$op\E.*\"/ or $line=~/\'\Q$op\E\'/);
465 587
466 # We need ; as an operator. // is a comment. 588 # We need ; as an operator. // is a comment.
467 if ($op eq ';' or $op eq '//') { 589 if ($op eq ';' or $op eq '//') {
@@ -515,20 +637,26 @@ sub process {
515 # 637 #
516 # - is the same 638 # - is the same
517 # 639 #
518 # * is the same only adding:
519 # type:
520 # (foo *)
521 # (foo **)
522 #
523 } elsif ($op eq '&' or $op eq '-') { 640 } elsif ($op eq '&' or $op eq '-') {
524 if ($ctx !~ /VxV|[EWB]x[WE]|[EWB]x[VO]/) { 641 if ($ctx !~ /VxV|[EW]x[WE]|[EWB]x[VO]/) {
525 print "need space before that '$op' $at\n"; 642 print "need space before that '$op' $at\n";
526 print "$hereptr"; 643 print "$hereptr";
527 $clean = 0; 644 $clean = 0;
528 } 645 }
529 646
647 # * is the same as & only adding:
648 # type:
649 # (foo *)
650 # (foo **)
651 #
530 } elsif ($op eq '*') { 652 } elsif ($op eq '*') {
531 if ($ctx !~ /VxV|[EWB]x[WE]|[EWB]x[VO]|[EWO]x[OBV]/) { 653 if ($ca eq '*') {
654 if ($cc =~ /\s/) {
655 print "no space after that '$op' $at\n";
656 print "$hereptr";
657 $clean = 0;
658 }
659 } elsif ($ctx !~ /VxV|[EW]x[WE]|[EWB]x[VO]|OxV|WxB/) {
532 print "need space before that '$op' $at\n"; 660 print "need space before that '$op' $at\n";
533 print "$hereptr"; 661 print "$hereptr";
534 $clean = 0; 662 $clean = 0;
@@ -578,6 +706,7 @@ sub process {
578 706
579# Check for illegal assignment in if conditional. 707# Check for illegal assignment in if conditional.
580 if ($line=~/\b(if|while)\s*\(.*[^<>!=]=[^=].*\)/) { 708 if ($line=~/\b(if|while)\s*\(.*[^<>!=]=[^=].*\)/) {
709 #next if ($line=~/\".*\Q$op\E.*\"/ or $line=~/\'\Q$op\E\'/);
581 print "do not use assignment in condition\n"; 710 print "do not use assignment in condition\n";
582 print "$herecurr"; 711 print "$herecurr";
583 $clean = 0; 712 $clean = 0;
@@ -592,30 +721,6 @@ sub process {
592 $clean = 0; 721 $clean = 0;
593 } 722 }
594 723
595 # Check for switch () and associated case and default
596 # statements should be at the same indent.
597 if ($line=~/\bswitch\s*\(.*\)/) {
598 my $err = '';
599 my $sep = '';
600 my @ctx = ctx_block_outer($linenr, $realcnt);
601 shift(@ctx);
602 for my $ctx (@ctx) {
603 my ($clen, $cindent) = line_stats($ctx);
604 if ($ctx =~ /\s*(case\s+|default:)/ &&
605 $indent != $cindent) {
606 $err .= "$sep$ctx\n";
607 $sep = '';
608 } else {
609 $sep = "[...]\n";
610 }
611 }
612 if ($err ne '') {
613 print "switch and case should be at the same indent\n";
614 print "$here\n$line\n$err\n";
615 $clean = 0;
616 }
617 }
618
619#studly caps, commented out until figure out how to distinguish between use of existing and adding new 724#studly caps, commented out until figure out how to distinguish between use of existing and adding new
620# if (($line=~/[\w_][a-z\d]+[A-Z]/) and !($line=~/print/)) { 725# if (($line=~/[\w_][a-z\d]+[A-Z]/) and !($line=~/print/)) {
621# print "No studly caps, use _\n"; 726# print "No studly caps, use _\n";
@@ -645,12 +750,12 @@ sub process {
645 my @opened = $prevline=~/\(/g; 750 my @opened = $prevline=~/\(/g;
646 my @closed = $prevline=~/\)/g; 751 my @closed = $prevline=~/\)/g;
647 my $nr_line = $linenr; 752 my $nr_line = $linenr;
648 my $remaining = $realcnt; 753 my $remaining = $realcnt - 1;
649 my $next_line = $line; 754 my $next_line = $line;
650 my $extra_lines = 0; 755 my $extra_lines = 0;
651 my $display_segment = $prevline; 756 my $display_segment = $prevline;
652 757
653 while ($remaining > 1 && scalar @opened > scalar @closed) { 758 while ($remaining > 0 && scalar @opened > scalar @closed) {
654 $prevline .= $next_line; 759 $prevline .= $next_line;
655 $display_segment .= "\n" . $next_line; 760 $display_segment .= "\n" . $next_line;
656 $next_line = $lines[$nr_line]; 761 $next_line = $lines[$nr_line];
@@ -689,7 +794,7 @@ sub process {
689 794
690# don't use deprecated functions 795# don't use deprecated functions
691 for my $func (@dep_functions) { 796 for my $func (@dep_functions) {
692 if (has_non_quoted($line, '\b' . $func . '\b')) { 797 if ($line =~ /\b$func\b/) {
693 print "Don't use $func(): see Documentation/feature-removal-schedule.txt\n"; 798 print "Don't use $func(): see Documentation/feature-removal-schedule.txt\n";
694 print "$herecurr"; 799 print "$herecurr";
695 $clean = 0; 800 $clean = 0;
@@ -697,19 +802,26 @@ sub process {
697 } 802 }
698 803
699# no volatiles please 804# no volatiles please
700 if (has_non_quoted($line, '\bvolatile\b')) { 805 if ($line =~ /\bvolatile\b/ && $line !~ /\basm\s+volatile\b/) {
701 print "Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt\n"; 806 print "Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt\n";
702 print "$herecurr"; 807 print "$herecurr";
703 $clean = 0; 808 $clean = 0;
704 } 809 }
705 810
706# warn about #ifdefs in C files 811# warn about #if 0
707 if ($line =~ /^.#\s*if(|n)def/ && ($realfile =~ /\.c$/)) { 812 if ($line =~ /^.#\s*if\s+0\b/) {
708 print "#ifdef in C files should be avoided\n"; 813 print "#if 0 -- if this code redundant remove it\n";
709 print "$herecurr"; 814 print "$herecurr";
710 $clean = 0; 815 $clean = 0;
711 } 816 }
712 817
818# warn about #ifdefs in C files
819# if ($line =~ /^.#\s*if(|n)def/ && ($realfile =~ /\.c$/)) {
820# print "#ifdef in C files should be avoided\n";
821# print "$herecurr";
822# $clean = 0;
823# }
824
713# check for spinlock_t definitions without a comment. 825# check for spinlock_t definitions without a comment.
714 if ($line =~ /^.\s*(struct\s+mutex|spinlock_t)\s+\S+;/) { 826 if ($line =~ /^.\s*(struct\s+mutex|spinlock_t)\s+\S+;/) {
715 my $which = $1; 827 my $which = $1;