Skip to content

Commit

Permalink
Adjust style a bit.
Browse files Browse the repository at this point in the history
  • Loading branch information
shkhln committed Jun 2, 2024
1 parent 0601cef commit 2e093b2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/libc/fcntl.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ int shim_fcntl_impl(int fd, int cmd, va_list args) {
if (cmd == LINUX_F_GETFL) {
LOG("%s: cmd = F_GETFL", __func__);
int flags = libepoll_epoll_shim_fcntl(fd, F_GETFL);

assert((flags & ~(O_RDWR | O_NONBLOCK)) == 0);

int linux_flags =
(flags & O_RDWR ? LINUX_O_RDWR : 0) |
(flags & O_NONBLOCK ? LINUX_O_NONBLOCK : 0);
Expand All @@ -81,7 +84,7 @@ int shim_fcntl_impl(int fd, int cmd, va_list args) {
int linux_flags = va_arg(args, int);
LOG("%s: cmd = F_SETFL, arg = 0x%x", __func__, linux_flags);

assert((linux_flags & (LINUX_O_RDWR | LINUX_O_NONBLOCK)) == linux_flags);
assert((linux_flags & ~(LINUX_O_RDWR | LINUX_O_NONBLOCK)) == 0);

int flags =
(linux_flags & LINUX_O_RDWR ? O_RDWR : 0) |
Expand Down
4 changes: 2 additions & 2 deletions src/libc/sys/eventfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ int shim_eventfd_impl(unsigned int initval, int linux_flags) {
assert((linux_flags & ~(LINUX_EFD_CLOEXEC | LINUX_EFD_NONBLOCK)) == 0);

int flags = 0;
if (linux_flags & LINUX_EFD_NONBLOCK) flags |= O_NONBLOCK;
if (linux_flags & LINUX_EFD_CLOEXEC) flags |= O_CLOEXEC;
if (linux_flags & LINUX_EFD_NONBLOCK) flags |= EFD_NONBLOCK;
if (linux_flags & LINUX_EFD_CLOEXEC) flags |= EFD_CLOEXEC;

return eventfd(initval, flags);
}
Expand Down

0 comments on commit 2e093b2

Please sign in to comment.