From a166a65eff40ae69f21b491897054d9526a05275 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 15 Mar 2021 09:04:04 +0100 Subject: [PATCH] Kernel: Don't return -EFOO when return type is KResultOr<...> --- Kernel/FileSystem/FIFO.cpp | 3 ++- Kernel/FileSystem/Inode.h | 2 +- Kernel/Net/Socket.cpp | 2 +- Kernel/Syscall.cpp | 4 ++-- Kernel/Syscalls/clock.cpp | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Kernel/FileSystem/FIFO.cpp b/Kernel/FileSystem/FIFO.cpp index 088f98b585..82c6abefba 100644 --- a/Kernel/FileSystem/FIFO.cpp +++ b/Kernel/FileSystem/FIFO.cpp @@ -155,8 +155,9 @@ KResultOr FIFO::write(FileDescription&, size_t, const UserOrKernelBuffer { if (!m_readers) { Thread::current()->send_signal(SIGPIPE, Process::current()); - return -EPIPE; + return EPIPE; } + return m_buffer.write(buffer, size); } diff --git a/Kernel/FileSystem/Inode.h b/Kernel/FileSystem/Inode.h index d7906b9c09..3e0b5645a5 100644 --- a/Kernel/FileSystem/Inode.h +++ b/Kernel/FileSystem/Inode.h @@ -85,7 +85,7 @@ public: virtual KResult truncate(u64) { return KSuccess; } virtual KResultOr> resolve_as_link(Custody& base, RefPtr* out_parent, int options, int symlink_recursion_level) const; - virtual KResultOr get_block_address(int) { return -ENOTSUP; } + virtual KResultOr get_block_address(int) { return ENOTSUP; } LocalSocket* socket() { return m_socket.ptr(); } const LocalSocket* socket() const { return m_socket.ptr(); } diff --git a/Kernel/Net/Socket.cpp b/Kernel/Net/Socket.cpp index d0ad2e3cec..24be032119 100644 --- a/Kernel/Net/Socket.cpp +++ b/Kernel/Net/Socket.cpp @@ -254,7 +254,7 @@ KResultOr Socket::read(FileDescription& description, size_t, UserOrKerne KResultOr Socket::write(FileDescription& description, size_t, const UserOrKernelBuffer& data, size_t size) { if (is_shut_down_for_writing()) - return -EPIPE; + return EPIPE; return sendto(description, data, size, 0, {}, 0); } diff --git a/Kernel/Syscall.cpp b/Kernel/Syscall.cpp index e46aa0f335..a093a6f895 100644 --- a/Kernel/Syscall.cpp +++ b/Kernel/Syscall.cpp @@ -131,12 +131,12 @@ KResultOr handle(RegisterState& regs, FlatPtr function, FlatPtr arg1, F if (function >= Function::__Count) { dbgln("Unknown syscall {} requested ({:08x}, {:08x}, {:08x})", function, arg1, arg2, arg3); - return -ENOSYS; + return ENOSYS; } if (s_syscall_table[function] == nullptr) { dbgln("Null syscall {} requested, you probably need to rebuild this program!", function); - return -ENOSYS; + return ENOSYS; } return (process.*(s_syscall_table[function]))(arg1, arg2, arg3); } diff --git a/Kernel/Syscalls/clock.cpp b/Kernel/Syscalls/clock.cpp index 2966a4f70b..610d59221c 100644 --- a/Kernel/Syscalls/clock.cpp +++ b/Kernel/Syscalls/clock.cpp @@ -75,7 +75,7 @@ KResultOr Process::sys$clock_nanosleep(Userspace requested_sleep = copy_time_from_user(params.requested_sleep); if (!requested_sleep.has_value()) - return -EFAULT; + return EFAULT; bool is_absolute; switch (params.flags) {