1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 18:17:44 +00:00

Kernel: Make Process::FileDescriptions::allocate return KResultOr<int>

Modernize more error checking by utilizing KResultOr.
This commit is contained in:
Brian Gianforcaro 2021-07-27 02:12:51 -07:00 committed by Andreas Kling
parent d2cee9cbf6
commit ba03b6ad02
10 changed files with 48 additions and 37 deletions

View file

@ -46,9 +46,10 @@ KResultOr<FlatPtr> Process::sys$recvfd(int sockfd, int options)
if (!socket.is_local())
return EAFNOSUPPORT;
int new_fd = m_fds.allocate();
if (new_fd < 0)
return new_fd;
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.value();
auto& local_socket = static_cast<LocalSocket&>(socket);
auto received_descriptor_or_error = local_socket.recvfd(*socket_description);