From ad3ae7e0e850313a38ef94c986a058e272f6936b Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 6 Aug 2021 00:35:27 +0200 Subject: [PATCH] Kernel: Fix handful of remaining "return -EFOO" mistakes Now that all KResult and KResultOr are used consistently throughout the kernel, it's no longer necessary to return negative error codes. However, we were still doing that in some places, so let's fix all those (bugs) by removing the minuses. :^) --- Kernel/Devices/KCOVDevice.h | 4 ++-- Kernel/Devices/MemoryDevice.h | 2 +- Kernel/FileSystem/FileDescription.cpp | 2 +- Kernel/FileSystem/Plan9FileSystem.cpp | 2 +- Kernel/FileSystem/SysFSComponent.h | 2 +- Kernel/Graphics/FramebufferDevice.h | 4 ++-- Kernel/Net/IPv4Socket.cpp | 2 +- Kernel/TTY/TTY.cpp | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Kernel/Devices/KCOVDevice.h b/Kernel/Devices/KCOVDevice.h index 80b522b80b..dcfcfd6968 100644 --- a/Kernel/Devices/KCOVDevice.h +++ b/Kernel/Devices/KCOVDevice.h @@ -35,8 +35,8 @@ protected: virtual bool can_read(const FileDescription&, size_t) const override final { return true; } virtual bool can_write(const FileDescription&, size_t) const override final { return true; } virtual void start_request(AsyncBlockDeviceRequest& request) override final { request.complete(AsyncDeviceRequest::Failure); } - virtual KResultOr read(FileDescription&, u64, UserOrKernelBuffer&, size_t) override { return -EINVAL; } - virtual KResultOr write(FileDescription&, u64, const UserOrKernelBuffer&, size_t) override { return -EINVAL; } + virtual KResultOr read(FileDescription&, u64, UserOrKernelBuffer&, size_t) override { return EINVAL; } + virtual KResultOr write(FileDescription&, u64, const UserOrKernelBuffer&, size_t) override { return EINVAL; } virtual KResult ioctl(FileDescription&, unsigned request, Userspace arg) override; private: diff --git a/Kernel/Devices/MemoryDevice.h b/Kernel/Devices/MemoryDevice.h index d5aacf0191..cf5ff1f472 100644 --- a/Kernel/Devices/MemoryDevice.h +++ b/Kernel/Devices/MemoryDevice.h @@ -32,7 +32,7 @@ private: virtual bool can_write(const FileDescription&, size_t) const override { return false; } virtual bool is_seekable() const override { return true; } virtual KResultOr read(FileDescription&, u64, UserOrKernelBuffer&, size_t) override; - virtual KResultOr write(FileDescription&, u64, const UserOrKernelBuffer&, size_t) override { return -EINVAL; } + virtual KResultOr write(FileDescription&, u64, const UserOrKernelBuffer&, size_t) override { return EINVAL; } virtual void did_seek(FileDescription&, off_t) override; diff --git a/Kernel/FileSystem/FileDescription.cpp b/Kernel/FileSystem/FileDescription.cpp index 6432cb26aa..ed4a488c51 100644 --- a/Kernel/FileSystem/FileDescription.cpp +++ b/Kernel/FileSystem/FileDescription.cpp @@ -270,7 +270,7 @@ KResultOr FileDescription::get_dir_entries(UserOrKernelBuffer& output_bu flush_stream_to_output_buffer(); if (result.is_error()) { - // We should only return -EFAULT when the userspace buffer is too small, + // We should only return EFAULT when the userspace buffer is too small, // so that userspace can reliably use it as a signal to increase its // buffer size. VERIFY(result != -EFAULT); diff --git a/Kernel/FileSystem/Plan9FileSystem.cpp b/Kernel/FileSystem/Plan9FileSystem.cpp index c8a015ded1..b21c81143a 100644 --- a/Kernel/FileSystem/Plan9FileSystem.cpp +++ b/Kernel/FileSystem/Plan9FileSystem.cpp @@ -618,7 +618,7 @@ KResult Plan9FS::post_message_and_wait_for_a_reply(Message& message) return KResult((ErrnoCode)error_code); } else if (reply_type == Message::Type::Rerror) { // Contains an error message. We could attempt to parse it, but for now - // we simply return -EIO instead. In 9P200.u, it can also contain a + // we simply return EIO instead. In 9P200.u, it can also contain a // numerical errno in an unspecified encoding; we ignore those too. StringView error_name; message >> error_name; diff --git a/Kernel/FileSystem/SysFSComponent.h b/Kernel/FileSystem/SysFSComponent.h index e222e41459..3bbf6019c9 100644 --- a/Kernel/FileSystem/SysFSComponent.h +++ b/Kernel/FileSystem/SysFSComponent.h @@ -24,7 +24,7 @@ public: virtual KResultOr read_bytes(off_t, size_t, UserOrKernelBuffer&, FileDescription*) const { VERIFY_NOT_REACHED(); } virtual KResult traverse_as_directory(unsigned, Function) const { VERIFY_NOT_REACHED(); } virtual RefPtr lookup(StringView) { VERIFY_NOT_REACHED(); }; - virtual KResultOr write_bytes(off_t, size_t, UserOrKernelBuffer const&, FileDescription*) { return -EROFS; } + virtual KResultOr write_bytes(off_t, size_t, UserOrKernelBuffer const&, FileDescription*) { return EROFS; } virtual size_t size() const { return 0; } virtual NonnullRefPtr to_inode(SysFS const&) const; diff --git a/Kernel/Graphics/FramebufferDevice.h b/Kernel/Graphics/FramebufferDevice.h index 033c248dbb..60e130461a 100644 --- a/Kernel/Graphics/FramebufferDevice.h +++ b/Kernel/Graphics/FramebufferDevice.h @@ -43,8 +43,8 @@ private: virtual bool can_read(const FileDescription&, size_t) const override final { return true; } virtual bool can_write(const FileDescription&, size_t) const override final { return true; } virtual void start_request(AsyncBlockDeviceRequest& request) override final { request.complete(AsyncDeviceRequest::Failure); } - virtual KResultOr read(FileDescription&, u64, UserOrKernelBuffer&, size_t) override { return -EINVAL; } - virtual KResultOr write(FileDescription&, u64, const UserOrKernelBuffer&, size_t) override { return -EINVAL; } + virtual KResultOr read(FileDescription&, u64, UserOrKernelBuffer&, size_t) override { return EINVAL; } + virtual KResultOr write(FileDescription&, u64, const UserOrKernelBuffer&, size_t) override { return EINVAL; } FramebufferDevice(const GraphicsDevice&, size_t, PhysicalAddress, size_t, size_t, size_t); diff --git a/Kernel/Net/IPv4Socket.cpp b/Kernel/Net/IPv4Socket.cpp index 4dd6d99a43..e14ba323bb 100644 --- a/Kernel/Net/IPv4Socket.cpp +++ b/Kernel/Net/IPv4Socket.cpp @@ -298,7 +298,7 @@ KResultOr IPv4Socket::receive_packet_buffered(FileDescription& descripti ReceivedPacket packet; { if (m_receive_queue.is_empty()) { - // FIXME: Shouldn't this return -ENOTCONN instead of EOF? + // FIXME: Shouldn't this return ENOTCONN instead of EOF? // But if so, we still need to deliver at least one EOF read to userspace.. right? if (protocol_is_disconnected()) return 0; diff --git a/Kernel/TTY/TTY.cpp b/Kernel/TTY/TTY.cpp index db7962bdb1..598eba8e85 100644 --- a/Kernel/TTY/TTY.cpp +++ b/Kernel/TTY/TTY.cpp @@ -465,7 +465,7 @@ KResult TTY::ioctl(FileDescription&, unsigned request, Userspace arg) // FIXME: When should we block things? // How do we make this work together with MasterPTY forwarding to us? if (current_process.tty() && current_process.tty() != this) { - return -ENOTTY; + return ENOTTY; } #endif switch (request) {