Skip to content

Commit

Permalink
get_maintainer: fix perlcritic warnings
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Joe Perches <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Stephen Hemminger authored and torvalds committed Mar 6, 2010
1 parent 64f77f3 commit 22dd5b0
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions scripts/get_maintainer.pl
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,9 @@
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*(.*)/) {
Expand All @@ -211,13 +212,14 @@
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*#/);
Expand All @@ -236,7 +238,7 @@
$mailmap{$name} = \@arr;
}
}
close(MAILMAP);
close($mailmap);
}

## use the filenames on the command line or find the filenames in the patchfiles
Expand All @@ -262,9 +264,10 @@
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($/) ; <FILE> };
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) {
Expand All @@ -280,8 +283,10 @@
} 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;
Expand All @@ -301,7 +306,8 @@
}
}
}
close(PATCH);
close($patch);

if ($file_cnt == @files) {
warn "$P: file '${file}' doesn't appear to be a patch. "
. "Add -f to options?\n";
Expand Down Expand Up @@ -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) {
Expand All @@ -1306,7 +1312,7 @@ ($)
# 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) {
Expand Down

0 comments on commit 22dd5b0

Please sign in to comment.