From: Eric Wong Date: Sat, 18 Jan 2025 01:26:12 +0000 (+0000) Subject: git: rely on autodie for sysseek/sysread/truncate X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6623cc623f0d7135b9e49ca4d1de1c99f2098866;p=thirdparty%2Fpublic-inbox.git git: rely on autodie for sysseek/sysread/truncate Error messages are more consistent with autodie. We'll also drop autodie::read since it's no longer in use for this package. --- diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm index b3f39adf8..9e0840ab5 100644 --- a/lib/PublicInbox/Git.pm +++ b/lib/PublicInbox/Git.pm @@ -11,8 +11,8 @@ use strict; use v5.10.1; use parent qw(Exporter PublicInbox::DS); use PublicInbox::DS qw(now); -use autodie qw(socketpair read); -use POSIX (); +use autodie qw(socketpair sysread sysseek truncate); +use POSIX qw(SEEK_SET); use Socket qw(AF_UNIX SOCK_STREAM); use PublicInbox::Syscall qw(EPOLLIN EPOLLET); use Errno qw(EAGAIN); @@ -145,11 +145,13 @@ sub object_format { sub last_check_err { my ($self) = @_; my $fh = $self->{err_c} or return ''; - sysseek($fh, 0, 0) or $self->fail("sysseek: $!"); my $size = -s $fh or return ''; - sysread($fh, my $buf, $size) // $self->fail("sysread: $!"); - truncate($fh, 0) or $self->fail("truncate: $!"); - $buf; + eval { + sysseek $fh, 0, SEEK_SET; + sysread($fh, my $buf, $size); + truncate $fh, 0; + $buf; + } // $self->fail($@); } sub gcf_drain { # awaitpid cb