]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
xap_client: autodie for pipe and socketpair
authorEric Wong <e@80x24.org>
Tue, 17 Oct 2023 23:37:57 +0000 (23:37 +0000)
committerEric Wong <e@80x24.org>
Wed, 18 Oct 2023 20:50:28 +0000 (20:50 +0000)
This saves us a few lines of code.

lib/PublicInbox/XapClient.pm

index 9e2d71a02a287eb501ce19034ccbf33c18f2e0bc..21c8926545bb0598784badc34edfd563767ec11e 100644 (file)
@@ -11,14 +11,12 @@ use v5.12;
 use PublicInbox::Spawn qw(spawn);
 use Socket qw(AF_UNIX SOCK_SEQPACKET);
 use PublicInbox::IPC;
+use autodie qw(pipe socketpair);
 
 sub mkreq {
        my ($self, $ios, @arg) = @_;
-       my ($r, $w, $n);
-       if (!defined($ios->[0])) {
-               pipe($r, $w) or die "pipe: $!";
-               $ios->[0] = $w;
-       }
+       my ($r, $n);
+       pipe($r, $ios->[0]) if !defined($ios->[0]);
        my @fds = map fileno($_), @$ios;
        my $buf = join("\0", @arg, '');
        $n = $PublicInbox::IPC::send_cmd->($self->{io}, \@fds, $buf, 0) //
@@ -29,8 +27,7 @@ sub mkreq {
 
 sub start_helper {
        my @argv = @_;
-       socketpair(my $sock, my $in, AF_UNIX, SOCK_SEQPACKET, 0) or
-               die "socketpair: $!";
+       socketpair(my $sock, my $in, AF_UNIX, SOCK_SEQPACKET, 0);
        my $cls = ($ENV{PI_NO_CXX} ? undef : eval {
                        require PublicInbox::XapHelperCxx;
                        PublicInbox::XapHelperCxx::check_build();