dumping ground for random patches and texts
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: spew@80x24.org
Subject: [PATCH] pop3d: split @FLOCK into $FLOCK_TMPL and @FLOCK_ORDER
Date: Sat, 16 Sep 2023 23:44:15 +0000	[thread overview]
Message-ID: <20230916234415.2329704-1-e@80x24.org> (raw)

This improves readability since we don't have to subscript
the array for use with the `pack' perlop.
---
 lib/PublicInbox/POP3D.pm | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/lib/PublicInbox/POP3D.pm b/lib/PublicInbox/POP3D.pm
index 580a26d3..bee668fc 100644
--- a/lib/PublicInbox/POP3D.pm
+++ b/lib/PublicInbox/POP3D.pm
@@ -13,7 +13,7 @@ use PublicInbox::POP3;
 use PublicInbox::Syscall;
 use File::Temp 0.19 (); # 0.19 for ->newdir
 use Fcntl qw(F_SETLK F_UNLCK F_WRLCK SEEK_SET);
-my @FLOCK;
+my ($FLOCK_TMPL, @FLOCK_ORDER);
 # are all BSDs the same "struct flock"? tested Free+Net+Open...
 if ($^O eq 'linux' || $^O =~ /bsd/) {
 	require Config;
@@ -26,15 +26,15 @@ if ($^O eq 'linux' || $^O =~ /bsd/) {
 
 	if (defined($off_t)) {
 		if ($^O eq 'linux') {
-			@FLOCK = ("ss\@8$off_t$off_t\@32",
-				qw(l_type l_whence l_start l_len));
+			$FLOCK_TMPL = "ss\@8$off_t$off_t\@32";
+			@FLOCK_ORDER = qw(l_type l_whence l_start l_len);
 		} elsif ($^O =~ /bsd/) { # @32 may be enough
-			@FLOCK = ("${off_t}${off_t}lss\@256",
-				qw(l_start l_len l_pid l_type l_whence));
+			$FLOCK_TMPL = "${off_t}${off_t}lss\@256";
+			@FLOCK_ORDER = qw(l_start l_len l_pid l_type l_whence);
 		}
 	}
 }
-@FLOCK or eval { require File::FcntlLock } or
+@FLOCK_ORDER or eval { require File::FcntlLock } or
 	die "File::FcntlLock required for POP3 on $^O: $@\n";
 
 sub new {
@@ -141,9 +141,9 @@ sub _setlk ($%) {
 	my ($self, %lk) = @_;
 	$lk{l_pid} = 0; # needed for *BSD
 	$lk{l_whence} = SEEK_SET;
-	if (@FLOCK) {
+	if (@FLOCK_ORDER) {
 		fcntl($self->{txn_fh}, F_SETLK,
-			pack($FLOCK[0], @lk{@FLOCK[1..$#FLOCK]}));
+			pack($FLOCK_TMPL, @lk{@FLOCK_ORDER}));
 	} else {
 		my $fs = File::FcntlLock->new(%lk);
 		$fs->lock($self->{txn_fh}, F_SETLK);

                 reply	other threads:[~2023-09-16 23:44 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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

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

  git send-email \
    --in-reply-to=20230916234415.2329704-1-e@80x24.org \
    --to=e@80x24.org \
    --cc=spew@80x24.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).