From 6623cc623f0d7135b9e49ca4d1de1c99f2098866 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 18 Jan 2025 01:26:12 +0000 Subject: [PATCH] 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. --- lib/PublicInbox/Git.pm | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) 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 -- 2.47.3