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/ttyname.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/ttyname.cpp')
-rw-r--r-- | Kernel/Syscalls/ttyname.cpp | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/Kernel/Syscalls/ttyname.cpp b/Kernel/Syscalls/ttyname.cpp index 5e795d9ff6..1b0cb09309 100644 --- a/Kernel/Syscalls/ttyname.cpp +++ b/Kernel/Syscalls/ttyname.cpp @@ -15,9 +15,7 @@ KResultOr<FlatPtr> Process::sys$ttyname(int fd, Userspace<char*> buffer, size_t { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) REQUIRE_PROMISE(tty); - auto description = fds().file_description(fd); - if (!description) - return EBADF; + auto description = TRY(fds().file_description(fd)); if (!description->is_tty()) return ENOTTY; auto tty_name = description->tty()->tty_name(); @@ -30,9 +28,7 @@ KResultOr<FlatPtr> Process::sys$ptsname(int fd, Userspace<char*> buffer, size_t { VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this) REQUIRE_PROMISE(tty); - auto description = fds().file_description(fd); - if (!description) - return EBADF; + auto description = TRY(fds().file_description(fd)); auto* master_pty = description->master_pty(); if (!master_pty) return ENOTTY; |