[Rt-commit] rt branch, 3.8/perlcritic, updated. rt-3.8.10-184-g77954ca
Alex Vandiver
alexmv at bestpractical.com
Fri Jul 29 21:29:20 EDT 2011
The branch, 3.8/perlcritic has been updated
via 77954cae90ee10d2c690ad79f904d0f52216f569 (commit)
from 12272901855ced249bbe07b3aa6a34ce6246acba (commit)
Summary of changes:
bin/rt-mailgate.in | 2 +-
bin/rt.in | 10 +++++++---
lib/RT/EmailParser.pm | 2 +-
lib/RT/Handle.pm | 17 ++++++++++-------
lib/RT/Installer.pm | 2 +-
lib/RT/Interface/Web.pm | 2 +-
lib/RT/Test.pm | 10 +++++-----
sbin/extract-message-catalog | 7 +++++--
sbin/factory | 4 ++--
sbin/license_tag | 32 ++++++++++++++++----------------
share/html/Install/index.html | 4 ++--
11 files changed, 51 insertions(+), 41 deletions(-)
- Log -----------------------------------------------------------------
commit 77954cae90ee10d2c690ad79f904d0f52216f569
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Mon Jul 25 21:14:45 2011 -0400
Check the return value of close()
diff --git a/bin/rt-mailgate.in b/bin/rt-mailgate.in
index c07888f..3adc58a 100755
--- a/bin/rt-mailgate.in
+++ b/bin/rt-mailgate.in
@@ -212,7 +212,7 @@ sub write_down_message {
$empty = 0 if $buf =~ /\S/;
print $fh $buf;
};
- close $fh;
+ close $fh or die "Can't close $filename: $!";
if ( $empty ) {
print STDERR "$0: no message passed on STDIN\n";
diff --git a/bin/rt.in b/bin/rt.in
index 218ad5d..3f41b14 100755
--- a/bin/rt.in
+++ b/bin/rt.in
@@ -1220,7 +1220,7 @@ sub submit {
}
}
}
- close($f);
+ close($f) or return 0;
chmod 0600, $file;
return 1;
}
@@ -1501,9 +1501,13 @@ sub vi {
local $/ = undef;
my $f;
- open($f, '>', $file) or die "$file: $!\n"; print $f $text; close($f);
+ open($f, '>', $file) or die "Can't write $file: $!\n";
+ print $f $text;
+ close($f) or die "Failed to close $file: $!";
system($editor, $file) && die "Couldn't run $editor.\n";
- open($f, '<', $file) or die "$file: $!\n"; $text = <$f>; close($f);
+ open($f, '<', $file) or die "Can't read $file: $!\n";
+ $text = <$f>;
+ close($f) or die "Failed to close $file: $!";
unlink($file);
return $text;
diff --git a/lib/RT/EmailParser.pm b/lib/RT/EmailParser.pm
index 5a5d274..c41c703 100755
--- a/lib/RT/EmailParser.pm
+++ b/lib/RT/EmailParser.pm
@@ -118,7 +118,7 @@ sub SmartParseMIMEEntityFromScalar {
binmode $fh;
$fh->autoflush(1);
print $fh $args{'Message'};
- close($fh);
+ close($fh) or warn "Can't close tmpfile: $!";
if ( -f $temp_file ) {
my $entity = $self->ParseMIMEEntityFromFile( $temp_file, $args{'Decode'}, $args{'Exact'} );
unlink($temp_file);
diff --git a/lib/RT/Handle.pm b/lib/RT/Handle.pm
index 989bc49..5173734 100755
--- a/lib/RT/Handle.pm
+++ b/lib/RT/Handle.pm
@@ -475,14 +475,18 @@ sub InsertSchema {
my (@schema);
- open( my $fh_schema, '<', $file ) or die $!;
-
- my $has_local = 1;
- open( my $fh_schema_local, "<", $self->GetVersionFile( $dbh, $RT::LocalEtcPath . "/schema." . $db_type ))
- or $has_local = 0;
+ open( my $fh_schema, '<', $file ) or die "Can't read $file: $!";
+ my @lines = (<$fh_schema>, ";;");
+ close($fh_schema) or die "Can't close $file: $!";
+
+ my $local_file = $self->GetVersionFile( $dbh, $RT::LocalEtcPath . "/schema." . $db_type );
+ if (open( my $fh_schema_local, "<", $local_file)) {
+ push @lines, <$fh_schema_local>;
+ close($fh_schema_local) or die "Can't close $local_file: $!";
+ }
my $statement = "";
- foreach my $line ( <$fh_schema>, ($_ = ';;'), $has_local? <$fh_schema_local>: () ) {
+ foreach my $line ( @lines ) {
$line =~ s/\#.*//g;
$line =~ s/--.*//g;
$statement .= $line;
@@ -492,7 +496,6 @@ sub InsertSchema {
$statement = "";
}
}
- close $fh_schema; close $fh_schema_local;
if ( $db_type eq 'Oracle' ) {
my $db_user = RT->Config->Get('DatabaseUser');
diff --git a/lib/RT/Installer.pm b/lib/RT/Installer.pm
index f4cd823..00ec98d 100644
--- a/lib/RT/Installer.pm
+++ b/lib/RT/Installer.pm
@@ -303,7 +303,7 @@ sub SaveConfig {
}
$content .= "1;\n";
print $fh $content;
- close $fh;
+ close $fh or return(0, "Failed to write $file: $!");
return ( 1, "Successfully saved configuration to $file." );
}
diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index 83a8792..acb8be7 100755
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -864,7 +864,7 @@ sub SendStaticFile {
$HTML::Mason::Commands::m->out($_) while (<$fh>);
$HTML::Mason::Commands::m->flush_buffer;
}
- close $fh;
+ close $fh or die "Couldn't close $file: $!";
return;
}
diff --git a/lib/RT/Test.pm b/lib/RT/Test.pm
index f619ae4..cf4d18b 100644
--- a/lib/RT/Test.pm
+++ b/lib/RT/Test.pm
@@ -260,7 +260,7 @@ END
print $config "\n1;\n";
$ENV{'RT_SITE_CONFIG'} = $tmp{'config'}{'RT'};
- close $config;
+ close $config or die "Failed to write $tmp{config}{RT}: $!";
return $config;
}
@@ -312,7 +312,7 @@ sub set_config_wrapper {
$dump =~ s/;\s+$//;
print $fh
"\nSet(${sigil}${name}, \@{". $dump ."}); 1;\n";
- close $fh;
+ close $fh or die "Failed to write $tmp{config}{RT}: $!";
if ( @SERVERS ) {
warn "you're changing config option in a test file"
@@ -743,10 +743,10 @@ sub run_and_capture {
$after_open->($child_in, $child_out) if $after_open;
- close $child_in;
+ close $child_in or die "Failed to close child stdin pipe: $!";
my $result = do { local $/ = undef; <$child_out> };
- close $child_out;
+ close $child_out or die "Failed to close child stdout pipe: $!";
waitpid $pid, 0;
return ($?, $result);
}
@@ -1239,7 +1239,7 @@ sub file_content {
return ''
};
my $content = do { local $/ = undef; <$fh> };
- close $fh;
+ close $fh or die "Failed to close $path: $!";
unlink $path if $args{'unlink'};
diff --git a/sbin/extract-message-catalog b/sbin/extract-message-catalog
index a433ac3..61ae3a7 100755
--- a/sbin/extract-message-catalog
+++ b/sbin/extract-message-catalog
@@ -130,7 +130,10 @@ sub extract_strings_from_code {
}
local $/ = undef;
$_ = <$fh>;
- close $fh;
+ unless (close $fh) {
+ print "Cannot close $file ($!), skipping.\n";
+ return;
+ }
my $re_space_wo_nl = qr{(?!\n)\s};
my $re_loc_suffix = qr{$re_space_wo_nl* \# $re_space_wo_nl* loc $re_space_wo_nl* $}mx;
@@ -352,7 +355,7 @@ sub update {
open( my $po, '>', $file ) or die "Couldn't open '$file' for writing: $!";
print $po $out;
- close $po;
+ close $po or die "Failed to write $file: $!";
return 1;
}
diff --git a/sbin/factory b/sbin/factory
index 3d71807..97dc31c 100755
--- a/sbin/factory
+++ b/sbin/factory
@@ -455,11 +455,11 @@ $ClassAccessible
my $fh;
open( $fh, '>', $RecordClassPath ) or die $!;
print $fh $RecordClass;
- close($fh);
+ close($fh) or die "Failed to write $RecordClassPath: $!";
open( $fh, '>', $CollectionClassPath ) or die $!;
print $fh $CollectionClass;
- close($fh);
+ close($fh) or die "Failed to write $CollectionClassPath: $!";
}
diff --git a/sbin/license_tag b/sbin/license_tag
index e3584e5..5d233b2 100755
--- a/sbin/license_tag
+++ b/sbin/license_tag
@@ -115,9 +115,9 @@ sub tag_mason {
my $pm = $_;
return unless (-f $pm);
return if $pm =~ /images/ || $pm =~ /\.(?:png|jpe?g|gif)$/;
- open( my $fh, '<', $pm ) or die "Failed to open $pm";
+ open( my $fh, '<', $pm ) or die "Failed to open $pm: $!";
my $file = (join "", <$fh>);
- close ($fh);
+ close ($fh) or die "Failed to close $pm: $!";
print "$pm - ";
return if another_license($pm => $file) && print "has different license\n";
@@ -139,18 +139,18 @@ sub tag_mason {
- open( $fh, '>', $pm ) or die "couldn't write new file";
+ open( $fh, '>', $pm ) or die "Failed to write $pm: $!";
print $fh $file;
- close $fh;
+ close $fh or die "Failed to close $pm: $!";
return;
}
sub tag_makefile {
my $pm = shift;
- open( my $fh, '<', $pm ) or die "Failed to open $pm";
+ open( my $fh, '<', $pm ) or die "Failed to open $pm: $!";
my $file = (join "", <$fh>);
- close ($fh);
+ close ($fh) or die "Failed to close $pm: $!";
print "$pm - ";
return if another_license($pm => $file) && print "has different license\n";
@@ -172,9 +172,9 @@ sub tag_makefile {
- open( $fh, '>', $pm ) or die "couldn't write new file";
+ open( $fh, '>', $pm ) or die "Failed to write $pm: $!";
print $fh $file;
- close $fh;
+ close $fh or die "Failed to close $pm: $!";
return;
}
@@ -182,9 +182,9 @@ sub tag_makefile {
sub tag_pm {
my $pm = $_;
next unless $pm =~ /\.pm/s;
- open( my $fh, '<', $pm ) or die "Failed to open $pm";
+ open( my $fh, '<', $pm ) or die "Failed to open $pm: $!";
my $file = (join "", <$fh>);
- close ($fh);
+ close ($fh) or die "Failed to close $pm: $!";
print "$pm - ";
return if another_license($pm => $file) && print "has different license\n";
@@ -206,9 +206,9 @@ sub tag_pm {
- open( $fh, '>', $pm ) or die "couldn't write new file $pm";
+ open( $fh, '>', $pm ) or die "Failed to write $pm: $!";
print $fh $file;
- close $fh;
+ close $fh or die "Failed to close $pm: $!";
return;
}
@@ -216,9 +216,9 @@ sub tag_pm {
sub tag_script {
my $pm = $_;
return unless (-f $pm);
- open( my $fh, '<', $pm ) or die "Failed to open $pm";
+ open( my $fh, '<', $pm ) or die "Failed to open $pm: $!";
my $file = (join "", <$fh>);
- close ($fh);
+ close ($fh) or die "Failed to close $pm: $!";
print "$pm - ";
return if another_license($pm => $file) && print "has different license\n";
@@ -243,9 +243,9 @@ sub tag_script {
print "\n";
- open( $fh, '>', $pm ) or die "couldn't write new file";
+ open( $fh, '>', $pm ) or die "Failed to write $pm: $!";
print $fh $file;
- close $fh;
+ close $fh or die "Failed to close $pm: $!";
return;
}
diff --git a/share/html/Install/index.html b/share/html/Install/index.html
index 1cad40f..c5c2cdd 100644
--- a/share/html/Install/index.html
+++ b/share/html/Install/index.html
@@ -95,8 +95,8 @@ my $file = File::Spec->catfile( $RT::EtcPath, 'RT_SiteConfig.pm' );
if ( ! -e $file ) {
# write a blank RT_SiteConfig.pm
- open( my $fh, '>', $file ) or die $!;
- close $fh;
+ open( my $fh, '>', $file ) or die "Failed to write $file: $!";
+ close $fh or die "Failed to write $file: $!";
}
elsif ( ! -w $file ) {
$locked = 1;
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list