1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 21:48:13 +00:00

Kernel: Clean up the page fault handling code a bit

Not using "else" after "return" unnests the code and makes it easier to
follow. Also use an enum for the two different page fault types.
This commit is contained in:
Andreas Kling 2019-08-06 09:33:35 +02:00
parent f58b0c245d
commit af4cf01560
2 changed files with 22 additions and 19 deletions

View file

@ -303,9 +303,16 @@ public:
{
}
enum class Type {
PageNotPresent,
ProtectionViolation,
};
VirtualAddress vaddr() const { return m_vaddr; }
u16 code() const { return m_code; }
Type type() const { return (Type)(m_code & 1); }
bool is_not_present() const { return (m_code & 1) == PageFaultFlags::NotPresent; }
bool is_protection_violation() const { return (m_code & 1) == PageFaultFlags::ProtectionViolation; }
bool is_read() const { return (m_code & 2) == PageFaultFlags::Read; }