All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] Get maintainer script cleanups
@ 2010-02-19  7:01 Stephen Hemminger
  2010-02-19  7:01 ` [PATCH 1/3] get_maintainer: fix perlcritic warnings Stephen Hemminger
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Stephen Hemminger @ 2010-02-19  7:01 UTC (permalink / raw)
  To: Joe Perches; +Cc: linux-kernel

-- 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/3] get_maintainer: fix perlcritic warnings
  2010-02-19  7:01 [PATCH 0/3] Get maintainer script cleanups Stephen Hemminger
@ 2010-02-19  7:01 ` Stephen Hemminger
  2010-02-19 16:07   ` Joe Perches
  2010-02-19  7:01 ` [PATCH 2/3] get_maintainer: use references and closures Stephen Hemminger
  2010-02-19  7:01 ` [PATCH 3/3] get_maintainer: quote email address with period Stephen Hemminger
  2 siblings, 1 reply; 7+ messages in thread
From: Stephen Hemminger @ 2010-02-19  7:01 UTC (permalink / raw)
  To: Joe Perches; +Cc: linux-kernel

[-- Attachment #1: cleanup-get-maintainer.patch --]
[-- Type: text/plain, Size: 4089 bytes --]

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...

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>

---

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)


--- a/scripts/get_maintainer.pl	2010-02-18 21:58:16.326458296 -0800
+++ b/scripts/get_maintainer.pl	2010-02-18 22:10:58.451944275 -0800
@@ -173,8 +173,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 (<MAINT>) {
+open (my $maint, '<', "${lk_path}MAINTAINERS")
+    or die "$P: Can't open MAINTAINERS: $!\n";
+while (<$maint>) {
     my $line = $_;
 
     if ($line =~ m/^(\C):\s*(.*)/) {
@@ -199,13 +200,14 @@ while (<MAINT>) {
 	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 (<MAILMAP>) {
+    open(my $mailmap, '<', "${lk_path}.mailmap")
+	or warn "$P: Can't open .mailmap: $!\n";
+    while (<$mailmap>) {
 	my $line = $_;
 
 	next if ($line =~ m/^\s*#/);
@@ -224,7 +226,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
@@ -243,20 +245,23 @@ foreach my $file (@ARGV) {
     if ($from_filename) {
 	push(@files, $file);
 	if (-f $file && $keywords) {
-	    open(FILE, "<$file") or die "$P: Can't open ${file}\n";
-	    my $text = do { local($/) ; <FILE> };
+	    open(my $f, '<', $file)
+		or die "$P: Can't open $file: $!\n";
+	    my $text = do { local($/) ; <$f> };
 	    foreach my $line (keys %keyword_hash) {
 		if ($text =~ m/$keyword_hash{$line}/x) {
 		    push(@keyword_tvi, $line);
 		}
 	    }
-	    close(FILE);
+	    close($f);
 	}
     } else {
 	my $file_cnt = @files;
 	my $lastfile;
-	open(PATCH, "<$file") or die "$P: Can't open ${file}\n";
-	while (<PATCH>) {
+
+	open(my $patch, '<', $file)
+	    or die "$P: Can't open $file: $!\n";
+	while (<$patch>) {
 	    my $patch_line = $_;
 	    if (m/^\+\+\+\s+(\S+)/) {
 		my $filename = $1;
@@ -276,7 +281,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";
@@ -1183,7 +1189,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) {
@@ -1203,7 +1209,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) {

-- 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 2/3] get_maintainer: use references and closures
  2010-02-19  7:01 [PATCH 0/3] Get maintainer script cleanups Stephen Hemminger
  2010-02-19  7:01 ` [PATCH 1/3] get_maintainer: fix perlcritic warnings Stephen Hemminger
@ 2010-02-19  7:01 ` Stephen Hemminger
  2010-02-19 16:08   ` Joe Perches
  2010-02-19  7:01 ` [PATCH 3/3] get_maintainer: quote email address with period Stephen Hemminger
  2 siblings, 1 reply; 7+ messages in thread
From: Stephen Hemminger @ 2010-02-19  7:01 UTC (permalink / raw)
  To: Joe Perches; +Cc: linux-kernel

[-- Attachment #1: get-maintainer-closure.patch --]
[-- Type: text/plain, Size: 4548 bytes --]

Using eval on a string is considered bad practice in Perl because of the 
possiblity of errors at run time.  Better to use a closure for
the is VCx available test.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>

--- a/scripts/get_maintainer.pl	2010-02-18 22:11:36.885833644 -0800
+++ b/scripts/get_maintainer.pl	2010-02-18 22:44:47.638010342 -0800
@@ -69,11 +69,11 @@ my $rfc822_char = '[\\000-\\377]';
 
 # VCS command support: class-like functions and strings
 
-my %VCS_cmds;
+my $VCS_cmds;
 
 my %VCS_cmds_git = (
     "execute_cmd" => \&git_execute_cmd,
-    "available" => '(which("git") ne "") && (-d ".git")',
+    "available" => sub { (which("git") ne "") && (-d ".git") },
     "find_signers_cmd" => "git log --no-color --since=\$email_git_since -- \$file",
     "find_commit_signers_cmd" => "git log --no-color -1 \$commit",
     "blame_range_cmd" => "git blame -l -L \$diff_start,+\$diff_length \$file",
@@ -84,7 +84,7 @@ my %VCS_cmds_git = (
 
 my %VCS_cmds_hg = (
     "execute_cmd" => \&hg_execute_cmd,
-    "available" => '(which("hg") ne "") && (-d ".hg")',
+    "available" => sub { (which("hg") ne "") && (-d ".hg") },
     "find_signers_cmd" =>
 	"hg log --date=\$email_hg_since" .
 		" --template='commit {node}\\n{desc}\\n' -- \$file",
@@ -900,9 +900,9 @@ sub vcs_find_signers {
     my @lines = ();
     my $commits;
 
-    @lines = &{$VCS_cmds{"execute_cmd"}}($cmd);
+    @lines = &{$VCS_cmds->{"execute_cmd"}}($cmd);
 
-    my $pattern = $VCS_cmds{"commit_pattern"};
+    my $pattern = $VCS_cmds->{"commit_pattern"};
 
     $commits = grep(/$pattern/, @lines);	# of commits
 
@@ -928,10 +928,10 @@ sub vcs_save_commits {
     my @lines = ();
     my @commits = ();
 
-    @lines = &{$VCS_cmds{"execute_cmd"}}($cmd);
+    @lines = &{$VCS_cmds->{"execute_cmd"}}($cmd);
 
     foreach my $line (@lines) {
-	if ($line =~ m/$VCS_cmds{"blame_commit_pattern"}/) {
+	if ($line =~ m/$VCS_cmds->{"blame_commit_pattern"}/) {
 	    push(@commits, $1);
 	}
     }
@@ -946,10 +946,10 @@ sub vcs_blame {
 
     return @commits if (!(-f $file));
 
-    if (@range && $VCS_cmds{"blame_range_cmd"} eq "") {
+    if (@range && $VCS_cmds->{"blame_range_cmd"} eq "") {
 	my @all_commits = ();
 
-	$cmd = $VCS_cmds{"blame_file_cmd"};
+	$cmd = $VCS_cmds->{"blame_file_cmd"};
 	$cmd =~ s/(\$\w+)/$1/eeg;		#interpolate $cmd
 	@all_commits = vcs_save_commits($cmd);
 
@@ -970,12 +970,12 @@ sub vcs_blame {
 	    my $diff_start = $2;
 	    my $diff_length = $3;
 	    next if ("$file" ne "$diff_file");
-	    $cmd = $VCS_cmds{"blame_range_cmd"};
+	    $cmd = $VCS_cmds->{"blame_range_cmd"};
 	    $cmd =~ s/(\$\w+)/$1/eeg;		#interpolate $cmd
 	    push(@commits, vcs_save_commits($cmd));
 	}
     } else {
-	$cmd = $VCS_cmds{"blame_file_cmd"};
+	$cmd = $VCS_cmds->{"blame_file_cmd"};
 	$cmd =~ s/(\$\w+)/$1/eeg;		#interpolate $cmd
 	@commits = vcs_save_commits($cmd);
     }
@@ -985,16 +985,17 @@ sub vcs_blame {
 
 my $printed_novcs = 0;
 sub vcs_exists {
-    %VCS_cmds = %VCS_cmds_git;
-    return 1 if eval $VCS_cmds{"available"};
-    %VCS_cmds = %VCS_cmds_hg;
-    return 1 if eval $VCS_cmds{"available"};
-    %VCS_cmds = ();
+    $VCS_cmds = \%VCS_cmds_git;
+    return 1 if eval $VCS_cmds->{"available"}();
+    $VCS_cmds = \%VCS_cmds_hg;
+    return 1 if eval $VCS_cmds->{"available"}();
+    $VCS_cmds = undef;
+
     if (!$printed_novcs) {
-	warn("$P: No supported VCS found.  Add --nogit to options?\n");
-	warn("Using a git repository produces better results.\n");
-	warn("Try Linus Torvalds' latest git repository using:\n");
-	warn("git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git\n");
+	warn "$P: No supported VCS found.  Add --nogit to options?\n",
+	     "Using a git repository produces better results.\n",
+	     "Try Linus Torvalds' latest git repository using:\n",
+	"git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git\n";
 	$printed_novcs = 1;
     }
     return 0;
@@ -1050,7 +1051,7 @@ sub vcs_file_signoffs {
 
     return if (!vcs_exists());
 
-    my $cmd = $VCS_cmds{"find_signers_cmd"};
+    my $cmd = $VCS_cmds->{"find_signers_cmd"};
     $cmd =~ s/(\$\w+)/$1/eeg;		# interpolate $cmd
 
     ($commits, @signers) = vcs_find_signers($cmd);
@@ -1074,7 +1075,7 @@ sub vcs_file_blame {
 	my $commit_count;
 	my @commit_signers = ();
 
-	my $cmd = $VCS_cmds{"find_commit_signers_cmd"};
+	my $cmd = $VCS_cmds->{"find_commit_signers_cmd"};
 	$cmd =~ s/(\$\w+)/$1/eeg;	#interpolate $cmd
 
 	($commit_count, @commit_signers) = vcs_find_signers($cmd);

-- 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 3/3] get_maintainer: quote email address with period
  2010-02-19  7:01 [PATCH 0/3] Get maintainer script cleanups Stephen Hemminger
  2010-02-19  7:01 ` [PATCH 1/3] get_maintainer: fix perlcritic warnings Stephen Hemminger
  2010-02-19  7:01 ` [PATCH 2/3] get_maintainer: use references and closures Stephen Hemminger
@ 2010-02-19  7:01 ` Stephen Hemminger
  2010-02-19 16:08   ` Joe Perches
  2 siblings, 1 reply; 7+ messages in thread
From: Stephen Hemminger @ 2010-02-19  7:01 UTC (permalink / raw)
  To: Joe Perches; +Cc: linux-kernel

[-- Attachment #1: get-maintainer-vger.patch --]
[-- Type: text/plain, Size: 963 bytes --]

Picky mail systems won't accept email addresses where recipient
has period in name; ie. David S. Miller <davemloft.net> will not work.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>

--- a/scripts/get_maintainer.pl	2010-02-18 22:57:00.614708380 -0800
+++ b/scripts/get_maintainer.pl	2010-02-18 22:57:00.634708417 -0800
@@ -551,7 +551,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/(?<!\\)"/\\"/g;       ##escape quotes
 	$name = "\"$name\"";
     }
@@ -568,7 +568,7 @@ sub format_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/(?<!\\)"/\\"/g;       ##escape quotes
 	$name = "\"$name\"";
     }

-- 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/3] get_maintainer: fix perlcritic warnings
  2010-02-19  7:01 ` [PATCH 1/3] get_maintainer: fix perlcritic warnings Stephen Hemminger
@ 2010-02-19 16:07   ` Joe Perches
  0 siblings, 0 replies; 7+ messages in thread
From: Joe Perches @ 2010-02-19 16:07 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: linux-kernel, Andrew Morton

On Thu, 2010-02-18 at 23:01 -0800, Stephen Hemminger wrote:
> This patch fixes most of the warnings in the get_maintainer script.
> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>

Thanks Stephen.

Acked-by: Joe Perches <joe@perches.com>


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/3] get_maintainer: use references and closures
  2010-02-19  7:01 ` [PATCH 2/3] get_maintainer: use references and closures Stephen Hemminger
@ 2010-02-19 16:08   ` Joe Perches
  0 siblings, 0 replies; 7+ messages in thread
From: Joe Perches @ 2010-02-19 16:08 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: linux-kernel

On Thu, 2010-02-18 at 23:01 -0800, Stephen Hemminger wrote:
>      if (!$printed_novcs) {
> -	warn("$P: No supported VCS found.  Add --nogit to options?\n");
> -	warn("Using a git repository produces better results.\n");
> -	warn("Try Linus Torvalds' latest git repository using:\n");
> -	warn("git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git\n");
> +	warn "$P: No supported VCS found.  Add --nogit to options?\n",
> +	     "Using a git repository produces better results.\n",
> +	     "Try Linus Torvalds' latest git repository using:\n",
> +	"git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git\n";
>  	$printed_novcs = 1;

All other quoted string line continuations use periods.
Please use periods and resubmit.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 3/3] get_maintainer: quote email address with period
  2010-02-19  7:01 ` [PATCH 3/3] get_maintainer: quote email address with period Stephen Hemminger
@ 2010-02-19 16:08   ` Joe Perches
  0 siblings, 0 replies; 7+ messages in thread
From: Joe Perches @ 2010-02-19 16:08 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: linux-kernel, Andrew Morton

On Thu, 2010-02-18 at 23:01 -0800, Stephen Hemminger wrote:
> plain text document attachment (get-maintainer-vger.patch)
> Picky mail systems won't accept email addresses where recipient
> has period in name; ie. David S. Miller <davemloft.net> will not work.
> 
> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>

Acked-by: Joe Perches <joe@perches.com>



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-02-20  2:43 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-19  7:01 [PATCH 0/3] Get maintainer script cleanups Stephen Hemminger
2010-02-19  7:01 ` [PATCH 1/3] get_maintainer: fix perlcritic warnings Stephen Hemminger
2010-02-19 16:07   ` Joe Perches
2010-02-19  7:01 ` [PATCH 2/3] get_maintainer: use references and closures Stephen Hemminger
2010-02-19 16:08   ` Joe Perches
2010-02-19  7:01 ` [PATCH 3/3] get_maintainer: quote email address with period Stephen Hemminger
2010-02-19 16:08   ` Joe Perches

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.