From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [RFC] treewide: handle multi-bit O_RDWR and O_APPEND flags
Date: Tue, 14 Feb 2023 11:35:31 +0000 [thread overview]
Message-ID: <20230214113531.2735214-1-e@80x24.org> (raw)
I'm not sure if this is necessary for some odd platforms, but
there could be some OS which uses a multi-bit O_RDWR and/or
O_APPEND flag and we'd need to check all the bits are set,
not just one bit.
This patch is not necessary on Linux nor FreeBSD. I assume
what goes for well-established flags on FreeBSD also applies
to NetBSD and OpenBSD, too.
Only found via random code reading.
---
lib/PublicInbox/LeiOverview.pm | 4 ++--
lib/PublicInbox/WwwCoderepo.pm | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/PublicInbox/LeiOverview.pm b/lib/PublicInbox/LeiOverview.pm
index 066c40bd..a3b41b64 100644
--- a/lib/PublicInbox/LeiOverview.pm
+++ b/lib/PublicInbox/LeiOverview.pm
@@ -1,4 +1,4 @@
-# Copyright (C) 2021 all contributors <meta@public-inbox.org>
+# Copyright (C) all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
# per-mitem/smsg iterators for search results
@@ -90,7 +90,7 @@ sub new {
if (!$isatty && -f _) {
my $fl = fcntl($lei->{$devfd}, F_GETFL, 0) //
die("fcntl(/dev/fd/$devfd): $!\n");
- ovv_out_lk_init($self) unless ($fl & O_APPEND);
+ ovv_out_lk_init($self) if ($fl & O_APPEND) != O_APPEND;
} else {
ovv_out_lk_init($self);
}
diff --git a/lib/PublicInbox/WwwCoderepo.pm b/lib/PublicInbox/WwwCoderepo.pm
index 7a2cb80b..44840cb5 100644
--- a/lib/PublicInbox/WwwCoderepo.pm
+++ b/lib/PublicInbox/WwwCoderepo.pm
@@ -82,7 +82,7 @@ sub new {
my @s = stat(STDIN) or die "stat(STDIN): $!";
if ("@l[0, 1]" eq "@s[0, 1]") {
my $f = fcntl(STDIN, F_GETFL, 0) // die "F_GETFL: $!";
- $self->{log_fh} = *STDIN{IO} if $f & O_RDWR;
+ $self->{log_fh} = *STDIN{IO} if ($f & O_RDWR) == O_RDWR;
}
$self;
}
reply other threads:[~2023-02-14 11:35 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
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=20230214113531.2735214-1-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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
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).