mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 08:57:47 +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
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue