summaryrefslogtreecommitdiff
path: root/scripts/checkincludes.pl
diff options
context:
space:
mode:
authorStephen Hemminger <shemminger@vyatta.com>2010-02-22 15:17:12 -0800
committerMichal Marek <mmarek@suse.cz>2010-03-07 21:19:57 +0100
commit3da27157316cbcce326d56faa0a7a5cadc7ae507 (patch)
tree0820dd4c307171f6013a4620028c3bb4e7287b15 /scripts/checkincludes.pl
parent1f2a144f5ab5e836b5ca8f67bd76b759fa947751 (diff)
downloadlinux-3.10-3da27157316cbcce326d56faa0a7a5cadc7ae507.tar.gz
linux-3.10-3da27157316cbcce326d56faa0a7a5cadc7ae507.tar.bz2
linux-3.10-3da27157316cbcce326d56faa0a7a5cadc7ae507.zip
checkincludes: fix perlcritic warnings
Turn on strict checking. Use local file handles. Use three argument open. Signed-off-by: Stephen Hemminger <shemminger@vyatta.com> Cc: Cong Wang <amwang@redhat.com> Cc: Michal Marek <mmarek@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Michal Marek <mmarek@suse.cz>
Diffstat (limited to 'scripts/checkincludes.pl')
-rwxr-xr-xscripts/checkincludes.pl24
1 files changed, 14 insertions, 10 deletions
diff --git a/scripts/checkincludes.pl b/scripts/checkincludes.pl
index 676ddc07d6f..97b2c6143fe 100755
--- a/scripts/checkincludes.pl
+++ b/scripts/checkincludes.pl
@@ -11,6 +11,8 @@
# you do have real dups and do not have them under #ifdef's. You
# could also just review the results.
+use strict;
+
sub usage {
print "Usage: checkincludes.pl [-r]\n";
print "By default we just warn of duplicates\n";
@@ -35,23 +37,24 @@ if ($#ARGV >= 1) {
}
}
-foreach $file (@ARGV) {
- open(FILE, $file) or die "Cannot open $file: $!.\n";
+foreach my $file (@ARGV) {
+ open(my $f, '<', $file)
+ or die "Cannot open $file: $!.\n";
my %includedfiles = ();
my @file_lines = ();
- while (<FILE>) {
+ while (<$f>) {
if (m/^\s*#\s*include\s*[<"](\S*)[>"]/o) {
++$includedfiles{$1};
}
push(@file_lines, $_);
}
- close(FILE);
+ close($f);
if (!$remove) {
- foreach $filename (keys %includedfiles) {
+ foreach my $filename (keys %includedfiles) {
if ($includedfiles{$filename} > 1) {
print "$file: $filename is included more than once.\n";
}
@@ -59,27 +62,28 @@ foreach $file (@ARGV) {
next;
}
- open(FILE,">$file") || die("Cannot write to $file: $!");
+ open($f, '>', $file)
+ or die("Cannot write to $file: $!");
my $dups = 0;
foreach (@file_lines) {
if (m/^\s*#\s*include\s*[<"](\S*)[>"]/o) {
- foreach $filename (keys %includedfiles) {
+ foreach my $filename (keys %includedfiles) {
if ($1 eq $filename) {
if ($includedfiles{$filename} > 1) {
$includedfiles{$filename}--;
$dups++;
} else {
- print FILE $_;
+ print {$f} $_;
}
}
}
} else {
- print FILE $_;
+ print {$f} $_;
}
}
if ($dups > 0) {
print "$file: removed $dups duplicate includes\n";
}
- close(FILE);
+ close($f);
}