1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:48:10 +00:00

Kernel: Make kernel region allocators return KResultOr<NOP<Region>>

This expands the reach of error propagation greatly throughout the
kernel. Sadly, it also exposes the fact that we're allocating (and
doing other fallible things) in constructors all over the place.

This patch doesn't attempt to address that of course. That's work for
our future selves.
This commit is contained in:
Andreas Kling 2021-09-06 01:36:14 +02:00
parent cb71a73708
commit 75564b4a5f
40 changed files with 173 additions and 193 deletions

View file

@ -49,11 +49,12 @@ RamdiskController::RamdiskController()
for (auto& used_memory_range : MM.used_memory_ranges()) {
if (used_memory_range.type == Memory::UsedMemoryRangeType::BootModule) {
size_t length = Memory::page_round_up(used_memory_range.end.get()) - used_memory_range.start.get();
auto region = MM.allocate_kernel_region(used_memory_range.start, length, "Ramdisk", Memory::Region::Access::ReadWrite);
if (!region)
auto region_or_error = MM.allocate_kernel_region(used_memory_range.start, length, "Ramdisk", Memory::Region::Access::ReadWrite);
if (region_or_error.is_error()) {
dmesgln("RamdiskController: Failed to allocate kernel region of size {}", length);
else
m_devices.append(RamdiskDevice::create(*this, region.release_nonnull(), 6, count));
} else {
m_devices.append(RamdiskDevice::create(*this, region_or_error.release_value(), 6, count));
}
count++;
}
}