History

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)

Stephen Hemminger committed 16 years ago

Commit 22dd5b01 parent 64f77f31 file · +20 −14Browse files

Showing the changes to scripts (1 of 1 file). Show all

Unified · Split

scripts/get_maintainer.pl+20−14
@@ -185,8 +185,9 @@ if (!top_of_kernel_tree($lk_path)) { · 184 unmodified lines
185185 my @typevalue = ();
186186 my %keyword_hash;
187187
188−open(MAINT, "<${lk_path}MAINTAINERS") || die "$P: Can't open MAINTAINERS\n";
189−while (<MAINT>) {
188+open (my $maint, '<', "${lk_path}MAINTAINERS")
189+ or die "$P: Can't open MAINTAINERS: $!\n";
190+while (<$maint>) {
190191 my $line = $_;
191192
192193 if ($line =~ m/^(\C):\s*(.*)/) {
@@ -211,13 +212,14 @@ while (<MAINT>) { · 18 unmodified lines
211212 push(@typevalue, $line);
212213 }
213214 }
214−close(MAINT);
215+close($maint);
215216
216217 my %mailmap;
217218
218219 if ($email_remove_duplicates) {
219− open(MAILMAP, "<${lk_path}.mailmap") || warn "$P: Can't open .mailmap\n";
220− while (<MAILMAP>) {
220+ open(my $mailmap, '<', "${lk_path}.mailmap")
221+ or warn "$P: Can't open .mailmap: $!\n";
222+ while (<$mailmap>) {
221223 my $line = $_;
222224
223225 next if ($line =~ m/^\s*#/);
@@ -236,7 +238,7 @@ if ($email_remove_duplicates) { · 12 unmodified lines
236238 $mailmap{$name} = \@arr;
237239 }
238240 }
239− close(MAILMAP);
241+ close($mailmap);
240242 }
241243
242244 ## use the filenames on the command line or find the filenames in the patchfiles
@@ -262,9 +264,10 @@ foreach my $file (@ARGV) { · 19 unmodified lines
262264 if ($from_filename) {
263265 push(@files, $file);
264266 if (-f $file && ($keywords || $file_emails)) {
265− open(FILE, "<$file") or die "$P: Can't open ${file}\n";
266− my $text = do { local($/) ; <FILE> };
267− close(FILE);
267+ open(my $f, '<', $file)
268+ or die "$P: Can't open $file: $!\n";
269+ my $text = do { local($/) ; <$f> };
270+ close($f);
268271 if ($keywords) {
269272 foreach my $line (keys %keyword_hash) {
270273 if ($text =~ m/$keyword_hash{$line}/x) {
@@ -280,8 +283,10 @@ foreach my $file (@ARGV) { · 9 unmodified lines
280283 } else {
281284 my $file_cnt = @files;
282285 my $lastfile;
283− open(PATCH, "<$file") or die "$P: Can't open ${file}\n";
284− while (<PATCH>) {
286+
287+ open(my $patch, '<', $file)
288+ or die "$P: Can't open $file: $!\n";
289+ while (<$patch>) {
285290 my $patch_line = $_;
286291 if (m/^\+\+\+\s+(\S+)/) {
287292 my $filename = $1;
@@ -301,7 +306,8 @@ foreach my $file (@ARGV) { · 13 unmodified lines
301306 }
302307 }
303308 }
304− close(PATCH);
309+ close($patch);
310+
305311 if ($file_cnt == @files) {
306312 warn "$P: file '${file}' doesn't appear to be a patch. "
307313 . "Add -f to options?\n";
@@ -1286,7 +1292,7 @@ sub rfc822_strip_comments { · 978 unmodified lines
12861292
12871293 # valid: returns true if the parameter is an RFC822 valid address
12881294 #
1289−sub rfc822_valid ($) {
1295+sub rfc822_valid {
12901296 my $s = rfc822_strip_comments(shift);
12911297
12921298 if (!$rfc822re) {
@@ -1306,7 +1312,7 @@ sub rfc822_valid ($) { · 13 unmodified lines
13061312 # from success with no addresses found, because an empty string is
13071313 # a valid list.
13081314
1309−sub rfc822_validlist ($) {
1315+sub rfc822_validlist {
13101316 my $s = rfc822_strip_comments(shift);
13111317
13121318 if (!$rfc822re) {