summaryrefslogtreecommitdiff
path: root/Kernel/Firmware/ACPI
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-11-08 00:51:39 +0100
committerAndreas Kling <kling@serenityos.org>2021-11-08 01:10:53 +0100
commit79fa9765ca89869d19364143989436d117974c21 (patch)
tree3af62f70127d9217d841047f6b7461351800d1ae /Kernel/Firmware/ACPI
parent7ee10c69264cb278845a1e1b06d5acf2e5e7ddf0 (diff)
downloadserenity-79fa9765ca89869d19364143989436d117974c21.zip
Kernel: Replace KResult and KResultOr<T> with Error and ErrorOr<T>
We now use AK::Error and AK::ErrorOr<T> in both kernel and userspace! This was a slightly tedious refactoring that took a long time, so it's not unlikely that some bugs crept in. Nevertheless, it does pass basic functionality testing, and it's just real nice to finally see the same pattern in all contexts. :^)
Diffstat (limited to 'Kernel/Firmware/ACPI')
-rw-r--r--Kernel/Firmware/ACPI/Parser.cpp8
-rw-r--r--Kernel/Firmware/ACPI/Parser.h6
2 files changed, 7 insertions, 7 deletions
diff --git a/Kernel/Firmware/ACPI/Parser.cpp b/Kernel/Firmware/ACPI/Parser.cpp
index 7d6a632b40..ef19a8661c 100644
--- a/Kernel/Firmware/ACPI/Parser.cpp
+++ b/Kernel/Firmware/ACPI/Parser.cpp
@@ -39,19 +39,19 @@ UNMAP_AFTER_INIT NonnullRefPtr<ACPISysFSComponent> ACPISysFSComponent::create(St
return adopt_ref(*new (nothrow) ACPISysFSComponent(name, paddr, table_size));
}
-KResultOr<size_t> ACPISysFSComponent::read_bytes(off_t offset, size_t count, UserOrKernelBuffer& buffer, OpenFileDescription*) const
+ErrorOr<size_t> ACPISysFSComponent::read_bytes(off_t offset, size_t count, UserOrKernelBuffer& buffer, OpenFileDescription*) const
{
auto blob = TRY(try_to_generate_buffer());
if ((size_t)offset >= blob->size())
- return KSuccess;
+ return 0;
ssize_t nread = min(static_cast<off_t>(blob->size() - offset), static_cast<off_t>(count));
TRY(buffer.write(blob->data() + offset, nread));
return nread;
}
-KResultOr<NonnullOwnPtr<KBuffer>> ACPISysFSComponent::try_to_generate_buffer() const
+ErrorOr<NonnullOwnPtr<KBuffer>> ACPISysFSComponent::try_to_generate_buffer() const
{
auto acpi_blob = Memory::map_typed<u8>((m_paddr), m_length);
return KBuffer::try_create_with_bytes(Span<u8> { acpi_blob.ptr(), m_length });
@@ -64,7 +64,7 @@ UNMAP_AFTER_INIT ACPISysFSComponent::ACPISysFSComponent(String name, PhysicalAdd
{
}
-UNMAP_AFTER_INIT KResultOr<NonnullRefPtr<ACPISysFSDirectory>> ACPISysFSDirectory::try_create(FirmwareSysFSDirectory& firmware_directory)
+UNMAP_AFTER_INIT ErrorOr<NonnullRefPtr<ACPISysFSDirectory>> ACPISysFSDirectory::try_create(FirmwareSysFSDirectory& firmware_directory)
{
auto acpi_directory = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) ACPISysFSDirectory(firmware_directory)));
return acpi_directory;
diff --git a/Kernel/Firmware/ACPI/Parser.h b/Kernel/Firmware/ACPI/Parser.h
index 9c11b2100b..903d6d5b49 100644
--- a/Kernel/Firmware/ACPI/Parser.h
+++ b/Kernel/Firmware/ACPI/Parser.h
@@ -22,7 +22,7 @@ namespace Kernel::ACPI {
class ACPISysFSDirectory : public SysFSDirectory {
public:
- static KResultOr<NonnullRefPtr<ACPISysFSDirectory>> try_create(FirmwareSysFSDirectory& firmware_directory);
+ static ErrorOr<NonnullRefPtr<ACPISysFSDirectory>> try_create(FirmwareSysFSDirectory& firmware_directory);
private:
explicit ACPISysFSDirectory(FirmwareSysFSDirectory& firmware_directory);
@@ -32,10 +32,10 @@ class ACPISysFSComponent : public SysFSComponent {
public:
static NonnullRefPtr<ACPISysFSComponent> create(String name, PhysicalAddress, size_t table_size);
- virtual KResultOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer&, OpenFileDescription*) const override;
+ virtual ErrorOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer&, OpenFileDescription*) const override;
protected:
- KResultOr<NonnullOwnPtr<KBuffer>> try_to_generate_buffer() const;
+ ErrorOr<NonnullOwnPtr<KBuffer>> try_to_generate_buffer() const;
ACPISysFSComponent(String name, PhysicalAddress, size_t table_size);
PhysicalAddress m_paddr;