summaryrefslogtreecommitdiff
path: root/Kernel/Syscalls/select.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Kernel/Syscalls/select.cpp')
-rw-r--r--Kernel/Syscalls/select.cpp16
1 files changed, 4 insertions, 12 deletions
diff --git a/Kernel/Syscalls/select.cpp b/Kernel/Syscalls/select.cpp
index 1e3d4b0b31..9ece4b8463 100644
--- a/Kernel/Syscalls/select.cpp
+++ b/Kernel/Syscalls/select.cpp
@@ -73,12 +73,8 @@ KResultOr<FlatPtr> Process::sys$select(Userspace<const Syscall::SC_select_params
if (block_flags == BlockFlags::None)
continue;
- auto description = fds().file_description(fd);
- if (!description) {
- dbgln("sys$select: Bad fd number {}", fd);
- return EBADF;
- }
- if (!fds_info.try_append({ description.release_nonnull(), block_flags }))
+ auto description = TRY(fds().file_description(fd));
+ if (!fds_info.try_append({ move(description), block_flags }))
return ENOMEM;
if (!selected_fds.try_append(fd))
return ENOMEM;
@@ -162,11 +158,7 @@ KResultOr<FlatPtr> Process::sys$poll(Userspace<const Syscall::SC_poll_params*> u
Thread::SelectBlocker::FDVector fds_info;
for (size_t i = 0; i < params.nfds; i++) {
auto& pfd = fds_copy[i];
- auto description = fds().file_description(pfd.fd);
- if (!description) {
- dbgln("sys$poll: Bad fd number {}", pfd.fd);
- return EBADF;
- }
+ auto description = TRY(fds().file_description(pfd.fd));
BlockFlags block_flags = BlockFlags::Exception; // always want POLLERR, POLLHUP, POLLNVAL
if (pfd.events & POLLIN)
block_flags |= BlockFlags::Read;
@@ -174,7 +166,7 @@ KResultOr<FlatPtr> Process::sys$poll(Userspace<const Syscall::SC_poll_params*> u
block_flags |= BlockFlags::Write;
if (pfd.events & POLLPRI)
block_flags |= BlockFlags::ReadPriority;
- if (!fds_info.try_append({ description.release_nonnull(), block_flags }))
+ if (!fds_info.try_append({ move(description), block_flags }))
return ENOMEM;
}