summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-09-05 16:14:34 +0200
committerAndreas Kling <kling@serenityos.org>2021-09-05 16:25:40 +0200
commit29bafec43bac0e61cdb2972cbde4ce0697722d20 (patch)
tree4daa8fe46c5349af5ecc46acbf57b05577834303 /Kernel
parentc767e20f911953cbc85e8d1bc4679b508699bc0d (diff)
downloadserenity-29bafec43bac0e61cdb2972cbde4ce0697722d20.zip
Kernel: Use is_error() in sys$fcntl()
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/Syscalls/fcntl.cpp9
1 files changed, 3 insertions, 6 deletions
diff --git a/Kernel/Syscalls/fcntl.cpp b/Kernel/Syscalls/fcntl.cpp
index c2d59bda0f..33265302ff 100644
--- a/Kernel/Syscalls/fcntl.cpp
+++ b/Kernel/Syscalls/fcntl.cpp
@@ -25,12 +25,9 @@ KResultOr<FlatPtr> Process::sys$fcntl(int fd, int cmd, u32 arg)
int arg_fd = (int)arg;
if (arg_fd < 0)
return EINVAL;
- auto new_fd_or_error = fds().allocate(arg_fd);
- if (new_fd_or_error.is_error())
- return new_fd_or_error.error();
- auto new_fd = new_fd_or_error.release_value();
- m_fds[new_fd.fd].set(*description);
- return new_fd.fd;
+ auto fd_allocation = TRY(m_fds.allocate(arg_fd));
+ m_fds[fd_allocation.fd].set(*description);
+ return fd_allocation.fd;
}
case F_GETFD:
return m_fds[fd].flags();