mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-25 10:48:41 +00:00
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.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user