diff options
author | Brian Gianforcaro <bgianf@serenityos.org> | 2021-11-29 03:02:55 -0800 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-11-30 11:16:35 +0100 |
commit | 1f65728d8b931c80ba15755fde0080a4e8dc27d9 (patch) | |
tree | a5116d1046b414bc094fc48f481dc0f8297b1feb /Kernel/Bus/PCI | |
parent | 74ee491b842e1f1a4df75f81e980957ff194c5b0 (diff) | |
download | serenity-1f65728d8b931c80ba15755fde0080a4e8dc27d9.zip |
Kernel: Handle string format errors in PCIDeviceAttributeSysFSComponent
Diffstat (limited to 'Kernel/Bus/PCI')
-rw-r--r-- | Kernel/Bus/PCI/SysFSPCI.cpp | 10 |
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()); } } |