diff options
author | Andreas Kling <kling@serenityos.org> | 2021-09-05 18:34:28 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-05 18:36:13 +0200 |
commit | a9204510a4c0c37588a38201f305d7e9b4e762a9 (patch) | |
tree | 752b1077191f2608755104f6cca2a19bc9f4591c /Kernel/Syscalls/get_dir_entries.cpp | |
parent | 2d2ea05c97e97848f431b5c9e5f709fe276eb7c8 (diff) | |
download | serenity-a9204510a4c0c37588a38201f305d7e9b4e762a9.zip |
Kernel: Make file description lookup return KResultOr
Instead of checking it at every call site (to generate EBADF), we make
file_description(fd) return a KResultOr<NonnullRefPtr<FileDescription>>.
This allows us to wrap all the calls in TRY(). :^)
The only place that got a little bit messier from this is sys$mount(),
and there's a whole bunch of things there in need of cleanup.
Diffstat (limited to 'Kernel/Syscalls/get_dir_entries.cpp')
-rw-r--r-- | Kernel/Syscalls/get_dir_entries.cpp | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/Kernel/Syscalls/get_dir_entries.cpp b/Kernel/Syscalls/get_dir_entries.cpp index 2f98386858..6cbd6c6fc7 100644 --- a/Kernel/Syscalls/get_dir_entries.cpp +++ b/Kernel/Syscalls/get_dir_entries.cpp @@ -15,9 +15,7 @@ KResultOr<FlatPtr> Process::sys$get_dir_entries(int fd, Userspace<void*> user_bu REQUIRE_PROMISE(stdio); if (user_size > NumericLimits<ssize_t>::max()) return EINVAL; - auto description = fds().file_description(fd); - if (!description) - return EBADF; + auto description = TRY(fds().file_description(fd)); auto buffer = UserOrKernelBuffer::for_user_buffer(user_buffer, static_cast<size_t>(user_size)); if (!buffer.has_value()) return EFAULT; |