History

Merge branch 'master' into next

James Morris committed 16 years ago

Commit d25d6fa2 parents 225a9be 2eaa9cf4041 files · +229972 −107940Browse files

Showing the changes to scripts (4 of 4041 files). Show all

Unified · Split

4 files
  1. scripts/checkpatch.pl +73 −5
  2. scripts/get_maintainer.pl +147 −38
  3. scripts/gfp-translate +1 −1
  4. scripts/kernel-doc +4 −1
scripts/checkpatch.pl+73−5
@@ -145,11 +145,14 @@ our $Sparse = qr{ · 144 unmodified lines
145145 __kprobes|
146146 __ref
147147 }x;
148+
149+# Notes to $Attribute:
150+# We need \b after 'init' otherwise 'initconst' will cause a false positive in a check
148151 our $Attribute = qr{
149152 const|
150153 __read_mostly|
151154 __kprobes|
152− __(?:mem|cpu|dev|)(?:initdata|init)|
155+ __(?:mem|cpu|dev|)(?:initdata|initconst|init\b)|
153156 ____cacheline_aligned|
154157 ____cacheline_aligned_in_smp|
155158 ____cacheline_internodealigned_in_smp|
@@ -189,6 +192,14 @@ our $typeTypedefs = qr{(?x: · 33 unmodified lines
189192 atomic_t
190193 )};
191194
195+our $logFunctions = qr{(?x:
196+ printk|
197+ pr_(debug|dbg|vdbg|devel|info|warning|err|notice|alert|crit|emerg|cont)|
198+ dev_(printk|dbg|vdbg|info|warn|err|notice|alert|crit|emerg|WARN)|
199+ WARN|
200+ panic
201+)};
202+
192203 our @typeList = (
193204 qr{void},
194205 qr{(?:unsigned\s+)?char},
@@ -1377,12 +1388,17 @@ sub process { · 1182 unmodified lines
13771388 #80 column limit
13781389 if ($line =~ /^\+/ && $prevrawline !~ /\/\*\*/ &&
13791390 $rawline !~ /^.\s*\*\s*\@$Ident\s/ &&
1380− $line !~ /^\+\s*printk\s*\(\s*(?:KERN_\S+\s*)?"[X\t]*"\s*(?:,|\)\s*;)\s*$/ &&
1391+ $line !~ /^\+\s*$logFunctions\s*\(\s*(?:KERN_\S+\s*)?"[X\t]*"\s*(?:,|\)\s*;)\s*$/ &&
13811392 $length > 80)
13821393 {
13831394 WARN("line over 80 characters\n" . $herecurr);
13841395 }
13851396
1397+# check for spaces before a quoted newline
1398+ if ($rawline =~ /^.*\".*\s\\n/) {
1399+ WARN("unnecessary whitespace before a quoted newline\n" . $herecurr);
1400+ }
1401+
13861402 # check for adding lines without a newline.
13871403 if ($line =~ /^\+/ && defined $lines[$linenr] && $lines[$linenr] =~ /^\\ No newline at end of file/) {
13881404 WARN("adding a line without newline at end of file\n" . $herecurr);
@@ -1411,6 +1427,12 @@ sub process { · 22 unmodified lines
14111427 ERROR("code indent should use tabs where possible\n" . $herevet);
14121428 }
14131429
1430+# check for space before tabs.
1431+ if ($rawline =~ /^\+/ && $rawline =~ / \t/) {
1432+ my $herevet = "$here\n" . cat_vet($rawline) . "\n";
1433+ WARN("please, no space before tabs\n" . $herevet);
1434+ }
1435+
14141436 # check we are in a valid C source file if not then ignore this hunk
14151437 next if ($realfile !~ /\.(h|c)$/);
14161438
@@ -2182,8 +2204,10 @@ sub process { · 765 unmodified lines
21822204 # Find out how long the conditional actually is.
21832205 my @newlines = ($c =~ /\n/gs);
21842206 my $cond_lines = 1 + $#newlines;
2207+ my $stat_real = '';
21852208
2186− my $stat_real = raw_line($linenr, $cond_lines);
2209+ $stat_real = raw_line($linenr, $cond_lines)
2210+ . "\n" if ($cond_lines);
21872211 if (defined($stat_real) && $cond_lines > 1) {
21882212 $stat_real = "[...]\n$stat_real";
21892213 }
@@ -2348,6 +2372,8 @@ sub process { · 158 unmodified lines
23482372 DECLARE_PER_CPU|
23492373 DEFINE_PER_CPU|
23502374 __typeof__\(|
2375+ union|
2376+ struct|
23512377 \.$Ident\s*=\s*|
23522378 ^\"|\"$
23532379 }x;
@@ -2572,6 +2598,11 @@ sub process { · 218 unmodified lines
25722598 WARN("plain inline is preferred over $1\n" . $herecurr);
25732599 }
25742600
2601+# check for sizeof(&)
2602+ if ($line =~ /\bsizeof\s*\(\s*\&/) {
2603+ WARN("sizeof(& should be avoided\n" . $herecurr);
2604+ }
2605+
25752606 # check for new externs in .c files.
25762607 if ($realfile =~ /\.c$/ && defined $stat &&
25772608 $stat =~ /^.\s*(?:extern\s+)?$Type\s+($Ident)(\s*)\(/s)
@@ -2634,9 +2665,46 @@ sub process { · 56 unmodified lines
26342665 if ($line =~ /^.\s*__initcall\s*\(/) {
26352666 WARN("please use device_initcall() instead of __initcall()\n" . $herecurr);
26362667 }
2637−# check for struct file_operations, ensure they are const.
2668+# check for various ops structs, ensure they are const.
2669+ my $struct_ops = qr{acpi_dock_ops|
2670+ address_space_operations|
2671+ backlight_ops|
2672+ block_device_operations|
2673+ dentry_operations|
2674+ dev_pm_ops|
2675+ dma_map_ops|
2676+ extent_io_ops|
2677+ file_lock_operations|
2678+ file_operations|
2679+ hv_ops|
2680+ ide_dma_ops|
2681+ intel_dvo_dev_ops|
2682+ item_operations|
2683+ iwl_ops|
2684+ kgdb_arch|
2685+ kgdb_io|
2686+ kset_uevent_ops|
2687+ lock_manager_operations|
2688+ microcode_ops|
2689+ mtrr_ops|
2690+ neigh_ops|
2691+ nlmsvc_binding|
2692+ pci_raw_ops|
2693+ pipe_buf_operations|
2694+ platform_hibernation_ops|
2695+ platform_suspend_ops|
2696+ proto_ops|
2697+ rpc_pipe_ops|
2698+ seq_operations|
2699+ snd_ac97_build_ops|
2700+ soc_pcmcia_socket_ops|
2701+ stacktrace_ops|
2702+ sysfs_ops|
2703+ tty_operations|
2704+ usb_mon_operations|
2705+ wd_ops}x;
26382706 if ($line !~ /\bconst\b/ &&
2639− $line =~ /\bstruct\s+(file_operations|seq_operations)\b/) {
2707+ $line =~ /\bstruct\s+($struct_ops)\b/) {
26402708 WARN("struct $1 should normally be const\n" .
26412709 $herecurr);
26422710 }
scripts/get_maintainer.pl+147−38
@@ -41,6 +41,8 @@ my $web = 0; · 40 unmodified lines
4141 my $subsystem = 0;
4242 my $status = 0;
4343 my $keywords = 1;
44+my $sections = 0;
45+my $file_emails = 0;
4446 my $from_filename = 0;
4547 my $pattern_depth = 0;
4648 my $version = 0;
@@ -120,9 +122,11 @@ if (!GetOptions( · 73 unmodified lines
120122 'web!' => \$web,
121123 'pattern-depth=i' => \$pattern_depth,
122124 'k|keywords!' => \$keywords,
125+ 'sections!' => \$sections,
126+ 'fe|file-emails!' => \$file_emails,
123127 'f|file' => \$from_filename,
124128 'v|version' => \$version,
125− 'h|help' => \$help,
129+ 'h|help|usage' => \$help,
126130 )) {
127131 die "$P: invalid argument - use --help if necessary\n";
128132 }
@@ -137,9 +141,9 @@ if ($version != 0) { · 8 unmodified lines
137141 exit 0;
138142 }
139143
140−if ($#ARGV < 0) {
141− usage();
142− die "$P: argument missing: patchfile or -f file please\n";
144+if (-t STDIN && !@ARGV) {
145+ # We're talking to a terminal, but have no command line arguments.
146+ die "$P: missing patchfile or -f file - use --help if necessary\n";
143147 }
144148
145149 if ($output_separator ne ", ") {
@@ -150,16 +154,24 @@ if ($output_rolestats) { · 4 unmodified lines
150154 $output_roles = 1;
151155 }
152156
153−my $selections = $email + $scm + $status + $subsystem + $web;
154−if ($selections == 0) {
155− usage();
156− die "$P: Missing required option: email, scm, status, subsystem or web\n";
157+if ($sections) {
158+ $email = 0;
159+ $email_list = 0;
160+ $scm = 0;
161+ $status = 0;
162+ $subsystem = 0;
163+ $web = 0;
164+ $keywords = 0;
165+} else {
166+ my $selections = $email + $scm + $status + $subsystem + $web;
167+ if ($selections == 0) {
168+ die "$P: Missing required option: email, scm, status, subsystem or web\n";
169+ }
157170 }
158171
159172 if ($email &&
160173 ($email_maintainer + $email_list + $email_subscriber_list +
161174 $email_git + $email_git_penguin_chiefs + $email_git_blame) == 0) {
162− usage();
163175 die "$P: Please select at least 1 email option\n";
164176 }
165177
@@ -173,8 +185,9 @@ if (!top_of_kernel_tree($lk_path)) { · 7 unmodified lines
173185 my @typevalue = ();
174186 my %keyword_hash;
175187
176−open(MAINT, "<${lk_path}MAINTAINERS") || die "$P: Can't open MAINTAINERS\n";
177−while (<MAINT>) {
188+open (my $maint, '<', "${lk_path}MAINTAINERS")
189+ or die "$P: Can't open MAINTAINERS: $!\n";
190+while (<$maint>) {
178191 my $line = $_;
179192
180193 if ($line =~ m/^(\C):\s*(.*)/) {
@@ -199,13 +212,14 @@ while (<MAINT>) { · 18 unmodified lines
199212 push(@typevalue, $line);
200213 }
201214 }
202−close(MAINT);
215+close($maint);
203216
204217 my %mailmap;
205218
206219 if ($email_remove_duplicates) {
207− open(MAILMAP, "<${lk_path}.mailmap") || warn "$P: Can't open .mailmap\n";
208− while (<MAILMAP>) {
220+ open(my $mailmap, '<', "${lk_path}.mailmap")
221+ or warn "$P: Can't open .mailmap: $!\n";
222+ while (<$mailmap>) {
209223 my $line = $_;
210224
211225 next if ($line =~ m/^\s*#/);
@@ -224,7 +238,7 @@ if ($email_remove_duplicates) { · 12 unmodified lines
224238 $mailmap{$name} = \@arr;
225239 }
226240 }
227− close(MAILMAP);
241+ close($mailmap);
228242 }
229243
230244 ## use the filenames on the command line or find the filenames in the patchfiles
@@ -232,31 +246,47 @@ if ($email_remove_duplicates) { · 1 unmodified line
232246 my @files = ();
233247 my @range = ();
234248 my @keyword_tvi = ();
249+my @file_emails = ();
250+
251+if (!@ARGV) {
252+ push(@ARGV, "&STDIN");
253+}
235254
236255 foreach my $file (@ARGV) {
237− ##if $file is a directory and it lacks a trailing slash, add one
238− if ((-d $file)) {
239− $file =~ s@([^/])$@$1/@;
240− } elsif (!(-f $file)) {
241− die "$P: file '${file}' not found\n";
256+ if ($file ne "&STDIN") {
257+ ##if $file is a directory and it lacks a trailing slash, add one
258+ if ((-d $file)) {
259+ $file =~ s@([^/])$@$1/@;
260+ } elsif (!(-f $file)) {
261+ die "$P: file '${file}' not found\n";
262+ }
242263 }
243264 if ($from_filename) {
244265 push(@files, $file);
245− if (-f $file && $keywords) {
246− open(FILE, "<$file") or die "$P: Can't open ${file}\n";
247− my $text = do { local($/) ; <FILE> };
248− foreach my $line (keys %keyword_hash) {
249− if ($text =~ m/$keyword_hash{$line}/x) {
250− push(@keyword_tvi, $line);
266+ if (-f $file && ($keywords || $file_emails)) {
267+ open(my $f, '<', $file)
268+ or die "$P: Can't open $file: $!\n";
269+ my $text = do { local($/) ; <$f> };
270+ close($f);
271+ if ($keywords) {
272+ foreach my $line (keys %keyword_hash) {
273+ if ($text =~ m/$keyword_hash{$line}/x) {
274+ push(@keyword_tvi, $line);
275+ }
251276 }
252277 }
253− close(FILE);
278+ if ($file_emails) {
279+ my @poss_addr = $text =~ m$[A-Za-zÀ-ÿ\"\' \,\.\+-]*\s*[\,]*\s*[\(\<\{]{0,1}[A-Za-z0-9_\.\+-]+\@[A-Za-z0-9\.-]+\.[A-Za-z0-9]+[\)\>\}]{0,1}$g;
280+ push(@file_emails, clean_file_emails(@poss_addr));
281+ }
254282 }
255283 } else {
256284 my $file_cnt = @files;
257285 my $lastfile;
258− open(PATCH, "<$file") or die "$P: Can't open ${file}\n";
259− while (<PATCH>) {
286+
287+ open(my $patch, "< $file")
288+ or die "$P: Can't open $file: $!\n";
289+ while (<$patch>) {
260290 my $patch_line = $_;
261291 if (m/^\+\+\+\s+(\S+)/) {
262292 my $filename = $1;
@@ -276,7 +306,8 @@ foreach my $file (@ARGV) { · 13 unmodified lines
276306 }
277307 }
278308 }
279− close(PATCH);
309+ close($patch);
310+
280311 if ($file_cnt == @files) {
281312 warn "$P: file '${file}' doesn't appear to be a patch. "
282313 . "Add -f to options?\n";
@@ -285,6 +316,8 @@ foreach my $file (@ARGV) { · 2 unmodified lines
285316 }
286317 }
287318
319+@file_emails = uniq(@file_emails);
320+
288321 my @email_to = ();
289322 my @list_to = ();
290323 my @scm = ();
@@ -314,6 +347,7 @@ foreach my $file (@files) { · 23 unmodified lines
314347 if ($type eq 'X') {
315348 if (file_match_pattern($file, $value)) {
316349 $exclude = 1;
350+ last;
317351 }
318352 }
319353 }
@@ -340,12 +374,28 @@ foreach my $file (@files) { · 20 unmodified lines
340374 }
341375 }
342376
343− $tvi += ($end - $start);
344−
377+ $tvi = $end + 1;
345378 }
346379
347380 foreach my $line (sort {$hash{$b} <=> $hash{$a}} keys %hash) {
348381 add_categories($line);
382+ if ($sections) {
383+ my $i;
384+ my $start = find_starting_index($line);
385+ my $end = find_ending_index($line);
386+ for ($i = $start; $i < $end; $i++) {
387+ my $line = $typevalue[$i];
388+ if ($line =~ /^[FX]:/) { ##Restore file patterns
389+ $line =~ s/([^\\])\.([^\*])/$1\?$2/g;
390+ $line =~ s/([^\\])\.$/$1\?/g; ##Convert . back to ?
391+ $line =~ s/\\\./\./g; ##Convert \. to .
392+ $line =~ s/\.\*/\*/g; ##Convert .* to *
393+ }
394+ $line =~ s/^([A-Z]):/$1:\t/g;
395+ print("$line\n");
396+ }
397+ print("\n");
398+ }
349399 }
350400
351401 if ($email && $email_git) {
@@ -377,6 +427,14 @@ if ($email) { · 25 unmodified lines
377427 }
378428 }
379429 }
430+
431+ foreach my $email (@file_emails) {
432+ my ($name, $address) = parse_email($email);
433+
434+ my $tmp_email = format_email($name, $address, $email_usename);
435+ push_email_address($tmp_email, '');
436+ add_role($tmp_email, 'in file');
437+ }
380438 }
381439
382440 if ($email || $email_list) {
@@ -453,6 +511,7 @@ MAINTAINER field selection options: · 70 unmodified lines
453511 --remove-duplicates => minimize duplicate email names/addresses
454512 --roles => show roles (status:subsystem, git-signer, list, etc...)
455513 --rolestats => show roles and statistics (commits/total_commits, %)
514+ --file-emails => add email addresses found in -f file (default: 0 (off))
456515 --scm => print SCM tree(s) if any
457516 --status => print status if any
458517 --subsystem => print subsystem name if any
@@ -466,6 +525,7 @@ Output type options: · 7 unmodified lines
466525 Other options:
467526 --pattern-depth => Number of pattern directory traversals (default: 0 (all))
468527 --keywords => scan patch for keywords (default: 1 (on))
528+ --sections => print the entire subsystem sections with pattern matches
469529 --version => show version
470530 --help => show this help information
471531
@@ -545,7 +605,7 @@ sub parse_email { · 73 unmodified lines
545605 $name =~ s/^\"|\"$//g;
546606 $address =~ s/^\s+|\s+$//g;
547607
548− if ($name =~ /[^a-z0-9 \.\-]/i) { ##has "must quote" chars
608+ if ($name =~ /[^\w \-]/i) { ##has "must quote" chars
549609 $name =~ s/(?<!\\)"/\\"/g; ##escape quotes
550610 $name = "\"$name\"";
551611 }
@@ -562,7 +622,7 @@ sub format_email { · 10 unmodified lines
562622 $name =~ s/^\"|\"$//g;
563623 $address =~ s/^\s+|\s+$//g;
564624
565− if ($name =~ /[^a-z0-9 \.\-]/i) { ##has "must quote" chars
625+ if ($name =~ /[^\w \-]/i) { ##has "must quote" chars
566626 $name =~ s/(?<!\\)"/\\"/g; ##escape quotes
567627 $name = "\"$name\"";
568628 }
@@ -811,7 +871,9 @@ sub add_role { · 242 unmodified lines
811871 foreach my $entry (@email_to) {
812872 if ($email_remove_duplicates) {
813873 my ($entry_name, $entry_address) = parse_email($entry->[0]);
814− if ($name eq $entry_name || $address eq $entry_address) {
874+ if (($name eq $entry_name || $address eq $entry_address)
875+ && ($role eq "" || !($entry->[1] =~ m/$role/))
876+ ) {
815877 if ($entry->[1] eq "") {
816878 $entry->[1] = "$role";
817879 } else {
@@ -819,7 +881,9 @@ sub add_role { · 1 unmodified line
819881 }
820882 }
821883 } else {
822− if ($email eq $entry->[0]) {
884+ if ($email eq $entry->[0]
885+ && ($role eq "" || !($entry->[1] =~ m/$role/))
886+ ) {
823887 if ($entry->[1] eq "") {
824888 $entry->[1] = "$role";
825889 } else {
@@ -1099,6 +1163,51 @@ sub sort_and_uniq { · 273 unmodified lines
10991163 return @parms;
11001164 }
11011165
1166+sub clean_file_emails {
1167+ my (@file_emails) = @_;
1168+ my @fmt_emails = ();
1169+
1170+ foreach my $email (@file_emails) {
1171+ $email =~ s/[\(\<\{]{0,1}([A-Za-z0-9_\.\+-]+\@[A-Za-z0-9\.-]+)[\)\>\}]{0,1}/\<$1\>/g;
1172+ my ($name, $address) = parse_email($email);
1173+ if ($name eq '"[,\.]"') {
1174+ $name = "";
1175+ }
1176+
1177+ my @nw = split(/[^A-Za-zÀ-ÿ\'\,\.\+-]/, $name);
1178+ if (@nw > 2) {
1179+ my $first = $nw[@nw - 3];
1180+ my $middle = $nw[@nw - 2];
1181+ my $last = $nw[@nw - 1];
1182+
1183+ if (((length($first) == 1 && $first =~ m/[A-Za-z]/) ||
1184+ (length($first) == 2 && substr($first, -1) eq ".")) ||
1185+ (length($middle) == 1 ||
1186+ (length($middle) == 2 && substr($middle, -1) eq "."))) {
1187+ $name = "$first $middle $last";
1188+ } else {
1189+ $name = "$middle $last";
1190+ }
1191+ }
1192+
1193+ if (substr($name, -1) =~ /[,\.]/) {
1194+ $name = substr($name, 0, length($name) - 1);
1195+ } elsif (substr($name, -2) =~ /[,\.]"/) {
1196+ $name = substr($name, 0, length($name) - 2) . '"';
1197+ }
1198+
1199+ if (substr($name, 0, 1) =~ /[,\.]/) {
1200+ $name = substr($name, 1, length($name) - 1);
1201+ } elsif (substr($name, 0, 2) =~ /"[,\.]/) {
1202+ $name = '"' . substr($name, 2, length($name) - 2);
1203+ }
1204+
1205+ my $fmt_email = format_email($name, $address, $email_usename);
1206+ push(@fmt_emails, $fmt_email);
1207+ }
1208+ return @fmt_emails;
1209+}
1210+
11021211 sub merge_email {
11031212 my @lines;
11041213 my %saw;
@@ -1183,7 +1292,7 @@ sub rfc822_strip_comments { · 78 unmodified lines
11831292
11841293 # valid: returns true if the parameter is an RFC822 valid address
11851294 #
1186−sub rfc822_valid ($) {
1295+sub rfc822_valid {
11871296 my $s = rfc822_strip_comments(shift);
11881297
11891298 if (!$rfc822re) {
@@ -1203,7 +1312,7 @@ sub rfc822_valid ($) { · 13 unmodified lines
12031312 # from success with no addresses found, because an empty string is
12041313 # a valid list.
12051314
1206−sub rfc822_validlist ($) {
1315+sub rfc822_validlist {
12071316 my $s = rfc822_strip_comments(shift);
12081317
12091318 if (!$rfc822re) {
scripts/gfp-translate+1−1
@@ -19,7 +19,7 @@ usage() { · 18 unmodified lines
1919 exit 0
2020 }
2121
22−# Parse command-line arguements
22+# Parse command-line arguments
2323 while [ $# -gt 0 ]; do
2424 case $1 in
2525 --source)
scripts/kernel-doc+4−1
@@ -1424,6 +1424,8 @@ sub dump_struct($$) { · 1423 unmodified lines
14241424 $nested =~ s/\/\*.*?\*\///gos;
14251425 # strip kmemcheck_bitfield_{begin,end}.*;
14261426 $members =~ s/kmemcheck_bitfield_.*?;//gos;
1427+ # strip attributes
1428+ $members =~ s/__aligned\s*\(\d+\)//gos;
14271429
14281430 create_parameterlist($members, ';', $file);
14291431 check_sections($file, $declaration_name, "struct", $sectcheck, $struct_actual, $nested);
@@ -1728,6 +1730,7 @@ sub dump_function($$) { · 298 unmodified lines
17281730 $prototype =~ s/^noinline +//;
17291731 $prototype =~ s/__devinit +//;
17301732 $prototype =~ s/__init +//;
1733+ $prototype =~ s/__init_or_module +//;
17311734 $prototype =~ s/^#\s*define\s+//; #ak added
17321735 $prototype =~ s/__attribute__\s*\(\([a-z,]*\)\)//;
17331736
@@ -2103,7 +2106,7 @@ sub process_file($) { · 369 unmodified lines
21032106 $section = $newsection;
21042107 } elsif (/$doc_end/) {
21052108
2106− if ($contents ne "") {
2109+ if (($contents ne "") && ($contents ne "\n")) {
21072110 dump_section($file, $section, xml_escape($contents));
21082111 $section = $section_default;
21092112 $contents = "";