1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:47:44 +00:00

Kernel: Make Memory::Region::map() return KResult

..and use TRY() at the call sites to propagate errors. :^)
This commit is contained in:
Andreas Kling 2021-09-06 12:52:23 +02:00
parent 7981422500
commit e3a716ceff
6 changed files with 17 additions and 25 deletions

View file

@ -338,11 +338,9 @@ KResultOr<FlatPtr> Process::sys$mprotect(Userspace<void*> addr, size_t size, int
// Map the new regions using our page directory (they were just allocated and don't have one).
for (auto* adjacent_region : adjacent_regions) {
if (!adjacent_region->map(address_space().page_directory()))
return ENOMEM;
TRY(adjacent_region->map(address_space().page_directory()));
}
if (!new_region->map(address_space().page_directory()))
return ENOMEM;
TRY(new_region->map(address_space().page_directory()));
return 0;
}
@ -401,11 +399,9 @@ KResultOr<FlatPtr> Process::sys$mprotect(Userspace<void*> addr, size_t size, int
// Map the new region using our page directory (they were just allocated and don't have one) if any.
if (adjacent_regions.size())
if (!adjacent_regions[0]->map(address_space().page_directory()))
return ENOMEM;
TRY(adjacent_regions[0]->map(address_space().page_directory()));
if (!new_region->map(address_space().page_directory()))
return ENOMEM;
TRY(new_region->map(address_space().page_directory()));
}
return 0;