]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
lei_store: use autodie for open+close
authorEric Wong <e@80x24.org>
Wed, 14 Aug 2024 00:16:42 +0000 (00:16 +0000)
committerEric Wong <e@80x24.org>
Thu, 15 Aug 2024 08:29:04 +0000 (08:29 +0000)
No reason to do error checking ourselves when the standard library
can do it.

lib/PublicInbox/LeiStore.pm

index f9e8267bbff0adc112bd1abf148775f35093683b..9551da5f1f3b82a4343ac251cd2032dcf2e8dd15 100644 (file)
@@ -15,6 +15,7 @@ package PublicInbox::LeiStore;
 use strict;
 use v5.10.1;
 use parent qw(PublicInbox::Lock PublicInbox::IPC);
+use autodie qw(open pipe);
 use PublicInbox::ExtSearchIdx;
 use PublicInbox::Eml;
 use PublicInbox::Import;
@@ -57,7 +58,7 @@ sub rotate_bytes {
 sub git_ident ($) {
        my ($git) = @_;
        my $rdr = {};
-       open $rdr->{2}, '>', '/dev/null' or die "open /dev/null: $!";
+       open $rdr->{2}, '>', '/dev/null';
        chomp(my $i = $git->qx([qw(var GIT_COMMITTER_IDENT)], undef, $rdr));
        $i =~ /\A(.+) <([^>]+)> [0-9]+ [-\+]?[0-9]+$/ and return ($1, $2);
        my ($user, undef, undef, undef, undef, undef, $gecos) = getpwuid($<);
@@ -585,8 +586,8 @@ sub xchg_stderr {
        return unless -e $dir;
        delete $self->{-tmp_err};
        my ($err, $name) = tmpnam();
-       open STDERR, '>>', $name or die "dup2: $!";
-       unlink($name);
+       open STDERR, '>>', $name;
+       unlink $name; # ignore errors
        STDERR->autoflush(1); # shared with shard subprocesses
        $self->{-tmp_err} = $err; # separate file description for RO access
        undef;
@@ -648,7 +649,7 @@ sub write_prepare {
        unless ($self->{-wq_s1}) {
                my $dir = $lei->store_path;
                substr($dir, -length('/lei/store'), 10, '');
-               pipe(my ($r, $w)) or die "pipe: $!";
+               pipe(my $r, my $w);
                $w->autoflush(1);
                # Mail we import into lei are private, so headers filtered out
                # by -mda for public mail are not appropriate