diff options
author | Idan Horowitz <idan.horowitz@gmail.com> | 2022-01-13 18:20:22 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-01-13 22:40:25 +0100 |
commit | fb3e46e930aaf03fa1caec0cdf18ba48b12e1b0e (patch) | |
tree | 5bb7c83a09bedcdb2d5431837bcedb61799d7de8 /Kernel/Memory | |
parent | e2e5d4da164aad9b4a77ce5f2c7bfad3dafb9a86 (diff) | |
download | serenity-fb3e46e930aaf03fa1caec0cdf18ba48b12e1b0e.zip |
Kernel: Make map_typed() & map_typed_writable() fallible using ErrorOr
This mostly just moved the problem, as a lot of the callers are not
capable of propagating the errors themselves, but it's a step in the
right direction.
Diffstat (limited to 'Kernel/Memory')
-rw-r--r-- | Kernel/Memory/TypedMapping.h | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/Kernel/Memory/TypedMapping.h b/Kernel/Memory/TypedMapping.h index 133dd058fe..10dbd9ecf2 100644 --- a/Kernel/Memory/TypedMapping.h +++ b/Kernel/Memory/TypedMapping.h @@ -24,26 +24,23 @@ struct TypedMapping { }; template<typename T> -static TypedMapping<T> map_typed(PhysicalAddress paddr, size_t length, Region::Access access = Region::Access::Read) +static ErrorOr<TypedMapping<T>> map_typed(PhysicalAddress paddr, size_t length, Region::Access access = Region::Access::Read) { TypedMapping<T> table; - size_t mapping_length = page_round_up(paddr.offset_in_page() + length).release_value_but_fixme_should_propagate_errors(); - auto region_or_error = MM.allocate_kernel_region(paddr.page_base(), mapping_length, {}, access); - if (region_or_error.is_error()) - TODO(); - table.region = region_or_error.release_value(); + auto mapping_length = TRY(page_round_up(paddr.offset_in_page() + length)); + table.region = TRY(MM.allocate_kernel_region(paddr.page_base(), mapping_length, {}, access)); table.offset = paddr.offset_in_page(); return table; } template<typename T> -static TypedMapping<T> map_typed(PhysicalAddress paddr) +static ErrorOr<TypedMapping<T>> map_typed(PhysicalAddress paddr) { return map_typed<T>(paddr, sizeof(T)); } template<typename T> -static TypedMapping<T> map_typed_writable(PhysicalAddress paddr) +static ErrorOr<TypedMapping<T>> map_typed_writable(PhysicalAddress paddr) { return map_typed<T>(paddr, sizeof(T), Region::Access::Read | Region::Access::Write); } |