diff options
author | Andreas Kling <kling@serenityos.org> | 2021-09-07 15:22:24 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-07 15:22:24 +0200 |
commit | 250b52d6e5ef4b57048ef7f52a02ebb2fb87780b (patch) | |
tree | ae1fcf16f632c159ee967073185acadd63a37670 /Kernel/Bus/PCI | |
parent | 899cee8185d06c7fe9b08e6b1a846cd6bc4363e1 (diff) | |
download | serenity-250b52d6e5ef4b57048ef7f52a02ebb2fb87780b.zip |
Kernel: Make KBuffer::try_create_with_bytes() return KResultOr
Diffstat (limited to 'Kernel/Bus/PCI')
-rw-r--r-- | Kernel/Bus/PCI/SysFSPCI.cpp | 6 | ||||
-rw-r--r-- | Kernel/Bus/PCI/SysFSPCI.h | 2 |
2 files changed, 3 insertions, 5 deletions
diff --git a/Kernel/Bus/PCI/SysFSPCI.cpp b/Kernel/Bus/PCI/SysFSPCI.cpp index 56a0f6ec9b..3a6e57dbfa 100644 --- a/Kernel/Bus/PCI/SysFSPCI.cpp +++ b/Kernel/Bus/PCI/SysFSPCI.cpp @@ -62,9 +62,7 @@ PCIDeviceAttributeSysFSComponent::PCIDeviceAttributeSysFSComponent(String name, KResultOr<size_t> PCIDeviceAttributeSysFSComponent::read_bytes(off_t offset, size_t count, UserOrKernelBuffer& buffer, OpenFileDescription*) const { - auto blob = try_to_generate_buffer(); - if (!blob) - return KResult(EFAULT); + auto blob = TRY(try_to_generate_buffer()); if ((size_t)offset >= blob->size()) return KSuccess; @@ -74,7 +72,7 @@ KResultOr<size_t> PCIDeviceAttributeSysFSComponent::read_bytes(off_t offset, siz return nread; } -OwnPtr<KBuffer> PCIDeviceAttributeSysFSComponent::try_to_generate_buffer() const +KResultOr<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 e6ddd35216..9a3bc47f9f 100644 --- a/Kernel/Bus/PCI/SysFSPCI.h +++ b/Kernel/Bus/PCI/SysFSPCI.h @@ -41,7 +41,7 @@ public: virtual ~PCIDeviceAttributeSysFSComponent() {}; protected: - virtual OwnPtr<KBuffer> try_to_generate_buffer() const; + KResultOr<NonnullOwnPtr<KBuffer>> try_to_generate_buffer() const; PCIDeviceAttributeSysFSComponent(String name, const PCIDeviceSysFSDirectory& device, size_t offset, size_t field_bytes_width); NonnullRefPtr<PCIDeviceSysFSDirectory> m_device; size_t m_offset; |