[SCM] Debian package checker branch, master, updated. 2.5.11-223-g8045ea2
The following commit has been merged in the master branch:
commit 8045ea2bbe37d782dfa1be65d809a6a120c35f97
Author: Niels Thykier <niels@thykier.net>
Date: Thu Apr 4 12:34:14 2013 +0200
Ensure open, opendir and chdir return values are checked
Files missing (any) return value check have been changed to use
autodie for these functions (and close were relevant).
NB: checks/manpages was a false-positive, but was "fixed" anyway to
allow perlcritic to perform this check automatically.
Signed-off-by: Niels Thykier <niels@thykier.net>
diff --git a/.perlcriticrc b/.perlcriticrc
index fb0787b..a404eff 100644
--- a/.perlcriticrc
+++ b/.perlcriticrc
@@ -28,6 +28,10 @@ allow-unsafe = 1
[BuiltinFunctions::ProhibitBooleanGrep]
+[InputOutput::RequireCheckedSyscalls]
+functions = open opendir chdir
+# possible TODO read readline readdir close closedir
+
# Checks and collections blow up
[-Modules::RequireFilenameMatchesPackage]
# We don't use package versions atm and even if we did, it probably
diff --git a/checks/manpages b/checks/manpages
index d755006..0f6c1eb 100644
--- a/checks/manpages
+++ b/checks/manpages
@@ -21,6 +21,7 @@
package Lintian::manpages;
use strict;
use warnings;
+use autodie qw(open close chdir);
use File::Basename;
use List::MoreUtils qw(any none);
@@ -160,11 +161,11 @@ foreach my $file ($info->sorted_index) {
my $path = $info->unpacked($file);
my $fd;
if ($file_info =~ m/gzip compressed/) {
- $fd = open_gz ($path);
+ $fd = open_gz($path)
+ or fail "cannot open $file: $!";
} else {
open $fd, '<', $path;
}
- $fd or fail "cannot open $file: $!";
my @manfile = <$fd>;
close $fd;
# Is it a .so link?
@@ -214,8 +215,7 @@ foreach my $file ($info->sorted_index) {
fail "fork (lexgrog) failed: $!";
} elsif ($pid == 0) {
clean_env;
- open STDERR, '>&', STDOUT
- or fail "Redirect STDERR failed: $!";
+ open(STDERR, '>&', \*STDOUT);
exec 'lexgrog', $path
or fail "exec lexgrog failed: $!";
}
@@ -227,8 +227,15 @@ foreach my $file ($info->sorted_index) {
tag 'manpage-is-dh_make-template', $file;
}
1 while <LEXGROG>;
- close LEXGROG;
- tag 'manpage-has-bad-whatis-entry', $file if $? != 0;
+ eval {
+ close(LEXGROG);
+ };
+ if (my $err = $@) {
+ # Problem closing the pipe?
+ fail "close pipe: $err" if $err->errno;
+ # No, then lexgrog returned with a non-zero exit code.
+ tag 'manpage-has-bad-whatis-entry', $file;
+ }
}
# If it's not a .so link, run it through 'man' to check for errors.
@@ -253,12 +260,10 @@ foreach my $file ($info->sorted_index) {
clean_env;
close STDOUT;
close $read;
- open STDOUT, '>', '/dev/null'
- or fail "Redirecting STDOUT: $!";
- open STDERR, '>&', $write
- or fail "Redirecting STDERR: $!";
+ open(STDOUT, '>', '/dev/null');
+ open(STDERR, '>&', $write);
if ($dir) {
- chdir $dir or fail "chdir $dir: $!";
+ chdir($dir);
}
$ENV{MANROFFSEQ} = '';
$ENV{MANWIDTH} = 80;
diff --git a/collection/diffstat b/collection/diffstat
index 6906fbc..d0edf62 100755
--- a/collection/diffstat
+++ b/collection/diffstat
@@ -29,6 +29,7 @@ package Lintian::coll::diffstat;
use strict;
use warnings;
+use autodie;
use lib "$ENV{'LINTIAN_ROOT'}/lib";
use Lintian::Util qw(fail get_dsc_info gunzip_file);
@@ -53,20 +54,19 @@ return unless (-f $diff_file);
gunzip_file($diff_file, "$dir/debian-patch");
-open STAT, '>', "$dir/diffstat" or fail "cannot open scripts output file: $!";
+open(STAT, '>', "$dir/diffstat");
# diffstat is noisy on stderr if its stdout is not a tty.
# Shut it up by redirecting stderr to /dev/null.
-open STDERR, '>', '/dev/null';
-open DIFF, '-|', 'diffstat', '-p1', "$dir/debian-patch"
- or fail("cannot open pipe to diffstat on debian-patch: $!");
+open(STDERR, '>', '/dev/null');
+open(DIFF, '-|', 'diffstat', '-p1', "$dir/debian-patch");
# Copy all except last line to the STAT file
my $previous;
while (<DIFF>) {
print STAT $previous if $previous;
$previous = $_;
}
-close DIFF or fail("cannot close pipe to diffstat on debian-patch: $!");
-close STAT or fail("error writing diffstat file: $!");
+close(DIFF);
+close(STAT);
}
diff --git a/lib/Lintian/Command/Simple.pm b/lib/Lintian/Command/Simple.pm
index 4bc0eea..ae23c60 100644
--- a/lib/Lintian/Command/Simple.pm
+++ b/lib/Lintian/Command/Simple.pm
@@ -17,6 +17,7 @@ package Lintian::Command::Simple;
use strict;
use warnings;
+use autodie qw(open close chdir);
use Exporter qw(import);
use POSIX qw(:sys_wait_h);
@@ -77,7 +78,7 @@ sub rundir {
my $dir = shift;
close(STDIN);
open(STDIN, '<', '/dev/null');
- chdir($dir) or die("Failed to chdir to $dir: $!\n");
+ chdir($dir);
CORE::exec @_ or die("Failed to exec '$_[0]': $!\n");
}
@@ -138,7 +139,7 @@ sub background_dir {
my $dir = shift;
close(STDIN);
open(STDIN, '<', '/dev/null');
- chdir($dir) or die("Failed to chdir to $dir: $!\n");
+ chdir($dir);
CORE::exec @_ or die("Failed to exec '$_[0]': $!\n");
}
}
--
Debian package checker
Reply to: