summaryrefslogtreecommitdiff
path: root/Kernel/Bus/PCI
diff options
context:
space:
mode:
authorBrian Gianforcaro <bgianf@serenityos.org>2021-11-29 03:02:55 -0800
committerAndreas Kling <kling@serenityos.org>2021-11-30 11:16:35 +0100
commit1f65728d8b931c80ba15755fde0080a4e8dc27d9 (patch)
treea5116d1046b414bc094fc48f481dc0f8297b1feb /Kernel/Bus/PCI
parent74ee491b842e1f1a4df75f81e980957ff194c5b0 (diff)
downloadserenity-1f65728d8b931c80ba15755fde0080a4e8dc27d9.zip
Kernel: Handle string format errors in PCIDeviceAttributeSysFSComponent
Diffstat (limited to 'Kernel/Bus/PCI')
-rw-r--r--Kernel/Bus/PCI/SysFSPCI.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/Kernel/Bus/PCI/SysFSPCI.cpp b/Kernel/Bus/PCI/SysFSPCI.cpp
index ab79bdd4f6..058df1323f 100644
--- a/Kernel/Bus/PCI/SysFSPCI.cpp
+++ b/Kernel/Bus/PCI/SysFSPCI.cpp
@@ -73,21 +73,21 @@ ErrorOr<size_t> PCIDeviceAttributeSysFSComponent::read_bytes(off_t offset, size_
ErrorOr<NonnullOwnPtr<KBuffer>> PCIDeviceAttributeSysFSComponent::try_to_generate_buffer() const
{
- String value;
+ OwnPtr<KString> value;
switch (m_field_bytes_width) {
case 1:
- value = String::formatted("{:#x}", PCI::read8(m_device->address(), m_offset));
+ value = TRY(KString::formatted("{:#x}", PCI::read8(m_device->address(), m_offset)));
break;
case 2:
- value = String::formatted("{:#x}", PCI::read16(m_device->address(), m_offset));
+ value = TRY(KString::formatted("{:#x}", PCI::read16(m_device->address(), m_offset)));
break;
case 4:
- value = String::formatted("{:#x}", PCI::read32(m_device->address(), m_offset));
+ value = TRY(KString::formatted("{:#x}", PCI::read32(m_device->address(), m_offset)));
break;
default:
VERIFY_NOT_REACHED();
}
- return KBuffer::try_create_with_bytes(value.substring_view(0).bytes());
+ return KBuffer::try_create_with_bytes(value->view().bytes());
}
}