mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:57:45 +00:00
Kernel: Make Memory::Region::map() return KResult
..and use TRY() at the call sites to propagate errors. :^)
This commit is contained in:
parent
7981422500
commit
e3a716ceff
6 changed files with 17 additions and 25 deletions
|
@ -95,8 +95,7 @@ KResultOr<FlatPtr> Process::sys$fork(RegisterState& regs)
|
|||
dbgln_if(FORK_DEBUG, "fork: cloning Region({}) '{}' @ {}", region, region->name(), region->vaddr());
|
||||
auto region_clone = TRY(region->try_clone());
|
||||
auto* child_region = TRY(child->address_space().add_region(move(region_clone)));
|
||||
if (!child_region->map(child->address_space().page_directory(), Memory::ShouldFlushTLB::No))
|
||||
return ENOMEM;
|
||||
TRY(child_region->map(child->address_space().page_directory(), Memory::ShouldFlushTLB::No));
|
||||
|
||||
if (region == m_master_tls_region.unsafe_ptr())
|
||||
child->m_master_tls_region = child_region;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue