Skip to content

Commit ce5939a

Browse files
committed
Allow openat to return fd 0.
1 parent 8ee1803 commit ce5939a

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

libc/src/fcntl/linux/openat.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ LLVM_LIBC_FUNCTION(int, openat, (int dfd, const char *path, int flags, ...)) {
3232

3333
int fd = LIBC_NAMESPACE::syscall_impl<int>(SYS_openat, dfd, path, flags,
3434
mode_flags);
35-
if (fd > 0)
36-
return fd;
37-
38-
libc_errno = -fd;
39-
return -1;
35+
if (fd < 0) {
36+
libc_errno = -fd;
37+
return -1;
38+
}
39+
return fd;
4040
}
4141

4242
} // namespace LIBC_NAMESPACE_DECL

0 commit comments

Comments
 (0)