diff options
author | Andreas Kling <kling@serenityos.org> | 2021-09-05 18:08:47 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-05 18:15:05 +0200 |
commit | 77b7a44691f561d714d2dad931b3ae903e4cbe6d (patch) | |
tree | ce2156d301a9ac5484962e7507a8cf291047f4a6 | |
parent | ea911bc1251825e34faabe1cb87479d6071a30e9 (diff) | |
download | serenity-77b7a44691f561d714d2dad931b3ae903e4cbe6d.zip |
Kernel: Use TRY() in sys$recvfd()
-rw-r--r-- | Kernel/Syscalls/sendfd.cpp | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/Kernel/Syscalls/sendfd.cpp b/Kernel/Syscalls/sendfd.cpp index 9981cbe52a..fd82027f4f 100644 --- a/Kernel/Syscalls/sendfd.cpp +++ b/Kernel/Syscalls/sendfd.cpp @@ -46,23 +46,17 @@ KResultOr<FlatPtr> Process::sys$recvfd(int sockfd, int options) if (!socket.is_local()) return EAFNOSUPPORT; - auto new_fd_or_error = m_fds.allocate(); - if (new_fd_or_error.is_error()) - return new_fd_or_error.error(); - auto new_fd = new_fd_or_error.release_value(); + auto fd_allocation = TRY(m_fds.allocate()); auto& local_socket = static_cast<LocalSocket&>(socket); - auto received_descriptor_or_error = local_socket.recvfd(*socket_description); - - if (received_descriptor_or_error.is_error()) - return received_descriptor_or_error.error(); + auto received_description = TRY(local_socket.recvfd(*socket_description)); u32 fd_flags = 0; if (options & O_CLOEXEC) fd_flags |= FD_CLOEXEC; - m_fds[new_fd.fd].set(*received_descriptor_or_error.value(), fd_flags); - return new_fd.fd; + m_fds[fd_allocation.fd].set(move(received_description), fd_flags); + return fd_allocation.fd; } } |