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 752B21F626 for ; Tue, 14 Feb 2023 11:35:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1676374531; bh=v+kXIyBAh3tbSn6f1vAjcQohTOP/L10Qg/fb0RCG3R4=; h=From:To:Subject:Date:From; b=Dt3U/0/XJXV1sW5uaK0Vj3lwnY/ORB+LMkIj2+wwEzAisaev/nemiz7TfHc1uSTho J89JFwy/905zju7+Xz2jnGNaGnLAFBMQktbxHlcA4z7S1sMozUthbcOxUGLzA22nm/ peOqj6VuK2VZRFIUV3/2Ddl/68FEIOZoxIKkenjI= From: Eric Wong 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 Message-Id: <20230214113531.2735214-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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 +# Copyright (C) all contributors # License: AGPL-3.0+ # 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; }