summaryrefslogtreecommitdiff
path: root/Kernel/Syscalls/sendfd.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Kernel/Syscalls/sendfd.cpp')
-rw-r--r--Kernel/Syscalls/sendfd.cpp13
1 files changed, 3 insertions, 10 deletions
diff --git a/Kernel/Syscalls/sendfd.cpp b/Kernel/Syscalls/sendfd.cpp
index fd82027f4f..6c0fed3cac 100644
--- a/Kernel/Syscalls/sendfd.cpp
+++ b/Kernel/Syscalls/sendfd.cpp
@@ -14,9 +14,7 @@ KResultOr<FlatPtr> Process::sys$sendfd(int sockfd, int fd)
{
VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this)
REQUIRE_PROMISE(sendfd);
- auto socket_description = fds().file_description(sockfd);
- if (!socket_description)
- return EBADF;
+ auto socket_description = TRY(fds().file_description(sockfd));
if (!socket_description->is_socket())
return ENOTSOCK;
auto& socket = *socket_description->socket();
@@ -25,10 +23,7 @@ KResultOr<FlatPtr> Process::sys$sendfd(int sockfd, int fd)
if (!socket.is_connected())
return ENOTCONN;
- auto passing_descriptor = fds().file_description(fd);
- if (!passing_descriptor)
- return EBADF;
-
+ auto passing_descriptor = TRY(fds().file_description(fd));
auto& local_socket = static_cast<LocalSocket&>(socket);
return local_socket.sendfd(*socket_description, *passing_descriptor);
}
@@ -37,9 +32,7 @@ KResultOr<FlatPtr> Process::sys$recvfd(int sockfd, int options)
{
VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this)
REQUIRE_PROMISE(recvfd);
- auto socket_description = fds().file_description(sockfd);
- if (!socket_description)
- return EBADF;
+ auto socket_description = TRY(fds().file_description(sockfd));
if (!socket_description->is_socket())
return ENOTSOCK;
auto& socket = *socket_description->socket();