diff options
author | Andreas Kling <kling@serenityos.org> | 2021-11-08 00:51:39 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-11-08 01:10:53 +0100 |
commit | 79fa9765ca89869d19364143989436d117974c21 (patch) | |
tree | 3af62f70127d9217d841047f6b7461351800d1ae /Kernel/Bus/PCI | |
parent | 7ee10c69264cb278845a1e1b06d5acf2e5e7ddf0 (diff) | |
download | serenity-79fa9765ca89869d19364143989436d117974c21.zip |
Kernel: Replace KResult and KResultOr<T> with Error and ErrorOr<T>
We now use AK::Error and AK::ErrorOr<T> in both kernel and userspace!
This was a slightly tedious refactoring that took a long time, so it's
not unlikely that some bugs crept in.
Nevertheless, it does pass basic functionality testing, and it's just
real nice to finally see the same pattern in all contexts. :^)
Diffstat (limited to 'Kernel/Bus/PCI')
-rw-r--r-- | Kernel/Bus/PCI/Access.cpp | 2 | ||||
-rw-r--r-- | Kernel/Bus/PCI/SysFSPCI.cpp | 6 | ||||
-rw-r--r-- | Kernel/Bus/PCI/SysFSPCI.h | 4 |
3 files changed, 6 insertions, 6 deletions
diff --git a/Kernel/Bus/PCI/Access.cpp b/Kernel/Bus/PCI/Access.cpp index ad1f8c9106..664d7bc150 100644 --- a/Kernel/Bus/PCI/Access.cpp +++ b/Kernel/Bus/PCI/Access.cpp @@ -5,8 +5,8 @@ */ #include <AK/ByteReader.h> +#include <AK/Error.h> #include <AK/HashTable.h> -#include <Kernel/API/KResult.h> #include <Kernel/Arch/x86/IO.h> #include <Kernel/Bus/PCI/Access.h> #include <Kernel/Debug.h> diff --git a/Kernel/Bus/PCI/SysFSPCI.cpp b/Kernel/Bus/PCI/SysFSPCI.cpp index a8fc6e9ddc..ab79bdd4f6 100644 --- a/Kernel/Bus/PCI/SysFSPCI.cpp +++ b/Kernel/Bus/PCI/SysFSPCI.cpp @@ -59,19 +59,19 @@ PCIDeviceAttributeSysFSComponent::PCIDeviceAttributeSysFSComponent(String name, { } -KResultOr<size_t> PCIDeviceAttributeSysFSComponent::read_bytes(off_t offset, size_t count, UserOrKernelBuffer& buffer, OpenFileDescription*) const +ErrorOr<size_t> PCIDeviceAttributeSysFSComponent::read_bytes(off_t offset, size_t count, UserOrKernelBuffer& buffer, OpenFileDescription*) const { auto blob = TRY(try_to_generate_buffer()); if ((size_t)offset >= blob->size()) - return KSuccess; + return 0; ssize_t nread = min(static_cast<off_t>(blob->size() - offset), static_cast<off_t>(count)); TRY(buffer.write(blob->data() + offset, nread)); return nread; } -KResultOr<NonnullOwnPtr<KBuffer>> PCIDeviceAttributeSysFSComponent::try_to_generate_buffer() const +ErrorOr<NonnullOwnPtr<KBuffer>> PCIDeviceAttributeSysFSComponent::try_to_generate_buffer() const { String value; switch (m_field_bytes_width) { diff --git a/Kernel/Bus/PCI/SysFSPCI.h b/Kernel/Bus/PCI/SysFSPCI.h index 4286150eaf..60b2bfddab 100644 --- a/Kernel/Bus/PCI/SysFSPCI.h +++ b/Kernel/Bus/PCI/SysFSPCI.h @@ -37,11 +37,11 @@ class PCIDeviceAttributeSysFSComponent : public SysFSComponent { public: static NonnullRefPtr<PCIDeviceAttributeSysFSComponent> create(String name, const PCIDeviceSysFSDirectory& device, PCI::RegisterOffset offset, size_t field_bytes_width); - virtual KResultOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer&, OpenFileDescription*) const override; + virtual ErrorOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer&, OpenFileDescription*) const override; virtual ~PCIDeviceAttributeSysFSComponent() {}; protected: - KResultOr<NonnullOwnPtr<KBuffer>> try_to_generate_buffer() const; + ErrorOr<NonnullOwnPtr<KBuffer>> try_to_generate_buffer() const; PCIDeviceAttributeSysFSComponent(String name, const PCIDeviceSysFSDirectory& device, PCI::RegisterOffset offset, size_t field_bytes_width); NonnullRefPtr<PCIDeviceSysFSDirectory> m_device; PCI::RegisterOffset m_offset; |