1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 01:17:35 +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

@ -37,18 +37,18 @@ public:
{
}
PhysicalAddress offset(FlatPtr o) const { return PhysicalAddress(m_address + o); }
FlatPtr get() const { return m_address; }
[[nodiscard]] PhysicalAddress offset(FlatPtr o) const { return PhysicalAddress(m_address + o); }
[[nodiscard]] FlatPtr get() const { return m_address; }
void set(FlatPtr address) { m_address = address; }
void mask(FlatPtr m) { m_address &= m; }
bool is_null() const { return m_address == 0; }
[[nodiscard]] bool is_null() const { return m_address == 0; }
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); }
PhysicalAddress page_base() const { return PhysicalAddress(m_address & 0xfffff000); }
FlatPtr offset_in_page() const { return PhysicalAddress(m_address & 0xfff).get(); }
[[nodiscard]] PhysicalAddress page_base() const { return PhysicalAddress(m_address & 0xfffff000); }
[[nodiscard]] FlatPtr offset_in_page() const { return PhysicalAddress(m_address & 0xfff).get(); }
bool operator==(const PhysicalAddress& other) const { return m_address == other.m_address; }
bool operator!=(const PhysicalAddress& other) const { return m_address != other.m_address; }