From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 25DB51F4CA for ; Sat, 16 Nov 2024 07:09:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1731740994; bh=TAP2ToLQdFkpHpE3dTkroUM9m+2L/KIRpfBH4GsbiTc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Bn7qvdgK4SD6WxSR3BAFUSxcp44XVkNIXxDQ9dyQjFJIJAHYHrKczztqaSqGaE9ir y34em4bySv5b24XCUroK4MHK6dMIWs+dzjzQD/+rWUZpdYgch4n96Ky+U9W1RtXitd ky+xyNiOaS8ruWDFhhUcvD3cRLUadU3/AeXh9XIY= From: Eric Wong 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 Message-ID: <20241116070953.2945078-4-e@80x24.org> In-Reply-To: <20241116070953.2945078-1-e@80x24.org> References: <20241116070953.2945078-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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 }