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 <[email protected]> +# Copyright (C) all contributors <[email protected]> # 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; }
