blob: 277c32647f36d84dc805efcd33f7ac1449a31ed1 [file] [log] [blame]
Andy Whitcroft0a920b52007-06-01 00:46:48 -07001#!/usr/bin/perl -w
2# (c) 2001, Dave Jones. <davej@codemonkey.org.uk> (the file handling bit)
Andy Whitcroft00df3442007-06-08 13:47:06 -07003# (c) 2005, Joel Schopp <jschopp@austin.ibm.com> (the ugly bit)
Andy Whitcroft0a920b52007-06-01 00:46:48 -07004# (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
6
7use strict;
8
9my $P = $0;
Andy Whitcroft00df3442007-06-08 13:47:06 -070010$P =~ s@.*/@@g;
Andy Whitcroft0a920b52007-06-01 00:46:48 -070011
Andy Whitcroftd8aaf122007-06-23 17:16:44 -070012my $V = '0.06';
Andy Whitcroft0a920b52007-06-01 00:46:48 -070013
14use Getopt::Long qw(:config no_auto_abbrev);
15
16my $quiet = 0;
17my $tree = 1;
18my $chk_signoff = 1;
19my $chk_patch = 1;
Andy Whitcroft653d4872007-06-23 17:16:34 -070020my $tst_type = 0;
Andy Whitcroft0a920b52007-06-01 00:46:48 -070021GetOptions(
22 'q|quiet' => \$quiet,
23 'tree!' => \$tree,
24 'signoff!' => \$chk_signoff,
25 'patch!' => \$chk_patch,
Andy Whitcroft653d4872007-06-23 17:16:34 -070026 'test-type!' => \$tst_type,
Andy Whitcroft0a920b52007-06-01 00:46:48 -070027) or exit;
28
29my $exit = 0;
30
31if ($#ARGV < 0) {
Andy Whitcroft00df3442007-06-08 13:47:06 -070032 print "usage: $P [options] patchfile\n";
Andy Whitcroft0a920b52007-06-01 00:46:48 -070033 print "version: $V\n";
34 print "options: -q => quiet\n";
35 print " --no-tree => run without a kernel tree\n";
36 exit(1);
37}
38
39if ($tree && !top_of_kernel_tree()) {
40 print "Must be run from the top-level dir. of a kernel tree\n";
41 exit(2);
42}
43
Andy Whitcroft4a0df2e2007-06-08 13:46:39 -070044my @dep_includes = ();
45my @dep_functions = ();
Andy Whitcroft0a920b52007-06-01 00:46:48 -070046my $removal = 'Documentation/feature-removal-schedule.txt';
47if ($tree && -f $removal) {
48 open(REMOVE, "<$removal") || die "$P: $removal: open failed - $!\n";
49 while (<REMOVE>) {
50 if (/^Files:\s+(.*\S)/) {
51 for my $file (split(/[, ]+/, $1)) {
52 if ($file =~ m@include/(.*)@) {
Andy Whitcroft4a0df2e2007-06-08 13:46:39 -070053 push(@dep_includes, $1);
Andy Whitcroft0a920b52007-06-01 00:46:48 -070054 }
55 }
Andy Whitcroft4a0df2e2007-06-08 13:46:39 -070056
57 } elsif (/^Funcs:\s+(.*\S)/) {
58 for my $func (split(/[, ]+/, $1)) {
59 push(@dep_functions, $func);
60 }
Andy Whitcroft0a920b52007-06-01 00:46:48 -070061 }
62 }
63}
64
Andy Whitcroft00df3442007-06-08 13:47:06 -070065my @rawlines = ();
Andy Whitcroft0a920b52007-06-01 00:46:48 -070066while (<>) {
67 chomp;
Andy Whitcroft00df3442007-06-08 13:47:06 -070068 push(@rawlines, $_);
Andy Whitcroft0a920b52007-06-01 00:46:48 -070069 if (eof(ARGV)) {
Andy Whitcroft00df3442007-06-08 13:47:06 -070070 if (!process($ARGV, @rawlines)) {
Andy Whitcroft0a920b52007-06-01 00:46:48 -070071 $exit = 1;
72 }
Andy Whitcroft00df3442007-06-08 13:47:06 -070073 @rawlines = ();
Andy Whitcroft0a920b52007-06-01 00:46:48 -070074 }
75}
76
77exit($exit);
78
79sub top_of_kernel_tree {
80 if ((-f "COPYING") && (-f "CREDITS") && (-f "Kbuild") &&
81 (-f "MAINTAINERS") && (-f "Makefile") && (-f "README") &&
82 (-d "Documentation") && (-d "arch") && (-d "include") &&
83 (-d "drivers") && (-d "fs") && (-d "init") && (-d "ipc") &&
84 (-d "kernel") && (-d "lib") && (-d "scripts")) {
85 return 1;
86 }
87 return 0;
88}
89
90sub expand_tabs {
91 my ($str) = @_;
92
93 my $res = '';
94 my $n = 0;
95 for my $c (split(//, $str)) {
96 if ($c eq "\t") {
97 $res .= ' ';
98 $n++;
99 for (; ($n % 8) != 0; $n++) {
100 $res .= ' ';
101 }
102 next;
103 }
104 $res .= $c;
105 $n++;
106 }
107
108 return $res;
109}
110
Andy Whitcroft4a0df2e2007-06-08 13:46:39 -0700111sub line_stats {
112 my ($line) = @_;
113
114 # Drop the diff line leader and expand tabs
115 $line =~ s/^.//;
116 $line = expand_tabs($line);
117
118 # Pick the indent from the front of the line.
119 my ($white) = ($line =~ /^(\s*)/);
120
121 return (length($line), length($white));
122}
123
Andy Whitcroft00df3442007-06-08 13:47:06 -0700124sub sanitise_line {
125 my ($line) = @_;
126
127 my $res = '';
128 my $l = '';
129
130 my $quote = '';
131
132 foreach my $c (split(//, $line)) {
133 if ($l ne "\\" && ($c eq "'" || $c eq '"')) {
134 if ($quote eq '') {
135 $quote = $c;
136 $res .= $c;
137 $l = $c;
138 next;
139 } elsif ($quote eq $c) {
140 $quote = '';
141 }
142 }
143 if ($quote && $c ne "\t") {
144 $res .= "X";
145 } else {
146 $res .= $c;
147 }
148
149 $l = $c;
150 }
151
152 return $res;
153}
154
Andy Whitcroft4a0df2e2007-06-08 13:46:39 -0700155sub ctx_block_get {
Andy Whitcroft653d4872007-06-23 17:16:34 -0700156 my ($linenr, $remain, $outer, $open, $close) = @_;
Andy Whitcroft4a0df2e2007-06-08 13:46:39 -0700157 my $line;
158 my $start = $linenr - 1;
Andy Whitcroft4a0df2e2007-06-08 13:46:39 -0700159 my $blk = '';
160 my @o;
161 my @c;
162 my @res = ();
163
Andy Whitcroft00df3442007-06-08 13:47:06 -0700164 for ($line = $start; $remain > 0; $line++) {
165 next if ($rawlines[$line] =~ /^-/);
166 $remain--;
167
168 $blk .= $rawlines[$line];
Andy Whitcroft4a0df2e2007-06-08 13:46:39 -0700169
Andy Whitcroft653d4872007-06-23 17:16:34 -0700170 @o = ($blk =~ /$open/g);
171 @c = ($blk =~ /$close/g);
Andy Whitcroft4a0df2e2007-06-08 13:46:39 -0700172
173 if (!$outer || (scalar(@o) - scalar(@c)) == 1) {
Andy Whitcroft00df3442007-06-08 13:47:06 -0700174 push(@res, $rawlines[$line]);
Andy Whitcroft4a0df2e2007-06-08 13:46:39 -0700175 }
176
177 last if (scalar(@o) == scalar(@c));
178 }
179
180 return @res;
181}
182sub ctx_block_outer {
183 my ($linenr, $remain) = @_;
184
Andy Whitcroft653d4872007-06-23 17:16:34 -0700185 return ctx_block_get($linenr, $remain, 1, '\{', '\}');
Andy Whitcroft4a0df2e2007-06-08 13:46:39 -0700186}
187sub ctx_block {
188 my ($linenr, $remain) = @_;
189
Andy Whitcroft653d4872007-06-23 17:16:34 -0700190 return ctx_block_get($linenr, $remain, 0, '\{', '\}');
191}
192sub ctx_statement {
193 my ($linenr, $remain) = @_;
194
195 return ctx_block_get($linenr, $remain, 0, '\(', '\)');
Andy Whitcroft4a0df2e2007-06-08 13:46:39 -0700196}
197
198sub ctx_locate_comment {
199 my ($first_line, $end_line) = @_;
200
201 # Catch a comment on the end of the line itself.
Andy Whitcroft00df3442007-06-08 13:47:06 -0700202 my ($current_comment) = ($rawlines[$end_line - 1] =~ m@.*(/\*.*\*/)\s*$@);
Andy Whitcroft4a0df2e2007-06-08 13:46:39 -0700203 return $current_comment if (defined $current_comment);
204
205 # Look through the context and try and figure out if there is a
206 # comment.
207 my $in_comment = 0;
208 $current_comment = '';
209 for (my $linenr = $first_line; $linenr < $end_line; $linenr++) {
Andy Whitcroft00df3442007-06-08 13:47:06 -0700210 my $line = $rawlines[$linenr - 1];
211 #warn " $line\n";
Andy Whitcroft4a0df2e2007-06-08 13:46:39 -0700212 if ($linenr == $first_line and $line =~ m@^.\s*\*@) {
213 $in_comment = 1;
214 }
215 if ($line =~ m@/\*@) {
216 $in_comment = 1;
217 }
218 if (!$in_comment && $current_comment ne '') {
219 $current_comment = '';
220 }
221 $current_comment .= $line . "\n" if ($in_comment);
222 if ($line =~ m@\*/@) {
223 $in_comment = 0;
224 }
225 }
226
227 chomp($current_comment);
228 return($current_comment);
229}
230sub ctx_has_comment {
231 my ($first_line, $end_line) = @_;
232 my $cmt = ctx_locate_comment($first_line, $end_line);
233
Andy Whitcroft00df3442007-06-08 13:47:06 -0700234 ##print "LINE: $rawlines[$end_line - 1 ]\n";
Andy Whitcroft4a0df2e2007-06-08 13:46:39 -0700235 ##print "CMMT: $cmt\n";
236
237 return ($cmt ne '');
238}
239
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700240sub cat_vet {
241 my ($vet) = @_;
242
243 $vet =~ s/\t/^I/;
244 $vet =~ s/$/\$/;
245
246 return $vet;
247}
248
249sub process {
250 my $filename = shift;
251 my @lines = @_;
252
253 my $linenr=0;
254 my $prevline="";
255 my $stashline="";
256
Andy Whitcroft4a0df2e2007-06-08 13:46:39 -0700257 my $length;
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700258 my $indent;
259 my $previndent=0;
260 my $stashindent=0;
261
262 my $clean = 1;
263 my $signoff = 0;
264 my $is_patch = 0;
265
266 # Trace the real file/line as we go.
267 my $realfile = '';
268 my $realline = 0;
269 my $realcnt = 0;
270 my $here = '';
271 my $in_comment = 0;
272 my $first_line = 0;
273
Andy Whitcroftd8aaf122007-06-23 17:16:44 -0700274 my $Ident = qr{[A-Za-z\d_]+};
275 my $Storage = qr{extern|static};
276 my $Sparse = qr{__user|__kernel|__force|__iomem};
277 my $NonptrType = qr{
278 \b
279 (?:const\s+)?
280 (?:unsigned\s+)?
281 (?:
282 void|
283 char|
284 short|
285 int|
286 long|
287 unsigned|
288 float|
289 double|
290 long\s+int|
291 long\s+long|
292 long\s+long\s+int|
293 struct\s+$Ident|
294 union\s+$Ident|
295 ${Ident}_t
296 )
297 (?:\s+$Sparse)*
298 \b
299 }x;
300 my $Type = qr{
301 \b$NonptrType\b
302 (?:\s*\*+\s*const|\s*\*+)?
303 }x;
304 my $Declare = qr{(?:$Storage\s+)?$Type};
305 my $Attribute = qr{__read_mostly|__init|__initdata};
Andy Whitcroft653d4872007-06-23 17:16:34 -0700306
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700307 foreach my $line (@lines) {
308 $linenr++;
309
Andy Whitcroft653d4872007-06-23 17:16:34 -0700310 my $rawline = $line;
311
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700312#extract the filename as it passes
313 if ($line=~/^\+\+\+\s+(\S+)/) {
314 $realfile=$1;
Andy Whitcroft00df3442007-06-08 13:47:06 -0700315 $realfile =~ s@^[^/]*/@@;
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700316 $in_comment = 0;
317 next;
318 }
319#extract the line range in the file after the patch is applied
320 if ($line=~/^\@\@ -\d+,\d+ \+(\d+)(,(\d+))? \@\@/) {
321 $is_patch = 1;
Andy Whitcroft4a0df2e2007-06-08 13:46:39 -0700322 $first_line = $linenr + 1;
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700323 $in_comment = 0;
324 $realline=$1-1;
325 if (defined $2) {
326 $realcnt=$3+1;
327 } else {
328 $realcnt=1+1;
329 }
330 next;
331 }
332
Andy Whitcroft4a0df2e2007-06-08 13:46:39 -0700333# track the line number as we move through the hunk, note that
334# new versions of GNU diff omit the leading space on completely
335# blank context lines so we need to count that too.
336 if ($line =~ /^( |\+|$)/) {
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700337 $realline++;
Andy Whitcroftd8aaf122007-06-23 17:16:44 -0700338 $realcnt-- if ($realcnt != 0);
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700339
340 # track any sort of multi-line comment. Obviously if
341 # the added text or context do not include the whole
342 # comment we will not see it. Such is life.
343 #
344 # Guestimate if this is a continuing comment. If this
345 # is the start of a diff block and this line starts
346 # ' *' then it is very likely a comment.
Andy Whitcroft4a0df2e2007-06-08 13:46:39 -0700347 if ($linenr == $first_line and $line =~ m@^.\s*\*@) {
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700348 $in_comment = 1;
349 }
350 if ($line =~ m@/\*@) {
351 $in_comment = 1;
352 }
353 if ($line =~ m@\*/@) {
354 $in_comment = 0;
355 }
356
Andy Whitcroft4a0df2e2007-06-08 13:46:39 -0700357 # Measure the line length and indent.
358 ($length, $indent) = line_stats($line);
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700359
360 # Track the previous line.
361 ($prevline, $stashline) = ($stashline, $line);
362 ($previndent, $stashindent) = ($stashindent, $indent);
Andy Whitcroftd8aaf122007-06-23 17:16:44 -0700363 } elsif ($realcnt == 1) {
364 $realcnt--;
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700365 }
366
367#make up the handle for any error we report on this line
Randy Dunlap389834b2007-06-08 13:47:03 -0700368 $here = "#$linenr: ";
369 $here .= "FILE: $realfile:$realline:" if ($realcnt != 0);
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700370
Andy Whitcroft00df3442007-06-08 13:47:06 -0700371 my $hereline = "$here\n$line\n";
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700372 my $herecurr = "$here\n$line\n\n";
373 my $hereprev = "$here\n$prevline\n$line\n\n";
374
375#check the patch for a signoff:
Andy Whitcroftd8aaf122007-06-23 17:16:44 -0700376 if ($line =~ /^\s*signed-off-by:/i) {
Andy Whitcroft4a0df2e2007-06-08 13:46:39 -0700377 # This is a signoff, if ugly, so do not double report.
378 $signoff++;
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700379 if (!($line =~ /^\s*Signed-off-by:/)) {
Andy Whitcroftd8aaf122007-06-23 17:16:44 -0700380 print "Signed-off-by: is the preferred form\n";
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700381 print "$herecurr";
382 $clean = 0;
383 }
384 if ($line =~ /^\s*signed-off-by:\S/i) {
385 print "need space after Signed-off-by:\n";
386 print "$herecurr";
387 $clean = 0;
388 }
389 }
390
Andy Whitcroft00df3442007-06-08 13:47:06 -0700391# Check for wrappage within a valid hunk of the file
392 if ($realcnt != 0 && $line !~ m{^(?:\+|-| |$)}) {
393 print "patch seems to be corrupt (line wrapped?) [$realcnt]\n";
394 print "$herecurr";
395 $clean = 0;
396 }
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700397
Andy Whitcroft00df3442007-06-08 13:47:06 -0700398#ignore lines being removed
399 if ($line=~/^-/) {next;}
400
401# check we are in a valid source file if not then ignore this hunk
402 next if ($realfile !~ /\.(h|c|s|S|pl|sh)$/);
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700403
404#trailing whitespace
Andy Whitcroftd8aaf122007-06-23 17:16:44 -0700405 if ($line =~ /^\+.*\S\s+$/ || $line =~ /^\+\s+$/) {
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700406 my $herevet = "$here\n" . cat_vet($line) . "\n\n";
407 print "trailing whitespace\n";
408 print "$herevet";
409 $clean = 0;
410 }
411#80 column limit
Andy Whitcroft00df3442007-06-08 13:47:06 -0700412 if ($line =~ /^\+/ && !($prevline=~/\/\*\*/) && $length > 80) {
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700413 print "line over 80 characters\n";
414 print "$herecurr";
415 $clean = 0;
416 }
417
418# check we are in a valid source file *.[hc] if not then ignore this hunk
419 next if ($realfile !~ /\.[hc]$/);
420
421# at the beginning of a line any tabs must come first and anything
422# more than 8 must use tabs.
423 if ($line=~/^\+\s* \t\s*\S/ or $line=~/^\+\s* \s*/) {
424 my $herevet = "$here\n" . cat_vet($line) . "\n\n";
425 print "use tabs not spaces\n";
426 print "$herevet";
427 $clean = 0;
428 }
429
430 #
431 # The rest of our checks refer specifically to C style
432 # only apply those _outside_ comments.
433 #
434 next if ($in_comment);
435
Andy Whitcroft653d4872007-06-23 17:16:34 -0700436# Remove comments from the line before processing.
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700437 $line =~ s@/\*.*\*/@@g;
438 $line =~ s@/\*.*@@;
439 $line =~ s@.*\*/@@;
Andy Whitcroft00df3442007-06-08 13:47:06 -0700440
Andy Whitcroft653d4872007-06-23 17:16:34 -0700441# Standardise the strings and chars within the input to simplify matching.
442 $line = sanitise_line($line);
Andy Whitcroft00df3442007-06-08 13:47:06 -0700443
Andy Whitcroft653d4872007-06-23 17:16:34 -0700444#
445# Checks which may be anchored in the context.
446#
447
448# Check for switch () and associated case and default
449# statements should be at the same indent.
Andy Whitcroft00df3442007-06-08 13:47:06 -0700450 if ($line=~/\bswitch\s*\(.*\)/) {
451 my $err = '';
452 my $sep = '';
453 my @ctx = ctx_block_outer($linenr, $realcnt);
454 shift(@ctx);
455 for my $ctx (@ctx) {
456 my ($clen, $cindent) = line_stats($ctx);
457 if ($ctx =~ /^\+\s*(case\s+|default:)/ &&
458 $indent != $cindent) {
459 $err .= "$sep$ctx\n";
460 $sep = '';
461 } else {
462 $sep = "[...]\n";
463 }
464 }
465 if ($err ne '') {
466 print "switch and case should be at the same indent\n";
467 print "$here\n$line\n$err\n";
468 $clean = 0;
469 }
470 }
471
472#ignore lines not being added
473 if ($line=~/^[^\+]/) {next;}
474
Andy Whitcroft653d4872007-06-23 17:16:34 -0700475# TEST: allow direct testing of the type matcher.
476 if ($tst_type && $line =~ /^.$Declare$/) {
477 print "TEST: is type $Declare\n";
478 print "$herecurr";
479 $clean = 0;
480 next;
481 }
482
483#
484# Checks which are anchored on the added line.
485#
486
487# check for malformed paths in #include statements (uses RAW line)
488 if ($rawline =~ m{^.#\s*include\s+[<"](.*)[">]}) {
489 my $path = $1;
490 if ($path =~ m{//}) {
491 print "malformed #include filename\n";
492 print "$herecurr";
493 $clean = 0;
494 }
495 # Sanitise this special form of string.
496 $path = 'X' x length($path);
497 $line =~ s{\<.*\>}{<$path>};
498 }
Andy Whitcroft00df3442007-06-08 13:47:06 -0700499
500# no C99 // comments
501 if ($line =~ m{//}) {
502 print "do not use C99 // comments\n";
503 print "$herecurr";
504 $clean = 0;
505 }
506 # Remove C99 comments.
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700507 $line =~ s@//.*@@;
508
509#EXPORT_SYMBOL should immediately follow its function closing }.
Andy Whitcroft653d4872007-06-23 17:16:34 -0700510 if (($line =~ /EXPORT_SYMBOL.*\((.*)\)/) ||
511 ($line =~ /EXPORT_UNUSED_SYMBOL.*\((.*)\)/)) {
512 my $name = $1;
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700513 if (($prevline !~ /^}/) &&
514 ($prevline !~ /^\+}/) &&
Andy Whitcroft653d4872007-06-23 17:16:34 -0700515 ($prevline !~ /^ }/) &&
516 ($prevline !~ /\s$name(?:\s+$Attribute)?\s*(?:;|=)/)) {
517 print "EXPORT_SYMBOL(foo); should immediately follow its function/variable\n";
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700518 print "$herecurr";
519 $clean = 0;
520 }
521 }
522
Andy Whitcroft653d4872007-06-23 17:16:34 -0700523# check for static initialisers.
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700524 if ($line=~/\s*static\s.*=\s+(0|NULL);/) {
525 print "do not initialise statics to 0 or NULL\n";
526 print "$herecurr";
527 $clean = 0;
528 }
529
Andy Whitcroft653d4872007-06-23 17:16:34 -0700530# check for new typedefs, only function parameters and sparse annotations
531# make sense.
532 if ($line =~ /\btypedef\s/ &&
533 $line !~ /\btypedef\s+$Type\s+\(\s*$Ident\s*\)\s*\(/ &&
534 $line !~ /\b__bitwise(?:__|)\b/) {
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700535 print "do not add new typedefs\n";
536 print "$herecurr";
537 $clean = 0;
538 }
539
540# * goes on variable not on type
Andy Whitcroftd8aaf122007-06-23 17:16:44 -0700541 if ($line =~ m{\($NonptrType(\*+)(?:\s+const)?\)}) {
Andy Whitcroft00df3442007-06-08 13:47:06 -0700542 print "\"(foo$1)\" should be \"(foo $1)\"\n";
543 print "$herecurr";
544 $clean = 0;
Andy Whitcroftd8aaf122007-06-23 17:16:44 -0700545
546 } elsif ($line =~ m{\($NonptrType\s+(\*+)(?!\s+const)\s+\)}) {
Andy Whitcroft00df3442007-06-08 13:47:06 -0700547 print "\"(foo $1 )\" should be \"(foo $1)\"\n";
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700548 print "$herecurr";
549 $clean = 0;
Andy Whitcroftd8aaf122007-06-23 17:16:44 -0700550
551 } elsif ($line =~ m{$NonptrType(\*+)(?:\s+const)?\s+[A-Za-z\d_]+}) {
552 print "\"foo$1 bar\" should be \"foo $1bar\"\n";
553 print "$herecurr";
554 $clean = 0;
555
556 } elsif ($line =~ m{$NonptrType\s+(\*+)(?!\s+const)\s+[A-Za-z\d_]+}) {
557 print "\"foo $1 bar\" should be \"foo $1bar\"\n";
558 print "$herecurr";
559 $clean = 0;
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700560 }
561
562# # no BUG() or BUG_ON()
563# if ($line =~ /\b(BUG|BUG_ON)\b/) {
564# print "Try to use WARN_ON & Recovery code rather than BUG() or BUG_ON()\n";
565# print "$herecurr";
566# $clean = 0;
567# }
568
Andy Whitcroft00df3442007-06-08 13:47:06 -0700569# printk should use KERN_* levels. Note that follow on printk's on the
570# same line do not need a level, so we use the current block context
571# 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.
573# we assume the first bad printk is the one to report.
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700574 if ($line =~ /\bprintk\((?!KERN_)/) {
Andy Whitcroft00df3442007-06-08 13:47:06 -0700575 my $ok = 0;
576 for (my $ln = $linenr - 1; $ln >= $first_line; $ln--) {
577 #print "CHECK<$lines[$ln - 1]\n";
578 # we have a preceeding printk if it ends
579 # with "\n" ignore it, else it is to blame
580 if ($lines[$ln - 1] =~ m{\bprintk\(}) {
581 if ($rawlines[$ln - 1] !~ m{\\n"}) {
582 $ok = 1;
583 }
584 last;
585 }
586 }
587 if ($ok == 0) {
588 print "printk() should include KERN_ facility level\n";
589 print "$herecurr";
590 $clean = 0;
591 }
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700592 }
593
Andy Whitcroft653d4872007-06-23 17:16:34 -0700594# function brace can't be on same line, except for #defines of do while,
595# or if closed on same line
Andy Whitcroftd8aaf122007-06-23 17:16:44 -0700596 if (($line=~/$Type\s*[A-Za-z\d_]+\(.*\).* {/) and
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700597 !($line=~/\#define.*do\s{/) and !($line=~/}/)) {
598 print "braces following function declarations go on the next line\n";
599 print "$herecurr";
600 $clean = 0;
601 }
Andy Whitcroft653d4872007-06-23 17:16:34 -0700602
603# Check operator spacing.
Andy Whitcroft4a0df2e2007-06-08 13:46:39 -0700604 # Note we expand the line with the leading + as the real
605 # line will be displayed with the leading + and the tabs
606 # will therefore also expand that way.
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700607 my $opline = $line;
Andy Whitcroft4a0df2e2007-06-08 13:46:39 -0700608 $opline = expand_tabs($opline);
Andy Whitcroft00df3442007-06-08 13:47:06 -0700609 $opline =~ s/^./ /;
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700610 if (!($line=~/\#\s*include/)) {
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700611 my @elements = split(/(<<=|>>=|<=|>=|==|!=|\+=|-=|\*=|\/=|%=|\^=|\|=|&=|->|<<|>>|<|>|=|!|~|&&|\|\||,|\^|\+\+|--|;|&|\||\+|-|\*|\/\/|\/)/, $opline);
Andy Whitcroft00df3442007-06-08 13:47:06 -0700612 my $off = 0;
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700613 for (my $n = 0; $n < $#elements; $n += 2) {
Andy Whitcroft4a0df2e2007-06-08 13:46:39 -0700614 $off += length($elements[$n]);
615
616 my $a = '';
617 $a = 'V' if ($elements[$n] ne '');
618 $a = 'W' if ($elements[$n] =~ /\s$/);
619 $a = 'B' if ($elements[$n] =~ /(\[|\()$/);
620 $a = 'O' if ($elements[$n] eq '');
621 $a = 'E' if ($elements[$n] eq '' && $n == 0);
622
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700623 my $op = $elements[$n + 1];
Andy Whitcroft4a0df2e2007-06-08 13:46:39 -0700624
625 my $c = '';
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700626 if (defined $elements[$n + 2]) {
Andy Whitcroft4a0df2e2007-06-08 13:46:39 -0700627 $c = 'V' if ($elements[$n + 2] ne '');
628 $c = 'W' if ($elements[$n + 2] =~ /^\s/);
629 $c = 'B' if ($elements[$n + 2] =~ /^(\)|\]|;)/);
630 $c = 'O' if ($elements[$n + 2] eq '');
631 } else {
632 $c = 'E';
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700633 }
634
Andy Whitcroft00df3442007-06-08 13:47:06 -0700635 # Pick up the preceeding and succeeding characters.
636 my $ca = substr($opline, $off - 1, 1);
637 my $cc = '';
Andy Whitcroft653d4872007-06-23 17:16:34 -0700638 if (length($opline) >= ($off + length($elements[$n + 1]))) {
Andy Whitcroftd8aaf122007-06-23 17:16:44 -0700639 $cc = substr($opline, $off + length($elements[$n + 1]));
Andy Whitcroft00df3442007-06-08 13:47:06 -0700640 }
641
Andy Whitcroft4a0df2e2007-06-08 13:46:39 -0700642 my $ctx = "${a}x${c}";
643
644 my $at = "(ctx:$ctx)";
645
646 my $ptr = (" " x $off) . "^";
Andy Whitcroft00df3442007-06-08 13:47:06 -0700647 my $hereptr = "$hereline$ptr\n\n";
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700648
649 ##print "<$s1:$op:$s2> <$elements[$n]:$elements[$n + 1]:$elements[$n + 2]>\n";
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700650
Andy Whitcroftd8aaf122007-06-23 17:16:44 -0700651 # ; should have either the end of line or a space or \ after it
652 if ($op eq ';') {
653 if ($ctx !~ /.x[WE]/ && $cc !~ /^\\/) {
654 print "need space after that '$op' $at\n";
655 print "$hereptr";
656 $clean = 0;
657 }
658
659 # // is a comment
660 } elsif ($op eq '//') {
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700661
662 # -> should have no spaces
663 } elsif ($op eq '->') {
Andy Whitcroft4a0df2e2007-06-08 13:46:39 -0700664 if ($ctx =~ /Wx.|.xW/) {
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700665 print "no spaces around that '$op' $at\n";
Andy Whitcroft4a0df2e2007-06-08 13:46:39 -0700666 print "$hereptr";
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700667 $clean = 0;
668 }
669
670 # , must have a space on the right.
671 } elsif ($op eq ',') {
Andy Whitcroftd8aaf122007-06-23 17:16:44 -0700672 if ($ctx !~ /.xW|.xE/ && $cc !~ /^}/) {
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700673 print "need space after that '$op' $at\n";
Andy Whitcroft4a0df2e2007-06-08 13:46:39 -0700674 print "$hereptr";
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700675 $clean = 0;
676 }
677
678 # unary ! and unary ~ are allowed no space on the right
679 } elsif ($op eq '!' or $op eq '~') {
Andy Whitcroft4a0df2e2007-06-08 13:46:39 -0700680 if ($ctx !~ /[WOEB]x./) {
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700681 print "need space before that '$op' $at\n";
Andy Whitcroft4a0df2e2007-06-08 13:46:39 -0700682 print "$hereptr";
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700683 $clean = 0;
684 }
Andy Whitcroft4a0df2e2007-06-08 13:46:39 -0700685 if ($ctx =~ /.xW/) {
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700686 print "no space after that '$op' $at\n";
Andy Whitcroft4a0df2e2007-06-08 13:46:39 -0700687 print "$hereptr";
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700688 $clean = 0;
689 }
690
691 # unary ++ and unary -- are allowed no space on one side.
692 } elsif ($op eq '++' or $op eq '--') {
Andy Whitcroftd8aaf122007-06-23 17:16:44 -0700693 if ($ctx !~ /[WOB]x[^W]/ && $ctx !~ /[^W]x[WOBE]/) {
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700694 print "need space one side of that '$op' $at\n";
Andy Whitcroft4a0df2e2007-06-08 13:46:39 -0700695 print "$hereptr";
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700696 $clean = 0;
697 }
Andy Whitcroftd8aaf122007-06-23 17:16:44 -0700698 if ($ctx =~ /Wx./ && $cc =~ /^;/) {
Andy Whitcroft653d4872007-06-23 17:16:34 -0700699 print "no space before that '$op' $at\n";
700 print "$hereptr";
701 $clean = 0;
702 }
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700703
704 # & is both unary and binary
705 # unary:
706 # a &b
707 # binary (consistent spacing):
708 # a&b OK
709 # a & b OK
710 #
711 # boiling down to: if there is a space on the right then there
712 # should be one on the left.
713 #
714 # - is the same
715 #
Andy Whitcroft4a0df2e2007-06-08 13:46:39 -0700716 } elsif ($op eq '&' or $op eq '-') {
Andy Whitcroft00df3442007-06-08 13:47:06 -0700717 if ($ctx !~ /VxV|[EW]x[WE]|[EWB]x[VO]/) {
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700718 print "need space before that '$op' $at\n";
Andy Whitcroft4a0df2e2007-06-08 13:46:39 -0700719 print "$hereptr";
720 $clean = 0;
721 }
722
Andy Whitcroft00df3442007-06-08 13:47:06 -0700723 # * is the same as & only adding:
724 # type:
725 # (foo *)
726 # (foo **)
727 #
Andy Whitcroft4a0df2e2007-06-08 13:46:39 -0700728 } elsif ($op eq '*') {
Andy Whitcroft00df3442007-06-08 13:47:06 -0700729 if ($ca eq '*') {
Andy Whitcroftd8aaf122007-06-23 17:16:44 -0700730 if ($cc =~ /^\s(?!\s*const)/) {
Andy Whitcroft00df3442007-06-08 13:47:06 -0700731 print "no space after that '$op' $at\n";
732 print "$hereptr";
733 $clean = 0;
734 }
Andy Whitcroft653d4872007-06-23 17:16:34 -0700735 } elsif ($ctx !~ /VxV|[EW]x[WE]|[EWB]x[VO]|OxV|WxB|BxB/) {
Andy Whitcroft4a0df2e2007-06-08 13:46:39 -0700736 print "need space before that '$op' $at\n";
737 print "$hereptr";
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700738 $clean = 0;
739 }
740
741 # << and >> may either have or not have spaces both sides
742 } elsif ($op eq '<<' or $op eq '>>' or $op eq '+' or $op eq '/' or
743 $op eq '^' or $op eq '|')
744 {
Andy Whitcroft4a0df2e2007-06-08 13:46:39 -0700745 if ($ctx !~ /VxV|WxW|VxE|WxE/) {
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700746 print "need consistent spacing around '$op' $at\n";
Andy Whitcroft4a0df2e2007-06-08 13:46:39 -0700747 print "$hereptr";
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700748 $clean = 0;
749 }
750
751 # All the others need spaces both sides.
Andy Whitcroft4a0df2e2007-06-08 13:46:39 -0700752 } elsif ($ctx !~ /[EW]x[WE]/) {
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700753 print "need spaces around that '$op' $at\n";
Andy Whitcroft4a0df2e2007-06-08 13:46:39 -0700754 print "$hereptr";
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700755 $clean = 0;
756 }
Andy Whitcroft4a0df2e2007-06-08 13:46:39 -0700757 $off += length($elements[$n + 1]);
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700758 }
759 }
760
761#need space before brace following if, while, etc
762 if ($line=~/\(.*\){/) {
763 print "need a space before the brace\n";
764 print "$herecurr";
765 $clean = 0;
766 }
767
768#goto labels aren't indented, allow a single space however
Andy Whitcroft4a0df2e2007-06-08 13:46:39 -0700769 if ($line=~/^.\s+[A-Za-z\d_]+:(?![0-9]+)/ and
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700770 !($line=~/^. [A-Za-z\d_]+:/) and !($line=~/^.\s+default:/)) {
771 print "labels should not be indented\n";
772 print "$herecurr";
773 $clean = 0;
774 }
775
776# Need a space before open parenthesis after if, while etc
Andy Whitcroft4a0df2e2007-06-08 13:46:39 -0700777 if ($line=~/\b(if|while|for|switch)\(/) {
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700778 print "need a space before the open parenthesis\n";
779 print "$herecurr";
780 $clean = 0;
781 }
782
783# Check for illegal assignment in if conditional.
Andy Whitcroft653d4872007-06-23 17:16:34 -0700784 if ($line=~/\bif\s*\(.*[^<>!=]=[^=].*\)/) {
Andy Whitcroft00df3442007-06-08 13:47:06 -0700785 #next if ($line=~/\".*\Q$op\E.*\"/ or $line=~/\'\Q$op\E\'/);
Andy Whitcroft653d4872007-06-23 17:16:34 -0700786 print "do not use assignment in if condition\n";
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700787 print "$herecurr";
788 $clean = 0;
789 }
790
791 # Check for }<nl>else {, these must be at the same
792 # indent level to be relevant to each other.
793 if ($prevline=~/}\s*$/ and $line=~/^.\s*else\s*/ and
794 $previndent == $indent) {
795 print "else should follow close brace\n";
796 print "$hereprev";
797 $clean = 0;
798 }
799
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700800#studly caps, commented out until figure out how to distinguish between use of existing and adding new
801# if (($line=~/[\w_][a-z\d]+[A-Z]/) and !($line=~/print/)) {
802# print "No studly caps, use _\n";
803# print "$herecurr";
804# $clean = 0;
805# }
806
807#no spaces allowed after \ in define
808 if ($line=~/\#define.*\\\s$/) {
809 print("Whitepspace after \\ makes next lines useless\n");
810 print "$herecurr";
811 $clean = 0;
812 }
813
Andy Whitcroft653d4872007-06-23 17:16:34 -0700814#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\>}) {
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700816 my $checkfile = "include/linux/$1.h";
817 if (-f $checkfile) {
818 print "Use #include <linux/$1.h> instead of <asm/$1.h>\n";
819 print $herecurr;
820 $clean = 0;
821 }
822 }
823
Andy Whitcroft653d4872007-06-23 17:16:34 -0700824# 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
Andy Whitcroftd8aaf122007-06-23 17:16:44 -0700826 if ($prevline=~/\b(?:(if|while|for|switch)\s*\(|do\b|else\b)/) {
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700827 my @opened = $prevline=~/\(/g;
828 my @closed = $prevline=~/\)/g;
829 my $nr_line = $linenr;
Andy Whitcroft00df3442007-06-08 13:47:06 -0700830 my $remaining = $realcnt - 1;
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700831 my $next_line = $line;
832 my $extra_lines = 0;
833 my $display_segment = $prevline;
834
Andy Whitcroft00df3442007-06-08 13:47:06 -0700835 while ($remaining > 0 && scalar @opened > scalar @closed) {
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700836 $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
Andy Whitcroftd8aaf122007-06-23 17:16:44 -0700846 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/)) {
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700848 print "That { should be on the previous line\n";
Andy Whitcroft4a0df2e2007-06-08 13:46:39 -0700849 print "$here\n$display_segment\n$next_line\n\n";
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700850 $clean = 0;
851 }
852 }
853
Andy Whitcroftd8aaf122007-06-23 17:16:44 -0700854# if and else should not have general statements after it
855 if ($line =~ /^.\s*(?:}\s*)?else\b(.*)/ &&
856 $1 !~ /^\s*(?:\sif|{|$)/) {
857 print "trailing statements should be on next line\n";
858 print "$herecurr";
859 $clean = 0;
860 }
861
Andy Whitcroft653d4872007-06-23 17:16:34 -0700862# multi-statement macros should be enclosed in a do while loop, grab the
863# first statement and ensure its the whole macro if its not enclosed
864# in a known goot container
865 if (($prevline=~/\#define.*\\/) and
866 !($prevline=~/do\s+{/) and !($prevline=~/\(\{/) and
867 !($line=~/do.*{/) and !($line=~/\(\{/) and
868 !($line=~/^.\s*$Declare\s/)) {
869 # Grab the first statement, if that is the entire macro
870 # its ok. This may start either on the #define line
871 # or the one below.
Andy Whitcroftd8aaf122007-06-23 17:16:44 -0700872 my $ln = $linenr;
873 my $cnt = $realcnt;
Andy Whitcroft653d4872007-06-23 17:16:34 -0700874
Andy Whitcroftd8aaf122007-06-23 17:16:44 -0700875 # If the macro starts on the define line start there.
876 if ($prevline !~ m{^.#\s*define\s*$Ident(?:\([^\)]*\))?\s*\\\s*$}) {
877 $ln--;
878 $cnt++;
879 }
880 my $ctx = join('', ctx_statement($ln, $cnt));
881
882 if ($ctx =~ /\\$/) {
883 if ($ctx =~ /;/) {
884 print "Macros with multiple statements should be enclosed in a do - while loop\n";
885 } else {
886 print "Macros with complex values should be enclosed in parenthesis\n";
887 }
Andy Whitcroft653d4872007-06-23 17:16:34 -0700888 print "$hereprev";
889 $clean = 0;
890 }
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700891 }
892
Andy Whitcroft653d4872007-06-23 17:16:34 -0700893# don't include deprecated include files (uses RAW line)
Andy Whitcroft4a0df2e2007-06-08 13:46:39 -0700894 for my $inc (@dep_includes) {
Andy Whitcroft653d4872007-06-23 17:16:34 -0700895 if ($rawline =~ m@\#\s*include\s*\<$inc>@) {
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700896 print "Don't use <$inc>: see Documentation/feature-removal-schedule.txt\n";
897 print "$herecurr";
898 $clean = 0;
899 }
900 }
901
Andy Whitcroft4a0df2e2007-06-08 13:46:39 -0700902# don't use deprecated functions
903 for my $func (@dep_functions) {
Andy Whitcroft00df3442007-06-08 13:47:06 -0700904 if ($line =~ /\b$func\b/) {
Andy Whitcroft4a0df2e2007-06-08 13:46:39 -0700905 print "Don't use $func(): see Documentation/feature-removal-schedule.txt\n";
906 print "$herecurr";
907 $clean = 0;
908 }
909 }
910
911# no volatiles please
Andy Whitcroft00df3442007-06-08 13:47:06 -0700912 if ($line =~ /\bvolatile\b/ && $line !~ /\basm\s+volatile\b/) {
Andy Whitcroft4a0df2e2007-06-08 13:46:39 -0700913 print "Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt\n";
914 print "$herecurr";
915 $clean = 0;
916 }
917
Andy Whitcroft00df3442007-06-08 13:47:06 -0700918# warn about #if 0
919 if ($line =~ /^.#\s*if\s+0\b/) {
920 print "#if 0 -- if this code redundant remove it\n";
Andy Whitcroft4a0df2e2007-06-08 13:46:39 -0700921 print "$herecurr";
922 $clean = 0;
923 }
924
Andy Whitcroft00df3442007-06-08 13:47:06 -0700925# warn about #ifdefs in C files
926# if ($line =~ /^.#\s*if(|n)def/ && ($realfile =~ /\.c$/)) {
927# print "#ifdef in C files should be avoided\n";
928# print "$herecurr";
929# $clean = 0;
930# }
931
Andy Whitcroft4a0df2e2007-06-08 13:46:39 -0700932# check for spinlock_t definitions without a comment.
933 if ($line =~ /^.\s*(struct\s+mutex|spinlock_t)\s+\S+;/) {
934 my $which = $1;
935 if (!ctx_has_comment($first_line, $linenr)) {
936 print "$1 definition without comment\n";
937 print "$herecurr";
938 $clean = 0;
939 }
940 }
941# 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)\(/) {
943 if (!ctx_has_comment($first_line, $linenr)) {
944 print "memory barrier without comment\n";
945 print "$herecurr";
946 $clean = 0;
947 }
948 }
949# check of hardware specific defines
950 if ($line =~ m@^.#\s*if.*\b(__i386__|__powerpc64__|__sun__|__s390x__)\b@) {
951 print "architecture specific defines should be avoided\n";
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700952 print "$herecurr";
953 $clean = 0;
954 }
Andy Whitcroft653d4872007-06-23 17:16:34 -0700955
956 if ($line =~ /$Type\s+(?:inline|__always_inline)\b/ ||
957 $line =~ /\b(?:inline|always_inline)\s+$Storage/) {
958 print "inline keyword should sit between storage class and type\n";
959 print "$herecurr";
960 $clean = 0;
961 }
Andy Whitcroft0a920b52007-06-01 00:46:48 -0700962 }
963
964 if ($chk_patch && !$is_patch) {
965 $clean = 0;
966 print "Does not appear to be a unified-diff format patch\n";
967 }
968 if ($is_patch && $chk_signoff && $signoff == 0) {
969 $clean = 0;
970 print "Missing Signed-off-by: line(s)\n";
971 }
972
973 if ($clean == 1 && $quiet == 0) {
974 print "Your patch has no obvious style problems and is ready for submission.\n"
975 }
976 if ($clean == 0 && $quiet == 0) {
977 print "Your patch has style problems, please review. If any of these errors\n";
978 print "are false positives report them to the maintainer, see\n";
979 print "CHECKPATCH in MAINTAINERS.\n";
980 }
981 return $clean;
982}