summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-09-05 18:08:47 +0200
committerAndreas Kling <kling@serenityos.org>2021-09-05 18:15:05 +0200
commit77b7a44691f561d714d2dad931b3ae903e4cbe6d (patch)
treece2156d301a9ac5484962e7507a8cf291047f4a6
parentea911bc1251825e34faabe1cb87479d6071a30e9 (diff)
downloadserenity-77b7a44691f561d714d2dad931b3ae903e4cbe6d.zip
Kernel: Use TRY() in sys$recvfd()
-rw-r--r--Kernel/Syscalls/sendfd.cpp14
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;
}
}