From: Eric Wong Date: Sat, 16 Nov 2024 07:09:53 +0000 (+0000) Subject: spamc: autodie for open + sysseek X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=383ebec6c080a1544dd4723055ff730a9dddd00a;p=thirdparty%2Fpublic-inbox.git spamc: autodie for open + sysseek autodie allows us to shorten some lines and generate error messages which are more consistent with the rest of the codebase. --- diff --git a/lib/PublicInbox/Spamcheck/Spamc.pm b/lib/PublicInbox/Spamcheck/Spamc.pm index b4f95e2ba..71474b8fa 100644 --- a/lib/PublicInbox/Spamcheck/Spamc.pm +++ b/lib/PublicInbox/Spamcheck/Spamc.pm @@ -4,6 +4,7 @@ # Default spam filter class for wrapping spamc(1) package PublicInbox::Spamcheck::Spamc; use v5.12; +use autodie qw(open sysseek); use PublicInbox::Spawn qw(run_qx run_wait); use IO::Handle; use Fcntl qw(SEEK_SET); @@ -48,8 +49,7 @@ sub _learn { sub _devnull { my ($self) = @_; $self->{-devnull} //= do { - open my $fh, '+>', '/dev/null' or - die "failed to open /dev/null: $!"; + open my $fh, '+>', '/dev/null'; $fh } } @@ -60,13 +60,11 @@ sub _msg_to_fh { my $fd = eval { fileno($msg) }; return $msg if defined($fd) && $fd >= 0; - open(my $tmpfh, '+>', undef) or die "failed to open: $!"; + open my $tmpfh, '+>', undef; $tmpfh->autoflush(1); $msg = \($msg->as_string) if $ref ne 'SCALAR'; print $tmpfh $$msg or die "failed to print: $!"; - sysseek($tmpfh, 0, SEEK_SET) or - die "sysseek(fh) failed: $!"; - + sysseek $tmpfh, 0, SEEK_SET; return $tmpfh; } $msg;