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 3/6] lei_blob: use autodie for open + seek
Date: Sat, 16 Nov 2024 07:09:50 +0000	[thread overview]
Message-ID: <20241116070953.2945078-4-e@80x24.org> (raw)
In-Reply-To: <20241116070953.2945078-1-e@80x24.org>

The numerous open() calls are less noisy on our end and more
consistent.  Our seek() call needed error checking anyways, and
autodie provides it.
---
 lib/PublicInbox/LeiBlob.pm | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/lib/PublicInbox/LeiBlob.pm b/lib/PublicInbox/LeiBlob.pm
index 31936c36..1c5ee302 100644
--- a/lib/PublicInbox/LeiBlob.pm
+++ b/lib/PublicInbox/LeiBlob.pm
@@ -7,6 +7,7 @@ package PublicInbox::LeiBlob;
 use strict;
 use v5.10.1;
 use parent qw(PublicInbox::IPC);
+use autodie qw(open seek);
 use PublicInbox::Spawn qw(run_wait run_qx which);
 use PublicInbox::DS;
 use PublicInbox::Eml;
@@ -22,7 +23,7 @@ sub get_git_dir ($$) {
 	if (defined($lei->{opt}->{cwd})) { # --cwd used, report errors
 		$opt->{2} = $lei->{2};
 	} else { # implicit --cwd, quiet errors
-		open $opt->{2}, '>', '/dev/null' or die "open /dev/null: $!";
+		open $opt->{2}, '>', '/dev/null';
 	}
 	chomp(my $git_dir = run_qx($cmd, {GIT_DIR => undef}, $opt));
 	$? ? undef : $git_dir;
@@ -57,7 +58,7 @@ sub do_solve_blob { # via wq_do
 		$x =~ tr/-/_/;
 		$hints->{$x} = $v;
 	}
-	open my $log, '+>', \(my $log_buf = '') or die "PerlIO::scalar: $!";
+	open my $log, '+>', \(my $log_buf = '');
 	$lei->{log_buf} = \$log_buf;
 	my $git = $lei->{ale}->git;
 	my @rmt = map {
@@ -114,9 +115,9 @@ sub lei_blob {
 		}
 		my $rdr = {};
 		if ($opt->{mail}) {
-			open $rdr->{2}, '+>', undef or die "open: $!";
+			open $rdr->{2}, '+>', undef;
 		} else {
-			open $rdr->{2}, '>', '/dev/null' or die "open: $!";
+			open $rdr->{2}, '>', '/dev/null';
 		}
 		my $cmd = $lei->ale->git->cmd('cat-file', 'blob', $blob);
 		my $cerr;
@@ -139,7 +140,7 @@ sub lei_blob {
 					extract_attach($lei, $blob, $bref) :
 					$lei->out($$bref);
 		if ($opt->{mail}) {
-			seek($rdr->{2}, 0, 0);
+			seek $rdr->{2}, 0, 0; # regular file (see above)
 			return $lei->child_error($cerr, read_all($rdr->{2}));
 		} # else: fall through to solver below
 	}

  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 ` Eric Wong [this message]
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 ` [PATCH 6/6] spamc: autodie for open + sysseek Eric Wong

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-4-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).