1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 05:27:46 +00:00

Kernel: Mark PhysicalAddress/VirtualAddress getters as [[nodiscard]]

There is no reason to call a getter without observing the result, doing
so indicates an error in the code. Mark these methods as [[nodiscard]]
to find these cases.
This commit is contained in:
Brian Gianforcaro 2021-02-14 15:18:35 -08:00 committed by Andreas Kling
parent d71e235894
commit 8752a27519
2 changed files with 14 additions and 14 deletions

View file

@ -42,11 +42,11 @@ public:
{
}
bool is_null() const { return m_address == 0; }
bool is_page_aligned() const { return (m_address & 0xfff) == 0; }
[[nodiscard]] bool is_null() const { return m_address == 0; }
[[nodiscard]] bool is_page_aligned() const { return (m_address & 0xfff) == 0; }
VirtualAddress offset(FlatPtr o) const { return VirtualAddress(m_address + o); }
FlatPtr get() const { return m_address; }
[[nodiscard]] VirtualAddress offset(FlatPtr o) const { return VirtualAddress(m_address + o); }
[[nodiscard]] FlatPtr get() const { return m_address; }
void set(FlatPtr address) { m_address = address; }
void mask(FlatPtr m) { m_address &= m; }
@ -57,10 +57,10 @@ public:
bool operator==(const VirtualAddress& other) const { return m_address == other.m_address; }
bool operator!=(const VirtualAddress& other) const { return m_address != other.m_address; }
u8* as_ptr() { return reinterpret_cast<u8*>(m_address); }
const u8* as_ptr() const { return reinterpret_cast<const u8*>(m_address); }
[[nodiscard]] u8* as_ptr() { return reinterpret_cast<u8*>(m_address); }
[[nodiscard]] const u8* as_ptr() const { return reinterpret_cast<const u8*>(m_address); }
VirtualAddress page_base() const { return VirtualAddress(m_address & 0xfffff000); }
[[nodiscard]] VirtualAddress page_base() const { return VirtualAddress(m_address & 0xfffff000); }
private:
FlatPtr m_address { 0 };