diff options
author | Andreas Kling <kling@serenityos.org> | 2021-09-05 17:38:37 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-05 17:38:37 +0200 |
commit | 48a0b31c478cb78dece459369610e0f993c8f6f0 (patch) | |
tree | f08fde80936619aa94f84edb0973878d8810d147 /Kernel/Syscalls/chdir.cpp | |
parent | 9903f5c6ef76dfd3c15e63205e307c9519c32ff3 (diff) | |
download | serenity-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/chdir.cpp')
-rw-r--r-- | Kernel/Syscalls/chdir.cpp | 3 |
1 files changed, 1 insertions, 2 deletions
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<FlatPtr> Process::sys$getcwd(Userspace<char*> 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; } |