summaryrefslogtreecommitdiff
path: root/Kernel/Memory/Region.h
diff options
context:
space:
mode:
authorAndrew Kaster <akaster@serenityos.org>2021-11-06 15:06:08 -0600
committerAndreas Kling <kling@serenityos.org>2021-11-14 22:52:35 +0100
commita92132e44a638a20537f66c860f6a4ebdc41062a (patch)
tree22895c871010a0f678e7677fbd916d63ccf969bd /Kernel/Memory/Region.h
parent6f580f2047f6fcab081d5f92ea751d8f2fb55e80 (diff)
downloadserenity-a92132e44a638a20537f66c860f6a4ebdc41062a.zip
Kernel: Resolve clang-tidy readability-implicit-bool-conversion warnings
... In files included from Kernel/Process.cpp and Kernel/Thread.cpp
Diffstat (limited to 'Kernel/Memory/Region.h')
-rw-r--r--Kernel/Memory/Region.h28
1 files changed, 14 insertions, 14 deletions
diff --git a/Kernel/Memory/Region.h b/Kernel/Memory/Region.h
index 80bb799fcf..5c31693619 100644
--- a/Kernel/Memory/Region.h
+++ b/Kernel/Memory/Region.h
@@ -57,13 +57,13 @@ public:
[[nodiscard]] VirtualRange const& range() const { return m_range; }
[[nodiscard]] VirtualAddress vaddr() const { return m_range.base(); }
[[nodiscard]] size_t size() const { return m_range.size(); }
- [[nodiscard]] bool is_readable() const { return m_access & Access::Read; }
- [[nodiscard]] bool is_writable() const { return m_access & Access::Write; }
- [[nodiscard]] bool is_executable() const { return m_access & Access::Execute; }
+ [[nodiscard]] bool is_readable() const { return (m_access & Access::Read) == Access::Read; }
+ [[nodiscard]] bool is_writable() const { return (m_access & Access::Write) == Access::Write; }
+ [[nodiscard]] bool is_executable() const { return (m_access & Access::Execute) == Access::Execute; }
- [[nodiscard]] bool has_been_readable() const { return m_access & Access::HasBeenReadable; }
- [[nodiscard]] bool has_been_writable() const { return m_access & Access::HasBeenWritable; }
- [[nodiscard]] bool has_been_executable() const { return m_access & Access::HasBeenExecutable; }
+ [[nodiscard]] bool has_been_readable() const { return (m_access & Access::HasBeenReadable) == Access::HasBeenReadable; }
+ [[nodiscard]] bool has_been_writable() const { return (m_access & Access::HasBeenWritable) == Access::HasBeenWritable; }
+ [[nodiscard]] bool has_been_executable() const { return (m_access & Access::HasBeenExecutable) == Access::HasBeenExecutable; }
[[nodiscard]] bool is_cacheable() const { return m_cacheable; }
[[nodiscard]] StringView name() const { return m_name ? m_name->view() : StringView {}; }
@@ -223,26 +223,26 @@ public:
AK_ENUM_BITWISE_OPERATORS(Region::Access)
-inline Region::Access prot_to_region_access_flags(int prot)
+inline constexpr Region::Access prot_to_region_access_flags(int prot)
{
Region::Access access = Region::Access::None;
- if (prot & PROT_READ)
+ if ((prot & PROT_READ) == PROT_READ)
access |= Region::Access::Read;
- if (prot & PROT_WRITE)
+ if ((prot & PROT_WRITE) == PROT_WRITE)
access |= Region::Access::Write;
- if (prot & PROT_EXEC)
+ if ((prot & PROT_EXEC) == PROT_EXEC)
access |= Region::Access::Execute;
return access;
}
-inline int region_access_flags_to_prot(Region::Access access)
+inline constexpr int region_access_flags_to_prot(Region::Access access)
{
int prot = 0;
- if (access & Region::Access::Read)
+ if ((access & Region::Access::Read) == Region::Access::Read)
prot |= PROT_READ;
- if (access & Region::Access::Write)
+ if ((access & Region::Access::Write) == Region::Access::Write)
prot |= PROT_WRITE;
- if (access & Region::Access::Execute)
+ if ((access & Region::Access::Execute) == Region::Access::Execute)
prot |= PROT_EXEC;
return prot;
}