diff options
author | Andreas Kling <kling@serenityos.org> | 2021-08-14 15:15:11 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-08-14 15:19:00 +0200 |
commit | 7676edfb9ba4d5052978968ba31ef940153ea7a9 (patch) | |
tree | c068023ed273da25fbecea848becc6848c738809 /Kernel/Syscalls | |
parent | d30d776ca46b12d7f4f9b5b7bdbfb247813a94af (diff) | |
download | serenity-7676edfb9ba4d5052978968ba31ef940153ea7a9.zip |
Kernel: Stop allowing implicit conversion from KResult to int
This patch removes KResult::operator int() and deals with the fallout.
This forces a lot of code to be more explicit in its handling of errors,
greatly improving readability.
Diffstat (limited to 'Kernel/Syscalls')
-rw-r--r-- | Kernel/Syscalls/open.cpp | 4 | ||||
-rw-r--r-- | Kernel/Syscalls/stat.cpp | 4 | ||||
-rw-r--r-- | Kernel/Syscalls/unveil.cpp | 2 |
3 files changed, 5 insertions, 5 deletions
diff --git a/Kernel/Syscalls/open.cpp b/Kernel/Syscalls/open.cpp index 209396ca97..77f2039669 100644 --- a/Kernel/Syscalls/open.cpp +++ b/Kernel/Syscalls/open.cpp @@ -84,9 +84,9 @@ KResultOr<FlatPtr> Process::sys$close(int fd) dbgln_if(IO_DEBUG, "sys$close({}) {}", fd, description.ptr()); if (!description) return EBADF; - int rc = description->close(); + auto result = description->close(); m_fds[fd] = {}; - return rc; + return result; } } diff --git a/Kernel/Syscalls/stat.cpp b/Kernel/Syscalls/stat.cpp index 7d42d49a2b..ac31ec9ce0 100644 --- a/Kernel/Syscalls/stat.cpp +++ b/Kernel/Syscalls/stat.cpp @@ -19,10 +19,10 @@ KResultOr<FlatPtr> Process::sys$fstat(int fd, Userspace<stat*> user_statbuf) if (!description) return EBADF; stat buffer = {}; - int rc = description->stat(buffer); + auto result = description->stat(buffer); if (!copy_to_user(user_statbuf, &buffer)) return EFAULT; - return rc; + return result; } KResultOr<FlatPtr> Process::sys$stat(Userspace<const Syscall::SC_stat_params*> user_params) diff --git a/Kernel/Syscalls/unveil.cpp b/Kernel/Syscalls/unveil.cpp index 7c7bfb7b95..710011a8e4 100644 --- a/Kernel/Syscalls/unveil.cpp +++ b/Kernel/Syscalls/unveil.cpp @@ -97,7 +97,7 @@ KResultOr<FlatPtr> Process::sys$unveil(Userspace<const Syscall::SC_unveil_params new_unveiled_path = custody_or_error.value()->try_create_absolute_path(); if (!new_unveiled_path) return ENOMEM; - } else if (custody_or_error.error() == -ENOENT && parent_custody && (new_permissions & UnveilAccess::CreateOrRemove)) { + } else if (custody_or_error.error() == ENOENT && parent_custody && (new_permissions & UnveilAccess::CreateOrRemove)) { auto parent_custody_path = parent_custody->try_create_absolute_path(); if (!parent_custody_path) return ENOMEM; |