mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 13:37:44 +00:00
Kernel: Make KBuffer::try_create_with_bytes() return KResultOr
This commit is contained in:
parent
899cee8185
commit
250b52d6e5
8 changed files with 16 additions and 24 deletions
|
@ -31,9 +31,7 @@ UNMAP_AFTER_INIT BIOSSysFSComponent::BIOSSysFSComponent(String name)
|
|||
|
||||
KResultOr<size_t> BIOSSysFSComponent::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;
|
||||
|
@ -50,7 +48,7 @@ UNMAP_AFTER_INIT DMIEntryPointExposedBlob::DMIEntryPointExposedBlob(PhysicalAddr
|
|||
{
|
||||
}
|
||||
|
||||
OwnPtr<KBuffer> DMIEntryPointExposedBlob::try_to_generate_buffer() const
|
||||
KResultOr<NonnullOwnPtr<KBuffer>> DMIEntryPointExposedBlob::try_to_generate_buffer() const
|
||||
{
|
||||
auto dmi_blob = Memory::map_typed<u8>((m_dmi_entry_point), m_dmi_entry_point_length);
|
||||
return KBuffer::try_create_with_bytes(Span<u8> { dmi_blob.ptr(), m_dmi_entry_point_length });
|
||||
|
@ -68,7 +66,7 @@ UNMAP_AFTER_INIT SMBIOSExposedTable::SMBIOSExposedTable(PhysicalAddress smbios_s
|
|||
{
|
||||
}
|
||||
|
||||
OwnPtr<KBuffer> SMBIOSExposedTable::try_to_generate_buffer() const
|
||||
KResultOr<NonnullOwnPtr<KBuffer>> SMBIOSExposedTable::try_to_generate_buffer() const
|
||||
{
|
||||
auto dmi_blob = Memory::map_typed<u8>((m_smbios_structure_table), m_smbios_structure_table_length);
|
||||
return KBuffer::try_create_with_bytes(Span<u8> { dmi_blob.ptr(), m_smbios_structure_table_length });
|
||||
|
|
|
@ -63,7 +63,7 @@ public:
|
|||
virtual KResultOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer&, OpenFileDescription*) const override;
|
||||
|
||||
protected:
|
||||
virtual OwnPtr<KBuffer> try_to_generate_buffer() const = 0;
|
||||
virtual KResultOr<NonnullOwnPtr<KBuffer>> try_to_generate_buffer() const = 0;
|
||||
explicit BIOSSysFSComponent(String name);
|
||||
};
|
||||
|
||||
|
@ -73,7 +73,7 @@ public:
|
|||
|
||||
private:
|
||||
DMIEntryPointExposedBlob(PhysicalAddress dmi_entry_point, size_t blob_size);
|
||||
virtual OwnPtr<KBuffer> try_to_generate_buffer() const override;
|
||||
virtual KResultOr<NonnullOwnPtr<KBuffer>> try_to_generate_buffer() const override;
|
||||
PhysicalAddress m_dmi_entry_point;
|
||||
size_t m_dmi_entry_point_length;
|
||||
};
|
||||
|
@ -84,7 +84,7 @@ public:
|
|||
|
||||
private:
|
||||
SMBIOSExposedTable(PhysicalAddress dmi_entry_point, size_t blob_size);
|
||||
virtual OwnPtr<KBuffer> try_to_generate_buffer() const override;
|
||||
virtual KResultOr<NonnullOwnPtr<KBuffer>> try_to_generate_buffer() const override;
|
||||
|
||||
PhysicalAddress m_smbios_structure_table;
|
||||
size_t m_smbios_structure_table_length;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue