Skip to content

Commit 98fbfdc

Browse files
committed
Also allow creat to return a zero file descriptor.
1 parent ce5939a commit 98fbfdc

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

libc/src/fcntl/linux/creat.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ LLVM_LIBC_FUNCTION(int, creat, (const char *path, int mode_flags)) {
2727
SYS_openat, AT_FDCWD, path, O_CREAT | O_WRONLY | O_TRUNC, mode_flags);
2828
#endif
2929

30-
if (fd > 0)
31-
return fd;
32-
33-
libc_errno = -fd;
34-
return -1;
30+
if (fd < 0) {
31+
libc_errno = -fd;
32+
return -1;
33+
}
34+
return fd;
3535
}
3636

3737
} // namespace LIBC_NAMESPACE_DECL

0 commit comments

Comments
 (0)