diff --git a/Kernel/Arch/x86/DescriptorTable.h b/Kernel/Arch/x86/DescriptorTable.h index 7068ed6f3e..bffa5f826e 100644 --- a/Kernel/Arch/x86/DescriptorTable.h +++ b/Kernel/Arch/x86/DescriptorTable.h @@ -160,7 +160,7 @@ struct [[gnu::packed]] IDTEntry { } - FlatPtr off() + FlatPtr off() const { #if ARCH(I386) return (u32)offset_2 << 16 & (u32)offset_1; @@ -168,7 +168,7 @@ struct [[gnu::packed]] IDTEntry return (u64)offset_3 << 32 & (u64)offset_2 << 16 & (u64)offset_1; #endif } - IDTEntryType type() + IDTEntryType type() const { return IDTEntryType(type_attr.gate_type); } diff --git a/Kernel/Arch/x86/IO.h b/Kernel/Arch/x86/IO.h index ca9955e9fb..b42bdce0f7 100644 --- a/Kernel/Arch/x86/IO.h +++ b/Kernel/Arch/x86/IO.h @@ -93,7 +93,7 @@ public: } template - ALWAYS_INLINE void out(T value) + ALWAYS_INLINE void out(T value) const { static_assert(sizeof(T) <= 4); if constexpr (sizeof(T) == 4) { @@ -111,7 +111,7 @@ public: VERIFY_NOT_REACHED(); } - inline void out(u32 value, u8 bit_width) + inline void out(u32 value, u8 bit_width) const { if (bit_width == 32) { IO::out32(get(), value); diff --git a/Kernel/Arch/x86/PageDirectory.h b/Kernel/Arch/x86/PageDirectory.h index 09d5a80ebf..d36373ea8f 100644 --- a/Kernel/Arch/x86/PageDirectory.h +++ b/Kernel/Arch/x86/PageDirectory.h @@ -77,7 +77,7 @@ private: class PageTableEntry { public: - PhysicalPtr physical_page_base() { return PhysicalAddress::physical_page_base(m_raw); } + PhysicalPtr physical_page_base() const { return PhysicalAddress::physical_page_base(m_raw); } void set_physical_page_base(PhysicalPtr value) { m_raw &= 0x8000000000000fffULL; diff --git a/Kernel/Arch/x86/Processor.h b/Kernel/Arch/x86/Processor.h index 9ba01358dd..a099b46f80 100644 --- a/Kernel/Arch/x86/Processor.h +++ b/Kernel/Arch/x86/Processor.h @@ -120,12 +120,12 @@ public: void detect_hypervisor(); void detect_hypervisor_hyperv(CPUID const& hypervisor_leaf_range); - void idle_begin() + void idle_begin() const { s_idle_cpu_mask.fetch_or(1u << m_cpu, AK::MemoryOrder::memory_order_relaxed); } - void idle_end() + void idle_end() const { s_idle_cpu_mask.fetch_and(~(1u << m_cpu), AK::MemoryOrder::memory_order_relaxed); } diff --git a/Kernel/FileSystem/FileSystem.h b/Kernel/FileSystem/FileSystem.h index 6cc2b50330..5e5fe1dde2 100644 --- a/Kernel/FileSystem/FileSystem.h +++ b/Kernel/FileSystem/FileSystem.h @@ -78,7 +78,7 @@ private: bool m_readonly { false }; }; -inline FileSystem* InodeIdentifier::fs() +inline FileSystem* InodeIdentifier::fs() // NOLINT(readability-make-member-function-const) const InodeIdentifiers should not be able to modify the FileSystem { return FileSystem::from_fsid(m_fsid); } diff --git a/Kernel/FileSystem/SysFS.h b/Kernel/FileSystem/SysFS.h index 818c035267..86772c2633 100644 --- a/Kernel/FileSystem/SysFS.h +++ b/Kernel/FileSystem/SysFS.h @@ -34,7 +34,7 @@ class SysFSDeviceComponent final public: static NonnullRefPtr must_create(Device const&); - bool is_block_device() { return m_block_device; } + bool is_block_device() const { return m_block_device; } private: explicit SysFSDeviceComponent(Device const&); diff --git a/Kernel/PhysicalAddress.h b/Kernel/PhysicalAddress.h index f6d9367e00..195e4c2cc0 100644 --- a/Kernel/PhysicalAddress.h +++ b/Kernel/PhysicalAddress.h @@ -38,8 +38,9 @@ public: [[nodiscard]] bool is_null() const { return m_address == 0; } + // NOLINTNEXTLINE(readability-make-member-function-const) const PhysicalAddress shouldn't be allowed to modify the underlying memory [[nodiscard]] u8* as_ptr() { return reinterpret_cast(m_address); } - [[nodiscard]] const u8* as_ptr() const { return reinterpret_cast(m_address); } + [[nodiscard]] const u8* as_ptr() const { return reinterpret_cast(m_address); } [[nodiscard]] PhysicalAddress page_base() const { return PhysicalAddress(physical_page_base(m_address)); } [[nodiscard]] PhysicalPtr offset_in_page() const { return PhysicalAddress(m_address & 0xfff).get(); } diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index 8fac55ad5c..cec01c5278 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -502,7 +502,7 @@ Time kgettimeofday() return TimeManagement::now(); } -siginfo_t Process::wait_info() +siginfo_t Process::wait_info() const { siginfo_t siginfo {}; siginfo.si_signo = SIGCHLD; @@ -889,7 +889,7 @@ static constexpr StringView to_string(Pledge promise) VERIFY_NOT_REACHED(); } -void Process::require_no_promises() +void Process::require_no_promises() const { if (!has_promises()) return; diff --git a/Kernel/Process.h b/Kernel/Process.h index 817c20cf94..996dd71269 100644 --- a/Kernel/Process.h +++ b/Kernel/Process.h @@ -421,7 +421,7 @@ public: static void initialize(); [[noreturn]] void crash(int signal, FlatPtr ip, bool out_of_memory = false); - [[nodiscard]] siginfo_t wait_info(); + [[nodiscard]] siginfo_t wait_info() const; const TTY* tty() const { return m_tty; } void set_tty(TTY*); @@ -509,7 +509,7 @@ public: VirtualAddress signal_trampoline() const { return m_protected_values.signal_trampoline; } void require_promise(Pledge); - void require_no_promises(); + void require_no_promises() const; private: friend class MemoryManager; diff --git a/Kernel/Thread.cpp b/Kernel/Thread.cpp index 197870866a..fba1876b24 100644 --- a/Kernel/Thread.cpp +++ b/Kernel/Thread.cpp @@ -445,12 +445,14 @@ void Thread::relock_process(LockMode previous_locked, u32 lock_count_to_restore) } } +// NOLINTNEXTLINE(readability-make-member-function-const) False positive; We call block which is not const auto Thread::sleep(clockid_t clock_id, const Time& duration, Time* remaining_time) -> BlockResult { VERIFY(state() == Thread::Running); return Thread::current()->block({}, Thread::BlockTimeout(false, &duration, nullptr, clock_id), remaining_time); } +// NOLINTNEXTLINE(readability-make-member-function-const) False positive; We call block which is not const auto Thread::sleep_until(clockid_t clock_id, const Time& deadline) -> BlockResult { VERIFY(state() == Thread::Running); diff --git a/Kernel/VirtualAddress.h b/Kernel/VirtualAddress.h index 7875e3f1c4..6f2120389f 100644 --- a/Kernel/VirtualAddress.h +++ b/Kernel/VirtualAddress.h @@ -37,6 +37,7 @@ 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; } + // NOLINTNEXTLINE(readability-make-member-function-const) const VirtualAddress shouldn't be allowed to modify the underlying memory [[nodiscard]] u8* as_ptr() { return reinterpret_cast(m_address); } [[nodiscard]] const u8* as_ptr() const { return reinterpret_cast(m_address); }