diff options
author | Andreas Kling <kling@serenityos.org> | 2021-03-01 13:49:16 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-03-01 13:54:32 +0100 |
commit | ac71775de5a71945e004f46b184dde4f628d112b (patch) | |
tree | bac755ef16ba74bd63d3a359e6aad9e32d2734ae /Kernel/Syscalls/stat.cpp | |
parent | 9af1e1a3bf43140dee327eb4f553c56ba95ad9d9 (diff) | |
download | serenity-ac71775de5a71945e004f46b184dde4f628d112b.zip |
Kernel: Make all syscall functions return KResultOr<T>
This makes it a lot easier to return errors since we no longer have to
worry about negating EFOO errors and can just return them flat.
Diffstat (limited to 'Kernel/Syscalls/stat.cpp')
-rw-r--r-- | Kernel/Syscalls/stat.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Kernel/Syscalls/stat.cpp b/Kernel/Syscalls/stat.cpp index 19cdb14f78..236eb39d8a 100644 --- a/Kernel/Syscalls/stat.cpp +++ b/Kernel/Syscalls/stat.cpp @@ -31,25 +31,25 @@ namespace Kernel { -int Process::sys$fstat(int fd, Userspace<stat*> user_statbuf) +KResultOr<int> Process::sys$fstat(int fd, Userspace<stat*> user_statbuf) { REQUIRE_PROMISE(stdio); auto description = file_description(fd); if (!description) - return -EBADF; + return EBADF; stat buffer = {}; int rc = description->stat(buffer); if (!copy_to_user(user_statbuf, &buffer)) - return -EFAULT; + return EFAULT; return rc; } -int Process::sys$stat(Userspace<const Syscall::SC_stat_params*> user_params) +KResultOr<int> Process::sys$stat(Userspace<const Syscall::SC_stat_params*> user_params) { REQUIRE_PROMISE(rpath); Syscall::SC_stat_params params; if (!copy_from_user(¶ms, user_params)) - return -EFAULT; + return EFAULT; auto path = get_syscall_path_argument(params.path); if (path.is_error()) return path.error(); @@ -61,7 +61,7 @@ int Process::sys$stat(Userspace<const Syscall::SC_stat_params*> user_params) if (result.is_error()) return result; if (!copy_to_user(params.statbuf, &statbuf)) - return -EFAULT; + return EFAULT; return 0; } |