From 48a0b31c478cb78dece459369610e0f993c8f6f0 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 5 Sep 2021 17:38:37 +0200 Subject: Kernel: Make copy_{from,to}_user() return KResult and use TRY() This makes EFAULT propagation flow much more naturally. :^) --- Kernel/Syscalls/chdir.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'Kernel/Syscalls/chdir.cpp') diff --git a/Kernel/Syscalls/chdir.cpp b/Kernel/Syscalls/chdir.cpp index eeaa1342a2..5b5da7acfc 100644 --- a/Kernel/Syscalls/chdir.cpp +++ b/Kernel/Syscalls/chdir.cpp @@ -52,8 +52,7 @@ KResultOr Process::sys$getcwd(Userspace buffer, size_t size) size_t ideal_size = path.length() + 1; auto size_to_copy = min(ideal_size, size); - if (!copy_to_user(buffer, path.characters(), size_to_copy)) - return EFAULT; + TRY(copy_to_user(buffer, path.characters(), size_to_copy)); // Note: we return the whole size here, not the copied size. return ideal_size; } -- cgit v1.2.3