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 A2D2A1F4D0 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=EaRbYDIs2gsqs3gWELncbHG9aRlXN26fMM3FtFigzG8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=QsqfhSxUqa4d3pbnWpmKC2gUZi5kIXD+tzYPRReLsBgoTG/9aJP2+MJnwDdt4we5K 6Nv3WPYa2jvBTzYfrbAwtxRun4ZD0FUmv7q9ps2yvIPO/3fvektOWsguc/JTFtg5Zx i3lXFUKweOpMup7EUhd6w0zEAZzB0aJJIIMcvfWU= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 5/6] xapcmd: use autodie for numerous syscalls Date: Sat, 16 Nov 2024 07:09:52 +0000 Message-ID: <20241116070953.2945078-6-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: autodie allows us to simplify a multi-line statement for conditional rename() and improve error message consistency with the rest of our codebase. syswrite() error checking was missing before and now exists trivially due to autodie. --- lib/PublicInbox/Xapcmd.pm | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/PublicInbox/Xapcmd.pm b/lib/PublicInbox/Xapcmd.pm index 9a148ae4..4af50ea8 100644 --- a/lib/PublicInbox/Xapcmd.pm +++ b/lib/PublicInbox/Xapcmd.pm @@ -2,6 +2,7 @@ # License: AGPL-3.0+ package PublicInbox::Xapcmd; use v5.12; +use autodie qw(chmod opendir rename syswrite); use PublicInbox::Spawn qw(which popen_rd); use PublicInbox::Syscall; use PublicInbox::Admin qw(setup_signals); @@ -61,12 +62,9 @@ sub commit_changes ($$$$) { next; } - chmod($mode & 07777, $new) or die "chmod($new): $!\n"; - if ($have_old) { - rename($old, "$new/old") or - die "rename $old => $new/old: $!\n"; - } - rename($new, $old) or die "rename $new => $old: $!\n"; + chmod $mode & 07777, $new; + rename $old, "$new/old" if $have_old; + rename $new, $old; push @old_shard, "$old/old" if $have_old; } @@ -219,7 +217,7 @@ sub prepare_run { PublicInbox::Syscall::nodatacow_dir($wip->dirname); push @queue, [ $old, $wip ]; } elsif (defined $old) { - opendir my $dh, $old or die "Failed to opendir $old: $!\n"; + opendir my $dh, $old; my @old_shards; while (defined(my $dn = readdir($dh))) { if ($dn =~ /\A[0-9]+\z/) {