1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:37:35 +00:00

Kernel: Use TRY() in sys$recvfd()

This commit is contained in:
Andreas Kling 2021-09-05 18:08:47 +02:00
parent ea911bc125
commit 77b7a44691

View file

@ -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;
}
}