From 3ad2f3fbb961429d2aa627465ae4829758bc7e07 Mon Sep 17 00:00:00 2001 From: Daniel Mack Date: Wed, 3 Feb 2010 08:01:28 +0800 Subject: tree-wide: Assorted spelling fixes In particular, several occurances of funny versions of 'success', 'unknown', 'therefore', 'acknowledge', 'argument', 'achieve', 'address', 'beginning', 'desirable', 'separate' and 'necessary' are fixed. Signed-off-by: Daniel Mack Cc: Joe Perches Cc: Junio C Hamano Signed-off-by: Jiri Kosina --- scripts/gfp-translate | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/gfp-translate b/scripts/gfp-translate index 073cb6d152a0..d81b968d864e 100644 --- a/scripts/gfp-translate +++ b/scripts/gfp-translate @@ -19,7 +19,7 @@ usage() { exit 0 } -# Parse command-line arguements +# Parse command-line arguments while [ $# -gt 0 ]; do case $1 in --source) -- cgit v1.2.3 From 03372dbbe618bfcd02f9c8cdbfe78e97e3aad43b Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Fri, 5 Mar 2010 13:43:00 -0800 Subject: scripts/get_maintainer.pl: add --file-emails, find embedded email addresses Add an imperfect option to search a source file for email addresses. New option: --file-emails or --fe email addresses in files are freeform text and are nearly impossible to parse. Still, might as well try to do a somewhat acceptable job of finding them. This code should find all addresses that are in the form addr@domain.tld The code assumes that up to 3 alphabetic words along with dashes, commas, and periods that preceed the email address are a name. If 3 words are found for the name, and one of the first two words are a single letter and period, or just a single letter then the 3 words are use as name otherwise the last 2 words are used. Some variants that are shown correctly: John Smith Random J. Developer Random J. Developer (rjd@tld.com) J. Random Developer rjd@tld.com Variants that are shown nominally correctly: Written by First Last (funny-addr@somecompany.com) is shown as: First Last Variants that are shown incorrectly: Some Really Long Name MontaVista Software, Inc. are returned as: Long Name "Software, Inc" --roles and --rolestats show "(in file)" for matches. For instance: Without -file-emails: $ ./scripts/get_maintainer.pl -f -nogit -roles net/core/netpoll.c David S. Miller (maintainer:NETWORKING [GENERAL]) linux-kernel@vger.kernel.org (open list) With -fe: $ ./scripts/get_maintainer.pl -f -fe -nogit -roles net/core/netpoll.c David S. Miller (maintainer:NETWORKING [GENERAL]) Matt Mackall (in file) Ingo Molnar (in file) linux-kernel@vger.kernel.org (open list) netdev@vger.kernel.org (open list:NETWORKING [GENERAL]) The number of email addresses in the file in not limited. Neither is the number of returned email addresses. Signed-off-by: Joe Perches Cc: Matt Mackall Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- scripts/get_maintainer.pl | 83 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 76 insertions(+), 7 deletions(-) (limited to 'scripts') diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl index 2f3230db7ffb..bff2390652c2 100755 --- a/scripts/get_maintainer.pl +++ b/scripts/get_maintainer.pl @@ -41,6 +41,7 @@ my $web = 0; my $subsystem = 0; my $status = 0; my $keywords = 1; +my $file_emails = 0; my $from_filename = 0; my $pattern_depth = 0; my $version = 0; @@ -120,6 +121,7 @@ if (!GetOptions( 'web!' => \$web, 'pattern-depth=i' => \$pattern_depth, 'k|keywords!' => \$keywords, + 'fe|file-emails!' => \$file_emails, 'f|file' => \$from_filename, 'v|version' => \$version, 'h|help' => \$help, @@ -232,6 +234,7 @@ if ($email_remove_duplicates) { my @files = (); my @range = (); my @keyword_tvi = (); +my @file_emails = (); foreach my $file (@ARGV) { ##if $file is a directory and it lacks a trailing slash, add one @@ -242,15 +245,21 @@ foreach my $file (@ARGV) { } if ($from_filename) { push(@files, $file); - if (-f $file && $keywords) { + if (-f $file && ($keywords || $file_emails)) { open(FILE, "<$file") or die "$P: Can't open ${file}\n"; my $text = do { local($/) ; }; - foreach my $line (keys %keyword_hash) { - if ($text =~ m/$keyword_hash{$line}/x) { - push(@keyword_tvi, $line); + close(FILE); + if ($keywords) { + foreach my $line (keys %keyword_hash) { + if ($text =~ m/$keyword_hash{$line}/x) { + push(@keyword_tvi, $line); + } } } - close(FILE); + if ($file_emails) { + 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; + push(@file_emails, clean_file_emails(@poss_addr)); + } } } else { my $file_cnt = @files; @@ -285,6 +294,8 @@ foreach my $file (@ARGV) { } } +@file_emails = uniq(@file_emails); + my @email_to = (); my @list_to = (); my @scm = (); @@ -377,6 +388,14 @@ if ($email) { } } } + + foreach my $email (@file_emails) { + my ($name, $address) = parse_email($email); + + my $tmp_email = format_email($name, $address, $email_usename); + push_email_address($tmp_email, ''); + add_role($tmp_email, 'in file'); + } } if ($email || $email_list) { @@ -453,6 +472,7 @@ MAINTAINER field selection options: --remove-duplicates => minimize duplicate email names/addresses --roles => show roles (status:subsystem, git-signer, list, etc...) --rolestats => show roles and statistics (commits/total_commits, %) + --file-emails => add email addresses found in -f file (default: 0 (off)) --scm => print SCM tree(s) if any --status => print status if any --subsystem => print subsystem name if any @@ -811,7 +831,9 @@ sub add_role { foreach my $entry (@email_to) { if ($email_remove_duplicates) { my ($entry_name, $entry_address) = parse_email($entry->[0]); - if ($name eq $entry_name || $address eq $entry_address) { + if (($name eq $entry_name || $address eq $entry_address) + && ($role eq "" || !($entry->[1] =~ m/$role/)) + ) { if ($entry->[1] eq "") { $entry->[1] = "$role"; } else { @@ -819,7 +841,9 @@ sub add_role { } } } else { - if ($email eq $entry->[0]) { + if ($email eq $entry->[0] + && ($role eq "" || !($entry->[1] =~ m/$role/)) + ) { if ($entry->[1] eq "") { $entry->[1] = "$role"; } else { @@ -1099,6 +1123,51 @@ sub sort_and_uniq { return @parms; } +sub clean_file_emails { + my (@file_emails) = @_; + my @fmt_emails = (); + + foreach my $email (@file_emails) { + $email =~ s/[\(\<\{]{0,1}([A-Za-z0-9_\.\+-]+\@[A-Za-z0-9\.-]+)[\)\>\}]{0,1}/\<$1\>/g; + my ($name, $address) = parse_email($email); + if ($name eq '"[,\.]"') { + $name = ""; + } + + my @nw = split(/[^A-Za-zÀ-ÿ\'\,\.\+-]/, $name); + if (@nw > 2) { + my $first = $nw[@nw - 3]; + my $middle = $nw[@nw - 2]; + my $last = $nw[@nw - 1]; + + if (((length($first) == 1 && $first =~ m/[A-Za-z]/) || + (length($first) == 2 && substr($first, -1) eq ".")) || + (length($middle) == 1 || + (length($middle) == 2 && substr($middle, -1) eq "."))) { + $name = "$first $middle $last"; + } else { + $name = "$middle $last"; + } + } + + if (substr($name, -1) =~ /[,\.]/) { + $name = substr($name, 0, length($name) - 1); + } elsif (substr($name, -2) =~ /[,\.]"/) { + $name = substr($name, 0, length($name) - 2) . '"'; + } + + if (substr($name, 0, 1) =~ /[,\.]/) { + $name = substr($name, 1, length($name) - 1); + } elsif (substr($name, 0, 2) =~ /"[,\.]/) { + $name = '"' . substr($name, 2, length($name) - 2); + } + + my $fmt_email = format_email($name, $address, $email_usename); + push(@fmt_emails, $fmt_email); + } + return @fmt_emails; +} + sub merge_email { my @lines; my %saw; -- cgit v1.2.3 From 4b76c9da611593eed6a13527c5ebd00c173624ad Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Fri, 5 Mar 2010 13:43:03 -0800 Subject: scripts/get_maintainer.pl: add --sections, print entire matched subsystem Print the complete contents of the matched subsystems in pattern match depth order. Sample output: $ ./scripts/get_maintainer.pl --sections -f drivers/net/usb/smsc95xx.c USB SMSC95XX ETHERNET DRIVER M:Steve Glendinning L:netdev@vger.kernel.org S:Supported F:drivers/net/usb/smsc95xx.* USB SUBSYSTEM M:Greg Kroah-Hartman L:linux-usb@vger.kernel.org W:http://www.linux-usb.org T:quilt kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/ S:Supported F:Documentation/usb/ F:drivers/net/usb/ F:drivers/usb/ F:include/linux/usb.h F:include/linux/usb/ NETWORKING DRIVERS L:netdev@vger.kernel.org W:http://www.linuxfoundation.org/en/Net T:git git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6.git S:Odd Fixes F:drivers/net/ F:include/linux/if_* F:include/linux/*device.h THE REST M:Linus Torvalds L:linux-kernel@vger.kernel.org Q:http://patchwork.kernel.org/project/LKML/list/ T:git git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git S:Buried alive in reporters F:* F:*/ Signed-off-by: Joe Perches Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- scripts/get_maintainer.pl | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) (limited to 'scripts') diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl index bff2390652c2..e54f72f6c341 100755 --- a/scripts/get_maintainer.pl +++ b/scripts/get_maintainer.pl @@ -41,6 +41,7 @@ my $web = 0; my $subsystem = 0; my $status = 0; my $keywords = 1; +my $sections = 0; my $file_emails = 0; my $from_filename = 0; my $pattern_depth = 0; @@ -121,6 +122,7 @@ if (!GetOptions( 'web!' => \$web, 'pattern-depth=i' => \$pattern_depth, 'k|keywords!' => \$keywords, + 'sections!' => \$sections, 'fe|file-emails!' => \$file_emails, 'f|file' => \$from_filename, 'v|version' => \$version, @@ -152,10 +154,20 @@ if ($output_rolestats) { $output_roles = 1; } -my $selections = $email + $scm + $status + $subsystem + $web; -if ($selections == 0) { - usage(); - die "$P: Missing required option: email, scm, status, subsystem or web\n"; +if ($sections) { + $email = 0; + $email_list = 0; + $scm = 0; + $status = 0; + $subsystem = 0; + $web = 0; + $keywords = 0; +} else { + my $selections = $email + $scm + $status + $subsystem + $web; + if ($selections == 0) { + usage(); + die "$P: Missing required option: email, scm, status, subsystem or web\n"; + } } if ($email && @@ -357,6 +369,21 @@ foreach my $file (@files) { foreach my $line (sort {$hash{$b} <=> $hash{$a}} keys %hash) { add_categories($line); + if ($sections) { + my $i; + my $start = find_starting_index($line); + my $end = find_ending_index($line); + for ($i = $start; $i < $end; $i++) { + my $line = $typevalue[$i]; + if ($line =~ /^[FX]:/) { ##Restore file patterns + $line =~ s/([^\\])\.([^\*])/$1\?$2/g; + $line =~ s/([^\\])\.$/$1\?/g; ##Convert . back to ? + $line =~ s/\\\./\./g; ##Convert \. to . + $line =~ s/\.\*/\*/g; ##Convert .* to * + } + print("$line\n"); + } + } } if ($email && $email_git) { @@ -486,6 +513,7 @@ Output type options: Other options: --pattern-depth => Number of pattern directory traversals (default: 0 (all)) --keywords => scan patch for keywords (default: 1 (on)) + --sections => print the entire subsystem sections with pattern matches --version => show version --help => show this help information -- cgit v1.2.3 From f11e9a1534c5e9dd4be97b30e6b24902e0ec325b Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Fri, 5 Mar 2010 13:43:03 -0800 Subject: scripts/get_maintainer.pl: change --sections to print in the same style as MAINTAINERS Signed-off-by: Joe Perches Cc: Stefan Richter Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- scripts/get_maintainer.pl | 2 ++ 1 file changed, 2 insertions(+) (limited to 'scripts') diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl index e54f72f6c341..4cd83fae87ca 100755 --- a/scripts/get_maintainer.pl +++ b/scripts/get_maintainer.pl @@ -381,8 +381,10 @@ foreach my $file (@files) { $line =~ s/\\\./\./g; ##Convert \. to . $line =~ s/\.\*/\*/g; ##Convert .* to * } + $line =~ s/^([A-Z]):/$1:\t/g; print("$line\n"); } + print("\n"); } } -- cgit v1.2.3 From 64f77f312b15f101bf6c4c65d5359ccc16e3f82b Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Fri, 5 Mar 2010 13:43:04 -0800 Subject: scripts/get_maintainer.pl: add ability to read from STDIN Doesn't need or accept '-' as a trailing option to read stdin. Doesn't print usage() after bad options. Adds --usage as command line equivalent of --help Suggested-by: Borislav Petkov Signed-off-by: Joe Perches Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- scripts/get_maintainer.pl | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'scripts') diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl index 4cd83fae87ca..f8baeeb8c3f7 100755 --- a/scripts/get_maintainer.pl +++ b/scripts/get_maintainer.pl @@ -126,7 +126,7 @@ if (!GetOptions( 'fe|file-emails!' => \$file_emails, 'f|file' => \$from_filename, 'v|version' => \$version, - 'h|help' => \$help, + 'h|help|usage' => \$help, )) { die "$P: invalid argument - use --help if necessary\n"; } @@ -141,9 +141,9 @@ if ($version != 0) { exit 0; } -if ($#ARGV < 0) { - usage(); - die "$P: argument missing: patchfile or -f file please\n"; +if (-t STDIN && !@ARGV) { + # We're talking to a terminal, but have no command line arguments. + die "$P: missing patchfile or -f file - use --help if necessary\n"; } if ($output_separator ne ", ") { @@ -165,7 +165,6 @@ if ($sections) { } else { my $selections = $email + $scm + $status + $subsystem + $web; if ($selections == 0) { - usage(); die "$P: Missing required option: email, scm, status, subsystem or web\n"; } } @@ -173,7 +172,6 @@ if ($sections) { if ($email && ($email_maintainer + $email_list + $email_subscriber_list + $email_git + $email_git_penguin_chiefs + $email_git_blame) == 0) { - usage(); die "$P: Please select at least 1 email option\n"; } @@ -248,12 +246,18 @@ my @range = (); my @keyword_tvi = (); my @file_emails = (); +if (!@ARGV) { + push(@ARGV, "&STDIN"); +} + foreach my $file (@ARGV) { - ##if $file is a directory and it lacks a trailing slash, add one - if ((-d $file)) { - $file =~ s@([^/])$@$1/@; - } elsif (!(-f $file)) { - die "$P: file '${file}' not found\n"; + if ($file ne "&STDIN") { + ##if $file is a directory and it lacks a trailing slash, add one + if ((-d $file)) { + $file =~ s@([^/])$@$1/@; + } elsif (!(-f $file)) { + die "$P: file '${file}' not found\n"; + } } if ($from_filename) { push(@files, $file); -- cgit v1.2.3 From 22dd5b0cba50a197aaa3bd2790a29ee2e8e4e372 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Fri, 5 Mar 2010 13:43:06 -0800 Subject: get_maintainer: fix perlcritic warnings perlcritic is a standard checker for Perl Best Practices. This patch fixes most of the warnings in the get_maintainer script. If kernel programmers are going to have checkpatch they should write clean scripts as well... Bareword file handle opened at line 176, column 1. See pages 202,204 of PBP. (Severity: 5) Two-argument "open" used at line 176, column 1. See page 207 of PBP. (Severity: 5) Bareword file handle opened at line 207, column 5. See pages 202,204 of PBP. (Severity: 5) Two-argument "open" used at line 207, column 5. See page 207 of PBP. (Severity: 5) Bareword file handle opened at line 246, column 6. See pages 202,204 of PBP. (Severity: 5) Two-argument "open" used at line 246, column 6. See page 207 of PBP. (Severity: 5) Bareword file handle opened at line 258, column 2. See pages 202,204 of PBP. (Severity: 5) Two-argument "open" used at line 258, column 2. See page 207 of PBP. (Severity: 5) Expression form of "eval" at line 983, column 17. See page 161 of PBP. (Severity: 5) Expression form of "eval" at line 985, column 17. See page 161 of PBP. (Severity: 5) Subroutine prototypes used at line 1186, column 1. See page 194 of PBP. (Severity: 5) Subroutine prototypes used at line 1206, column 1. See page 194 of PBP. (Severity: 5) Signed-off-by: Stephen Hemminger Acked-by: Joe Perches Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- scripts/get_maintainer.pl | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) (limited to 'scripts') diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl index f8baeeb8c3f7..9bb094138dd8 100755 --- a/scripts/get_maintainer.pl +++ b/scripts/get_maintainer.pl @@ -185,8 +185,9 @@ if (!top_of_kernel_tree($lk_path)) { my @typevalue = (); my %keyword_hash; -open(MAINT, "<${lk_path}MAINTAINERS") || die "$P: Can't open MAINTAINERS\n"; -while () { +open (my $maint, '<', "${lk_path}MAINTAINERS") + or die "$P: Can't open MAINTAINERS: $!\n"; +while (<$maint>) { my $line = $_; if ($line =~ m/^(\C):\s*(.*)/) { @@ -211,13 +212,14 @@ while () { push(@typevalue, $line); } } -close(MAINT); +close($maint); my %mailmap; if ($email_remove_duplicates) { - open(MAILMAP, "<${lk_path}.mailmap") || warn "$P: Can't open .mailmap\n"; - while () { + open(my $mailmap, '<', "${lk_path}.mailmap") + or warn "$P: Can't open .mailmap: $!\n"; + while (<$mailmap>) { my $line = $_; next if ($line =~ m/^\s*#/); @@ -236,7 +238,7 @@ if ($email_remove_duplicates) { $mailmap{$name} = \@arr; } } - close(MAILMAP); + close($mailmap); } ## use the filenames on the command line or find the filenames in the patchfiles @@ -262,9 +264,10 @@ foreach my $file (@ARGV) { if ($from_filename) { push(@files, $file); if (-f $file && ($keywords || $file_emails)) { - open(FILE, "<$file") or die "$P: Can't open ${file}\n"; - my $text = do { local($/) ; }; - close(FILE); + open(my $f, '<', $file) + or die "$P: Can't open $file: $!\n"; + my $text = do { local($/) ; <$f> }; + close($f); if ($keywords) { foreach my $line (keys %keyword_hash) { if ($text =~ m/$keyword_hash{$line}/x) { @@ -280,8 +283,10 @@ foreach my $file (@ARGV) { } else { my $file_cnt = @files; my $lastfile; - open(PATCH, "<$file") or die "$P: Can't open ${file}\n"; - while () { + + open(my $patch, '<', $file) + or die "$P: Can't open $file: $!\n"; + while (<$patch>) { my $patch_line = $_; if (m/^\+\+\+\s+(\S+)/) { my $filename = $1; @@ -301,7 +306,8 @@ foreach my $file (@ARGV) { } } } - close(PATCH); + close($patch); + if ($file_cnt == @files) { warn "$P: file '${file}' doesn't appear to be a patch. " . "Add -f to options?\n"; @@ -1286,7 +1292,7 @@ sub rfc822_strip_comments { # valid: returns true if the parameter is an RFC822 valid address # -sub rfc822_valid ($) { +sub rfc822_valid { my $s = rfc822_strip_comments(shift); if (!$rfc822re) { @@ -1306,7 +1312,7 @@ sub rfc822_valid ($) { # from success with no addresses found, because an empty string is # a valid list. -sub rfc822_validlist ($) { +sub rfc822_validlist { my $s = rfc822_strip_comments(shift); if (!$rfc822re) { -- cgit v1.2.3 From a63ceb4c36a7674f7efa90e8ba96b44a3989d717 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Fri, 5 Mar 2010 13:43:06 -0800 Subject: get_maintainer: quote email address with period Picky mail systems won't accept email addresses where recipient has period in name; ie. David S. Miller will not work. Signed-off-by: Stephen Hemminger Acked-by: Joe Perches Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- scripts/get_maintainer.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl index 9bb094138dd8..b61002dceaba 100755 --- a/scripts/get_maintainer.pl +++ b/scripts/get_maintainer.pl @@ -605,7 +605,7 @@ sub parse_email { $name =~ s/^\"|\"$//g; $address =~ s/^\s+|\s+$//g; - if ($name =~ /[^a-z0-9 \.\-]/i) { ##has "must quote" chars + if ($name =~ /[^\w \-]/i) { ##has "must quote" chars $name =~ s/(? Date: Fri, 5 Mar 2010 13:43:07 -0800 Subject: scripts/get_maintainer.pl: fix possible infinite loop If MAINTAINERS section entries are misformatted, it was possible to have an infinite loop. Correct the defect by always moving the index to the end of section + 1 Also, exit check for exclude as soon as possible. Signed-off-by: Joe Perches Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- scripts/get_maintainer.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl index b61002dceaba..f76f3d13276d 100755 --- a/scripts/get_maintainer.pl +++ b/scripts/get_maintainer.pl @@ -347,6 +347,7 @@ foreach my $file (@files) { if ($type eq 'X') { if (file_match_pattern($file, $value)) { $exclude = 1; + last; } } } @@ -373,8 +374,7 @@ foreach my $file (@files) { } } - $tvi += ($end - $start); - + $tvi = $end + 1; } foreach my $line (sort {$hash{$b} <=> $hash{$a}} keys %hash) { -- cgit v1.2.3 From 8f53a9b80f011080555c498d2ca2dc6b1a77c42c Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Fri, 5 Mar 2010 13:43:48 -0800 Subject: scripts/checkpatch.pl: add WARN on sizeof(&foo) sizeof(&foo) is frequently an error. Warn on its use. Signed-off-by: Joe Perches Cc: Andy Whitcroft Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- scripts/checkpatch.pl | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'scripts') diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 3257d3d96767..309050f30874 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -2572,6 +2572,11 @@ sub process { WARN("plain inline is preferred over $1\n" . $herecurr); } +# check for sizeof(&) + if ($line =~ /\bsizeof\s*\(\s*\&/) { + WARN("sizeof(& should be avoided\n" . $herecurr); + } + # check for new externs in .c files. if ($realfile =~ /\.c$/ && defined $stat && $stat =~ /^.\s*(?:extern\s+)?$Type\s+($Ident)(\s*)\(/s) -- cgit v1.2.3 From 42bdf74c95b6935f3c09a09ba4bead6cad11b540 Mon Sep 17 00:00:00 2001 From: Hidetoshi Seto Date: Fri, 5 Mar 2010 13:43:50 -0800 Subject: checkpatch: trivial fix for trailing statements check In case if the statement and the conditional are in one line, the line appears in the report doubly. And items of this check have no blank line before the next item. This patch fixes these trivial problems, to improve readability of the report. [sample.c] > if (cond1 > && cond2 > && cond3) func_foo(); > > if (cond4) func_bar(); Before: > ERROR: trailing statements should be on next line > #1: FILE: sample.c:1: > +if (cond1 > [...] > + && cond3) func_foo(); > ERROR: trailing statements should be on next line > #5: FILE: sample.c:5: > +if (cond4) func_bar(); > +if (cond4) func_bar(); > total: 2 errors, 0 warnings, 5 lines checked After: > ERROR: trailing statements should be on next line > #1: FILE: sample.c:1: > +if (cond1 > [...] > + && cond3) func_foo(); > > ERROR: trailing statements should be on next line > #5: FILE: sample.c:5: > +if (cond4) func_bar(); > > total: 2 errors, 0 warnings, 5 lines checked Signed-off-by: Hidetoshi Seto Cc: Andy Whitcroft Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- scripts/checkpatch.pl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 309050f30874..3e4099a6df51 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -2182,8 +2182,10 @@ sub process { # Find out how long the conditional actually is. my @newlines = ($c =~ /\n/gs); my $cond_lines = 1 + $#newlines; + my $stat_real = ''; - my $stat_real = raw_line($linenr, $cond_lines); + $stat_real = raw_line($linenr, $cond_lines) + . "\n" if ($cond_lines); if (defined($stat_real) && $cond_lines > 1) { $stat_real = "[...]\n$stat_real"; } -- cgit v1.2.3 From 691e669ba8c64d31ac08d87b1751e6acfa3ff65e Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Fri, 5 Mar 2010 13:43:51 -0800 Subject: checkpatch.pl: allow > 80 char lines for logging functions not just printk Signed-off-by: Joe Perches Cc: Andy Whitcroft Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- scripts/checkpatch.pl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 3e4099a6df51..9a3894dbf752 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -189,6 +189,14 @@ our $typeTypedefs = qr{(?x: atomic_t )}; +our $logFunctions = qr{(?x: + printk| + pr_(debug|dbg|vdbg|devel|info|warning|err|notice|alert|crit|emerg|cont)| + dev_(printk|dbg|vdbg|info|warn|err|notice|alert|crit|emerg|WARN)| + WARN| + panic +)}; + our @typeList = ( qr{void}, qr{(?:unsigned\s+)?char}, @@ -1377,7 +1385,7 @@ sub process { #80 column limit if ($line =~ /^\+/ && $prevrawline !~ /\/\*\*/ && $rawline !~ /^.\s*\*\s*\@$Ident\s/ && - $line !~ /^\+\s*printk\s*\(\s*(?:KERN_\S+\s*)?"[X\t]*"\s*(?:,|\)\s*;)\s*$/ && + $line !~ /^\+\s*$logFunctions\s*\(\s*(?:KERN_\S+\s*)?"[X\t]*"\s*(?:,|\)\s*;)\s*$/ && $length > 80) { WARN("line over 80 characters\n" . $herecurr); -- cgit v1.2.3 From 52131292c069b74f4b5f3c786ff66ff6e82b0e69 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Fri, 5 Mar 2010 13:43:51 -0800 Subject: checkpatch: fix false positive on __initconst checkpatch falsely complained about '__initconst' because it thought the 'const' needed a space before. Fix this by changing the list of attributes: - add '__initconst' - force plain 'init' to contain a word-boundary at the end Signed-off-by: Wolfram Sang Cc: Andy Whitcroft Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- scripts/checkpatch.pl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 9a3894dbf752..1530dbf1dab5 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -145,11 +145,14 @@ our $Sparse = qr{ __kprobes| __ref }x; + +# Notes to $Attribute: +# We need \b after 'init' otherwise 'initconst' will cause a false positive in a check our $Attribute = qr{ const| __read_mostly| __kprobes| - __(?:mem|cpu|dev|)(?:initdata|init)| + __(?:mem|cpu|dev|)(?:initdata|initconst|init\b)| ____cacheline_aligned| ____cacheline_aligned_in_smp| ____cacheline_internodealigned_in_smp| -- cgit v1.2.3 From 22fd2d3e4f75a2596ccdfdcbdfd505c9c60bf346 Mon Sep 17 00:00:00 2001 From: Stefani Seibold Date: Fri, 5 Mar 2010 13:43:52 -0800 Subject: checkpatch.pl: add union and struct to the exceptions list Here is a small code snippet, which will be complained about by checkpatch.pl: #define __STRUCT_KFIFO_COMMON(recsize, ptrtype) \ union { \ struct { \ unsigned int in; \ unsigned int out; \ }; \ char rectype[recsize]; \ ptrtype *ptr; \ const ptrtype *ptr_const; \ }; This construct is legal and safe, so checkpatch.pl should accept this. It should be also true for struct defined in a macro. Add the `struct' and `union' keywords to the exceptions list of the checkpatch.pl script, to prevent error message "Macros with multiple statements should be enclosed in a do - while loop". Otherwise it is not possible to build a struct or union with a macro. Signed-off-by: Stefani Seibold Cc: Andy Whitcroft Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- scripts/checkpatch.pl | 2 ++ 1 file changed, 2 insertions(+) (limited to 'scripts') diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 1530dbf1dab5..623d07b97727 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -2361,6 +2361,8 @@ sub process { DECLARE_PER_CPU| DEFINE_PER_CPU| __typeof__\(| + union| + struct| \.$Ident\s*=\s*| ^\"|\"$ }x; -- cgit v1.2.3 From 79404849e90a41ea2109bd0e2f7c7164b0c4ce73 Mon Sep 17 00:00:00 2001 From: Emese Revfy Date: Fri, 5 Mar 2010 13:43:53 -0800 Subject: checkpatch.pl: extend list of expected-to-be-const structures Based on Arjan's suggestion, extend the list of ops structures that should be const. Signed-off-by: Emese Revfy Cc: Andy Whitcroft Cc: Arjan van de Ven Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- scripts/checkpatch.pl | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 623d07b97727..1a93ac265c31 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -2654,9 +2654,46 @@ sub process { if ($line =~ /^.\s*__initcall\s*\(/) { WARN("please use device_initcall() instead of __initcall()\n" . $herecurr); } -# check for struct file_operations, ensure they are const. +# check for various ops structs, ensure they are const. + my $struct_ops = qr{acpi_dock_ops| + address_space_operations| + backlight_ops| + block_device_operations| + dentry_operations| + dev_pm_ops| + dma_map_ops| + extent_io_ops| + file_lock_operations| + file_operations| + hv_ops| + ide_dma_ops| + intel_dvo_dev_ops| + item_operations| + iwl_ops| + kgdb_arch| + kgdb_io| + kset_uevent_ops| + lock_manager_operations| + microcode_ops| + mtrr_ops| + neigh_ops| + nlmsvc_binding| + pci_raw_ops| + pipe_buf_operations| + platform_hibernation_ops| + platform_suspend_ops| + proto_ops| + rpc_pipe_ops| + seq_operations| + snd_ac97_build_ops| + soc_pcmcia_socket_ops| + stacktrace_ops| + sysfs_ops| + tty_operations| + usb_mon_operations| + wd_ops}x; if ($line !~ /\bconst\b/ && - $line =~ /\bstruct\s+(file_operations|seq_operations)\b/) { + $line =~ /\bstruct\s+($struct_ops)\b/) { WARN("struct $1 should normally be const\n" . $herecurr); } -- cgit v1.2.3 From 08e4436566250cb98b3f3ac37643b1cf09481256 Mon Sep 17 00:00:00 2001 From: Alberto Panizzo Date: Fri, 5 Mar 2010 13:43:54 -0800 Subject: checkpatch.pl: warn if an adding line introduce spaces before tabs. Signed-off-by: Alberto Panizzo Cc: Andy Whitcroft Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- scripts/checkpatch.pl | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'scripts') diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 1a93ac265c31..cf4e44cf3c27 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -1422,6 +1422,12 @@ sub process { ERROR("code indent should use tabs where possible\n" . $herevet); } +# check for space before tabs. + if ($rawline =~ /^\+/ && $rawline =~ / \t/) { + my $herevet = "$here\n" . cat_vet($rawline) . "\n"; + WARN("please, no space before tabs\n" . $herevet); + } + # check we are in a valid C source file if not then ignore this hunk next if ($realfile !~ /\.(h|c)$/); -- cgit v1.2.3 From 5e79d96eed306a8b4af67b3f35f6867edfabeebc Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Fri, 5 Mar 2010 13:43:55 -0800 Subject: checkpatch: warn on unnecessary spaces before quoted newlines Signed-off-by: Joe Perches Cc: Andy Whitcroft Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- scripts/checkpatch.pl | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'scripts') diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index cf4e44cf3c27..a4d74344d805 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -1394,6 +1394,11 @@ sub process { WARN("line over 80 characters\n" . $herecurr); } +# check for spaces before a quoted newline + if ($rawline =~ /^.*\".*\s\\n/) { + WARN("unnecessary whitespace before a quoted newline\n" . $herecurr); + } + # check for adding lines without a newline. if ($line =~ /^\+/ && defined $lines[$linenr] && $lines[$linenr] =~ /^\\ No newline at end of file/) { WARN("adding a line without newline at end of file\n" . $herecurr); -- cgit v1.2.3 From 4c98ecaf350737cd424eb94140e9e9f1a3408956 Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Wed, 10 Mar 2010 15:22:02 -0800 Subject: scripts/kernel-doc: fix empty function description section scripts/kernel-doc mishandles a function that has a multi-line function short description and no function parameters. The observed problem was from drivers/scsi/scsi_netlink.c: /** * scsi_netlink_init - Called by SCSI subsystem to intialize * the SCSI transport netlink interface * **/ kernel-doc treated the " * " line as a Description: section with only a newline character in the Description contents. This caused output_highlight() to complain: "output_highlight got called with no args?", plus produce a perl call stack backtrace. The fix is just to ignore Description sections if they only contain "\n". Signed-off-by: Randy Dunlap Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- scripts/kernel-doc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/kernel-doc b/scripts/kernel-doc index 208ad3b0ca51..c7865c362d28 100755 --- a/scripts/kernel-doc +++ b/scripts/kernel-doc @@ -2103,7 +2103,7 @@ sub process_file($) { $section = $newsection; } elsif (/$doc_end/) { - if ($contents ne "") { + if (($contents ne "") && ($contents ne "\n")) { dump_section($file, $section, xml_escape($contents)); $section = $section_default; $contents = ""; -- cgit v1.2.3 From ef5da59f12602815baa8fad98241b77dedea3b31 Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Tue, 23 Mar 2010 13:35:14 -0700 Subject: scripts/kernel-doc: handle struct member __aligned scripts/kernel-doc erroneously says: Warning(include/linux/skbuff.h:410): Excess struct/union/enum/typedef member 'cb' description in 'sk_buff' on this line in struct sk_buff: char cb[48] __aligned(8); due to treating the last field as the struct member name, so teach kernel-doc to ignore __aligned(x) in structs. Signed-off-by: Randy Dunlap Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- scripts/kernel-doc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'scripts') diff --git a/scripts/kernel-doc b/scripts/kernel-doc index c7865c362d28..c297eb4785d6 100755 --- a/scripts/kernel-doc +++ b/scripts/kernel-doc @@ -1424,6 +1424,8 @@ sub dump_struct($$) { $nested =~ s/\/\*.*?\*\///gos; # strip kmemcheck_bitfield_{begin,end}.*; $members =~ s/kmemcheck_bitfield_.*?;//gos; + # strip attributes + $members =~ s/__aligned\s*\(\d+\)//gos; create_parameterlist($members, ';', $file); check_sections($file, $declaration_name, "struct", $sectcheck, $struct_actual, $nested); -- cgit v1.2.3 From 3a4df13d2420ae1998e5c7d26275f8714e84da30 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Tue, 23 Mar 2010 13:35:18 -0700 Subject: get_maintainer: repair STDIN usage Commit 22dd5b0cba50a197aaa3bd2790a29ee2e8e4e372 (fix perlcritic warnings) broke the ability to handle STDIN because the three argument version of open() cannot handle standard IO-streams (which is mentioned in PerlBestPractices, too). Signed-off-by: Wolfram Sang Cc: Stephen Hemminger Acked-by: Joe Perches Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- scripts/get_maintainer.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl index f76f3d13276d..6f97a13bcee4 100755 --- a/scripts/get_maintainer.pl +++ b/scripts/get_maintainer.pl @@ -284,7 +284,7 @@ foreach my $file (@ARGV) { my $file_cnt = @files; my $lastfile; - open(my $patch, '<', $file) + open(my $patch, "< $file") or die "$P: Can't open $file: $!\n"; while (<$patch>) { my $patch_line = $_; -- cgit v1.2.3 From 20072205fcdf7d85cd3101f1f11dfab333c5fd0c Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Tue, 23 Mar 2010 13:35:24 -0700 Subject: scripts/kernel-doc: fix fatal error on function prototype Fix a fatal error in scripts/kernel-doc when a function signature uses __init_or_module (just ignore that string): Error(drivers/base/platform.c:568): cannot understand prototype: 'struct platform_device * __init_or_module platform_create_bundle(struct platform_driver *driver, int (*probe)(struct platform_device *), struct resource *res, unsigned int n_res, const void *data, size_t size) ' Signed-off-by: Randy Dunlap Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- scripts/kernel-doc | 1 + 1 file changed, 1 insertion(+) (limited to 'scripts') diff --git a/scripts/kernel-doc b/scripts/kernel-doc index c297eb4785d6..fcdfb245a575 100755 --- a/scripts/kernel-doc +++ b/scripts/kernel-doc @@ -1730,6 +1730,7 @@ sub dump_function($$) { $prototype =~ s/^noinline +//; $prototype =~ s/__devinit +//; $prototype =~ s/__init +//; + $prototype =~ s/__init_or_module +//; $prototype =~ s/^#\s*define\s+//; #ak added $prototype =~ s/__attribute__\s*\(\([a-z,]*\)\)//; -- cgit v1.2.3