[libc-commits] [compiler-rt] [libc] compiler-rt Never consider an fd being 0 as an error (PR #176581)
via libc-commits
libc-commits at lists.llvm.org
Sat Jan 17 09:58:31 PST 2026
https://github.com/AZero13 updated https://github.com/llvm/llvm-project/pull/176581
>From c3a450c0d453de8aa1c45d4e1766dd2dd014ca57 Mon Sep 17 00:00:00 2001
From: AZero13 <gfunni234 at gmail.com>
Date: Sat, 17 Jan 2026 12:48:30 -0500
Subject: [PATCH] compiler-rt Never consider an fd being 0 as an error
This is not semantically right, even if unlikely to happen.
---
compiler-rt/lib/fuzzer/afl/afl_driver.cpp | 2 +-
libc/src/spawn/linux/posix_spawn.cpp | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/compiler-rt/lib/fuzzer/afl/afl_driver.cpp b/compiler-rt/lib/fuzzer/afl/afl_driver.cpp
index 52aede7e078dc..7643cf6d5bf0f 100644
--- a/compiler-rt/lib/fuzzer/afl/afl_driver.cpp
+++ b/compiler-rt/lib/fuzzer/afl/afl_driver.cpp
@@ -154,7 +154,7 @@ static void close_stdout() { discard_output(STDOUT_FILENO); }
static void dup_and_close_stderr() {
int output_fileno = fileno(output_file);
int output_fd = dup(output_fileno);
- if (output_fd <= 0)
+ if (output_fd < 0)
abort();
FILE *new_output_file = fdopen(output_fd, "w");
if (!new_output_file)
diff --git a/libc/src/spawn/linux/posix_spawn.cpp b/libc/src/spawn/linux/posix_spawn.cpp
index fe82ba260148a..f05815805dc05 100644
--- a/libc/src/spawn/linux/posix_spawn.cpp
+++ b/libc/src/spawn/linux/posix_spawn.cpp
@@ -44,7 +44,7 @@ cpp::optional<int> open(const char *path, int oflags, mode_t mode) {
int fd = LIBC_NAMESPACE::syscall_impl<int>(SYS_openat, AT_FDCWD, path, oflags,
mode);
#endif
- if (fd > 0)
+ if (fd >= 0)
return fd;
// The open function is called as part of the child process' preparatory
// steps. If an open fails, the child process just exits. So, unlike
More information about the libc-commits
mailing list