unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 6/6] spamc: autodie for open + sysseek
Date: Sat, 16 Nov 2024 07:09:53 +0000	[thread overview]
Message-ID: <20241116070953.2945078-7-e@80x24.org> (raw)
In-Reply-To: <20241116070953.2945078-1-e@80x24.org>

autodie allows us to shorten some lines and generate
error messages which are more consistent with the rest
of the codebase.
---
 lib/PublicInbox/Spamcheck/Spamc.pm | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/lib/PublicInbox/Spamcheck/Spamc.pm b/lib/PublicInbox/Spamcheck/Spamc.pm
index b4f95e2b..71474b8f 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;

      parent reply	other threads:[~2024-11-16  7:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-16  7:09 [PATCH 0/6] v5.12 + autodie cleanups Eric Wong
2024-11-16  7:09 ` [PATCH 1/6] index: use v5.12, remove outdated comment Eric Wong
2024-11-16  7:09 ` [PATCH 2/6] over: use autodie for open Eric Wong
2024-11-16  7:09 ` [PATCH 3/6] lei_blob: use autodie for open + seek Eric Wong
2024-11-16  7:09 ` [PATCH 4/6] admin: autodie chdir + open Eric Wong
2024-11-16  7:09 ` [PATCH 5/6] xapcmd: use autodie for numerous syscalls Eric Wong
2024-11-16  7:09 ` Eric Wong [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241116070953.2945078-7-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).