summaryrefslogtreecommitdiff
path: root/Kernel/Process.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-01-27 21:01:45 +0100
committerAndreas Kling <kling@serenityos.org>2021-01-27 21:14:42 +0100
commite67402c7027f13fcc03d61f88725470e4c66e820 (patch)
tree673d40ced3c4dec8da64200ee21c4c8398d6fcb6 /Kernel/Process.cpp
parent67bc5e0bbdcf313b20b32069a5e9b9806f8bd790 (diff)
downloadserenity-e67402c7027f13fcc03d61f88725470e4c66e820.zip
Kernel: Remove Range "valid" state and use Optional<Range> instead
It's easier to understand VM ranges if they are always valid. We can simply use an empty Optional<Range> to encode absence when needed.
Diffstat (limited to 'Kernel/Process.cpp')
-rw-r--r--Kernel/Process.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp
index aa341b00bd..e4b01c735e 100644
--- a/Kernel/Process.cpp
+++ b/Kernel/Process.cpp
@@ -116,7 +116,7 @@ bool Process::in_group(gid_t gid) const
return m_gid == gid || m_extra_gids.contains_slow(gid);
}
-Range Process::allocate_range(VirtualAddress vaddr, size_t size, size_t alignment)
+Optional<Range> Process::allocate_range(VirtualAddress vaddr, size_t size, size_t alignment)
{
vaddr.mask(PAGE_MASK);
size = PAGE_ROUND_UP(size);
@@ -195,7 +195,7 @@ bool Process::deallocate_region(Region& region)
Region* Process::find_region_from_range(const Range& range)
{
ScopedSpinLock lock(m_lock);
- if (m_region_lookup_cache.range == range && m_region_lookup_cache.region)
+ if (m_region_lookup_cache.range.has_value() && m_region_lookup_cache.range.value() == range && m_region_lookup_cache.region)
return m_region_lookup_cache.region.unsafe_ptr();
size_t size = PAGE_ROUND_UP(range.size());