summaryrefslogtreecommitdiff
path: root/Kernel/Bus/PCI
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-09-07 15:22:24 +0200
committerAndreas Kling <kling@serenityos.org>2021-09-07 15:22:24 +0200
commit250b52d6e5ef4b57048ef7f52a02ebb2fb87780b (patch)
treeae1fcf16f632c159ee967073185acadd63a37670 /Kernel/Bus/PCI
parent899cee8185d06c7fe9b08e6b1a846cd6bc4363e1 (diff)
downloadserenity-250b52d6e5ef4b57048ef7f52a02ebb2fb87780b.zip
Kernel: Make KBuffer::try_create_with_bytes() return KResultOr
Diffstat (limited to 'Kernel/Bus/PCI')
-rw-r--r--Kernel/Bus/PCI/SysFSPCI.cpp6
-rw-r--r--Kernel/Bus/PCI/SysFSPCI.h2
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;