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, T_SCC_BODY_TEXT_LINE 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 D93E11F513 for ; Wed, 14 Aug 2024 00:16:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1723594605; bh=AGunDRoSLETWcwFibaw4rJg+pamFuhZxgCtcjYHmB3U=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ZIFktq5nYGxYloc//U+1REehtpF85fgP5Hcv0iRHmXb27XIoJ7BJchz+UXYcthfOT /ZrqfVmyh6wieNYeFmYfC2wrklXtz8fXe55b7uDUYmQz98iCcaeT7KlD+CH6YTbUp9 kxwpFbjOaRpL/iXO7hI15E+/GSzg321DKwVIWUTg= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 2/5] lei_store: use autodie for open+close Date: Wed, 14 Aug 2024 00:16:42 +0000 Message-Id: <20240814001645.395576-3-e@80x24.org> In-Reply-To: <20240814001645.395576-1-e@80x24.org> References: <20240814001645.395576-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: No reason to do error checking ourselves when the standard library can do it. --- lib/PublicInbox/LeiStore.pm | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/PublicInbox/LeiStore.pm b/lib/PublicInbox/LeiStore.pm index f9e8267b..9551da5f 100644 --- a/lib/PublicInbox/LeiStore.pm +++ b/lib/PublicInbox/LeiStore.pm @@ -15,6 +15,7 @@ package PublicInbox::LeiStore; use strict; use v5.10.1; use parent qw(PublicInbox::Lock PublicInbox::IPC); +use autodie qw(open pipe); use PublicInbox::ExtSearchIdx; use PublicInbox::Eml; use PublicInbox::Import; @@ -57,7 +58,7 @@ sub rotate_bytes { sub git_ident ($) { my ($git) = @_; my $rdr = {}; - open $rdr->{2}, '>', '/dev/null' or die "open /dev/null: $!"; + open $rdr->{2}, '>', '/dev/null'; chomp(my $i = $git->qx([qw(var GIT_COMMITTER_IDENT)], undef, $rdr)); $i =~ /\A(.+) <([^>]+)> [0-9]+ [-\+]?[0-9]+$/ and return ($1, $2); my ($user, undef, undef, undef, undef, undef, $gecos) = getpwuid($<); @@ -585,8 +586,8 @@ sub xchg_stderr { return unless -e $dir; delete $self->{-tmp_err}; my ($err, $name) = tmpnam(); - open STDERR, '>>', $name or die "dup2: $!"; - unlink($name); + open STDERR, '>>', $name; + unlink $name; # ignore errors STDERR->autoflush(1); # shared with shard subprocesses $self->{-tmp_err} = $err; # separate file description for RO access undef; @@ -648,7 +649,7 @@ sub write_prepare { unless ($self->{-wq_s1}) { my $dir = $lei->store_path; substr($dir, -length('/lei/store'), 10, ''); - pipe(my ($r, $w)) or die "pipe: $!"; + pipe(my $r, my $w); $w->autoflush(1); # Mail we import into lei are private, so headers filtered out # by -mda for public mail are not appropriate