From 250b52d6e5ef4b57048ef7f52a02ebb2fb87780b Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 7 Sep 2021 15:22:24 +0200 Subject: Kernel: Make KBuffer::try_create_with_bytes() return KResultOr --- Kernel/Bus/PCI/SysFSPCI.cpp | 6 ++---- Kernel/Bus/PCI/SysFSPCI.h | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) (limited to 'Kernel/Bus/PCI') 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 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 PCIDeviceAttributeSysFSComponent::read_bytes(off_t offset, siz return nread; } -OwnPtr PCIDeviceAttributeSysFSComponent::try_to_generate_buffer() const +KResultOr> 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 try_to_generate_buffer() const; + KResultOr> try_to_generate_buffer() const; PCIDeviceAttributeSysFSComponent(String name, const PCIDeviceSysFSDirectory& device, size_t offset, size_t field_bytes_width); NonnullRefPtr m_device; size_t m_offset; -- cgit v1.2.3