summaryrefslogtreecommitdiff
path: root/Kernel/Syscalls/realpath.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-09-05 17:38:37 +0200
committerAndreas Kling <kling@serenityos.org>2021-09-05 17:38:37 +0200
commit48a0b31c478cb78dece459369610e0f993c8f6f0 (patch)
treef08fde80936619aa94f84edb0973878d8810d147 /Kernel/Syscalls/realpath.cpp
parent9903f5c6ef76dfd3c15e63205e307c9519c32ff3 (diff)
downloadserenity-48a0b31c478cb78dece459369610e0f993c8f6f0.zip
Kernel: Make copy_{from,to}_user() return KResult and use TRY()
This makes EFAULT propagation flow much more naturally. :^)
Diffstat (limited to 'Kernel/Syscalls/realpath.cpp')
-rw-r--r--Kernel/Syscalls/realpath.cpp6
1 files changed, 2 insertions, 4 deletions
diff --git a/Kernel/Syscalls/realpath.cpp b/Kernel/Syscalls/realpath.cpp
index eac65ef303..168ef61f6e 100644
--- a/Kernel/Syscalls/realpath.cpp
+++ b/Kernel/Syscalls/realpath.cpp
@@ -17,8 +17,7 @@ KResultOr<FlatPtr> Process::sys$realpath(Userspace<const Syscall::SC_realpath_pa
REQUIRE_PROMISE(rpath);
Syscall::SC_realpath_params params;
- if (!copy_from_user(&params, user_params))
- return EFAULT;
+ TRY(copy_from_user(&params, user_params));
auto path = get_syscall_path_argument(params.path);
if (path.is_error())
@@ -34,8 +33,7 @@ KResultOr<FlatPtr> Process::sys$realpath(Userspace<const Syscall::SC_realpath_pa
size_t ideal_size = absolute_path->length() + 1;
auto size_to_copy = min(ideal_size, params.buffer.size);
- if (!copy_to_user(params.buffer.data, absolute_path->characters(), size_to_copy))
- return EFAULT;
+ TRY(copy_to_user(params.buffer.data, absolute_path->characters(), size_to_copy));
// Note: we return the whole size here, not the copied size.
return ideal_size;
};