about summary refs log tree commit homepage
path: root/lib/PublicInbox/xap_helper.h
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2023-09-04 23:49:46 +0000
committerEric Wong <e@80x24.org>2023-09-05 03:01:45 +0000
commit2983af77a96a1bf2bcf1cc5409957ab4ef4138aa (patch)
tree2180788ed41fa303de29bf2e2bed5b032255c704 /lib/PublicInbox/xap_helper.h
parent6e0d801c4ace7675ba2accf75150e6790f6c6827 (diff)
downloadpublic-inbox-2983af77a96a1bf2bcf1cc5409957ab4ef4138aa.tar.gz
pipe2(.., O_CLOEXEC) on NetBSD sets the O_CLOEXEC file description
flag along with the FD_CLOEXEC file descriptor flag, so we must
not attempt to do exact matches on the file description flags.
Diffstat (limited to 'lib/PublicInbox/xap_helper.h')
-rw-r--r--lib/PublicInbox/xap_helper.h15
1 files changed, 7 insertions, 8 deletions
diff --git a/lib/PublicInbox/xap_helper.h b/lib/PublicInbox/xap_helper.h
index 0f16d316..73590efd 100644
--- a/lib/PublicInbox/xap_helper.h
+++ b/lib/PublicInbox/xap_helper.h
@@ -636,18 +636,17 @@ static bool recv_req(struct req *req, char *rbuf, size_t *len)
                         int fd = *fdp++;
                         const char *mode = NULL;
                         int fl = fd_ok ? fcntl(fd, F_GETFL) : 0;
-                        switch (fl) {
-                        case 0: break; // hit previous error
-                        case -1:
+                        if (fl == 0) {
+                                continue; // hit previous error
+                        } else if (fl == -1) {
                                 warnx("invalid fd=%d", fd);
                                 fd_ok = false;
-                                break;
-                        case O_WRONLY: mode = "w"; break;
-                        case O_RDWR:
+                        } else if (fl & O_WRONLY) {
+                                mode = "w";
+                        } else if (fl & O_RDWR) {
                                 mode = "r+";
                                 if (i == 0) req->has_input = true;
-                                break;
-                        default:
+                        } else {
                                 warnx("invalid mode from F_GETFL: 0x%x", fl);
                                 fd_ok = false;
                         }