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/pledge.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/pledge.cpp')
-rw-r--r-- | Kernel/Syscalls/pledge.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/Kernel/Syscalls/pledge.cpp b/Kernel/Syscalls/pledge.cpp index 448fad8ef8..2d1676ab5a 100644 --- a/Kernel/Syscalls/pledge.cpp +++ b/Kernel/Syscalls/pledge.cpp @@ -29,27 +29,27 @@ namespace Kernel { -int Process::sys$pledge(Userspace<const Syscall::SC_pledge_params*> user_params) +KResultOr<int> Process::sys$pledge(Userspace<const Syscall::SC_pledge_params*> user_params) { Syscall::SC_pledge_params params; if (!copy_from_user(¶ms, user_params)) - return -EFAULT; + return EFAULT; if (params.promises.length > 1024 || params.execpromises.length > 1024) - return -E2BIG; + return E2BIG; String promises; if (params.promises.characters) { promises = copy_string_from_user(params.promises); if (promises.is_null()) - return -EFAULT; + return EFAULT; } String execpromises; if (params.execpromises.characters) { execpromises = copy_string_from_user(params.execpromises); if (execpromises.is_null()) - return -EFAULT; + return EFAULT; } auto parse_pledge = [&](auto& pledge_spec, u32& mask) { @@ -70,9 +70,9 @@ int Process::sys$pledge(Userspace<const Syscall::SC_pledge_params*> user_params) if (!promises.is_null()) { u32 new_promises = 0; if (!parse_pledge(promises, new_promises)) - return -EINVAL; + return EINVAL; if (m_promises && (!new_promises || new_promises & ~m_promises)) - return -EPERM; + return EPERM; m_has_promises = true; m_promises = new_promises; } @@ -80,9 +80,9 @@ int Process::sys$pledge(Userspace<const Syscall::SC_pledge_params*> user_params) if (!execpromises.is_null()) { u32 new_execpromises = 0; if (!parse_pledge(execpromises, new_execpromises)) - return -EINVAL; + return EINVAL; if (m_execpromises && (!new_execpromises || new_execpromises & ~m_execpromises)) - return -EPERM; + return EPERM; m_has_execpromises = true; m_execpromises = new_execpromises; } |