mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-29 06:02:07 +03:00
Kernel: Resolve clang-tidy readability-make-member-function-const
... In files included from Kernel/Thread.cpp or Kernel/Process.cpp Some places the warning is suppressed, because we do not want a const object do have non-const access to the returned sub-object.
This commit is contained in:
parent
a92132e44a
commit
65edc62c02
Notes:
sideshowbarker
2024-07-18 01:07:20 +09:00
Author: https://github.com/ADKaster Commit: https://github.com/SerenityOS/serenity/commit/65edc62c025 Pull-request: https://github.com/SerenityOS/serenity/pull/10737 Reviewed-by: https://github.com/BenWiederhake Reviewed-by: https://github.com/PeterBindels-TomTom Reviewed-by: https://github.com/awesomekling Reviewed-by: https://github.com/dascandy Reviewed-by: https://github.com/trflynn89
@ -160,7 +160,7 @@ struct [[gnu::packed]] IDTEntry
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
FlatPtr off()
|
FlatPtr off() const
|
||||||
{
|
{
|
||||||
#if ARCH(I386)
|
#if ARCH(I386)
|
||||||
return (u32)offset_2 << 16 & (u32)offset_1;
|
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;
|
return (u64)offset_3 << 32 & (u64)offset_2 << 16 & (u64)offset_1;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
IDTEntryType type()
|
IDTEntryType type() const
|
||||||
{
|
{
|
||||||
return IDTEntryType(type_attr.gate_type);
|
return IDTEntryType(type_attr.gate_type);
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
ALWAYS_INLINE void out(T value)
|
ALWAYS_INLINE void out(T value) const
|
||||||
{
|
{
|
||||||
static_assert(sizeof(T) <= 4);
|
static_assert(sizeof(T) <= 4);
|
||||||
if constexpr (sizeof(T) == 4) {
|
if constexpr (sizeof(T) == 4) {
|
||||||
@ -111,7 +111,7 @@ public:
|
|||||||
VERIFY_NOT_REACHED();
|
VERIFY_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void out(u32 value, u8 bit_width)
|
inline void out(u32 value, u8 bit_width) const
|
||||||
{
|
{
|
||||||
if (bit_width == 32) {
|
if (bit_width == 32) {
|
||||||
IO::out32(get(), value);
|
IO::out32(get(), value);
|
||||||
|
@ -77,7 +77,7 @@ private:
|
|||||||
|
|
||||||
class PageTableEntry {
|
class PageTableEntry {
|
||||||
public:
|
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)
|
void set_physical_page_base(PhysicalPtr value)
|
||||||
{
|
{
|
||||||
m_raw &= 0x8000000000000fffULL;
|
m_raw &= 0x8000000000000fffULL;
|
||||||
|
@ -120,12 +120,12 @@ public:
|
|||||||
void detect_hypervisor();
|
void detect_hypervisor();
|
||||||
void detect_hypervisor_hyperv(CPUID const& hypervisor_leaf_range);
|
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);
|
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);
|
s_idle_cpu_mask.fetch_and(~(1u << m_cpu), AK::MemoryOrder::memory_order_relaxed);
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ private:
|
|||||||
bool m_readonly { false };
|
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);
|
return FileSystem::from_fsid(m_fsid);
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ class SysFSDeviceComponent final
|
|||||||
public:
|
public:
|
||||||
static NonnullRefPtr<SysFSDeviceComponent> must_create(Device const&);
|
static NonnullRefPtr<SysFSDeviceComponent> must_create(Device const&);
|
||||||
|
|
||||||
bool is_block_device() { return m_block_device; }
|
bool is_block_device() const { return m_block_device; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit SysFSDeviceComponent(Device const&);
|
explicit SysFSDeviceComponent(Device const&);
|
||||||
|
@ -38,8 +38,9 @@ public:
|
|||||||
|
|
||||||
[[nodiscard]] bool is_null() const { return m_address == 0; }
|
[[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<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); }
|
[[nodiscard]] const u8* as_ptr() const { return reinterpret_cast<u8 const*>(m_address); }
|
||||||
|
|
||||||
[[nodiscard]] PhysicalAddress page_base() const { return PhysicalAddress(physical_page_base(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(); }
|
[[nodiscard]] PhysicalPtr offset_in_page() const { return PhysicalAddress(m_address & 0xfff).get(); }
|
||||||
|
@ -502,7 +502,7 @@ Time kgettimeofday()
|
|||||||
return TimeManagement::now();
|
return TimeManagement::now();
|
||||||
}
|
}
|
||||||
|
|
||||||
siginfo_t Process::wait_info()
|
siginfo_t Process::wait_info() const
|
||||||
{
|
{
|
||||||
siginfo_t siginfo {};
|
siginfo_t siginfo {};
|
||||||
siginfo.si_signo = SIGCHLD;
|
siginfo.si_signo = SIGCHLD;
|
||||||
@ -889,7 +889,7 @@ static constexpr StringView to_string(Pledge promise)
|
|||||||
VERIFY_NOT_REACHED();
|
VERIFY_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Process::require_no_promises()
|
void Process::require_no_promises() const
|
||||||
{
|
{
|
||||||
if (!has_promises())
|
if (!has_promises())
|
||||||
return;
|
return;
|
||||||
|
@ -421,7 +421,7 @@ public:
|
|||||||
static void initialize();
|
static void initialize();
|
||||||
|
|
||||||
[[noreturn]] void crash(int signal, FlatPtr ip, bool out_of_memory = false);
|
[[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; }
|
const TTY* tty() const { return m_tty; }
|
||||||
void set_tty(TTY*);
|
void set_tty(TTY*);
|
||||||
@ -509,7 +509,7 @@ public:
|
|||||||
VirtualAddress signal_trampoline() const { return m_protected_values.signal_trampoline; }
|
VirtualAddress signal_trampoline() const { return m_protected_values.signal_trampoline; }
|
||||||
|
|
||||||
void require_promise(Pledge);
|
void require_promise(Pledge);
|
||||||
void require_no_promises();
|
void require_no_promises() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class MemoryManager;
|
friend class MemoryManager;
|
||||||
|
@ -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<SleepBlocker> which is not const
|
||||||
auto Thread::sleep(clockid_t clock_id, const Time& duration, Time* remaining_time) -> BlockResult
|
auto Thread::sleep(clockid_t clock_id, const Time& duration, Time* remaining_time) -> BlockResult
|
||||||
{
|
{
|
||||||
VERIFY(state() == Thread::Running);
|
VERIFY(state() == Thread::Running);
|
||||||
return Thread::current()->block<Thread::SleepBlocker>({}, Thread::BlockTimeout(false, &duration, nullptr, clock_id), remaining_time);
|
return Thread::current()->block<Thread::SleepBlocker>({}, Thread::BlockTimeout(false, &duration, nullptr, clock_id), remaining_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOLINTNEXTLINE(readability-make-member-function-const) False positive; We call block<SleepBlocker> which is not const
|
||||||
auto Thread::sleep_until(clockid_t clock_id, const Time& deadline) -> BlockResult
|
auto Thread::sleep_until(clockid_t clock_id, const Time& deadline) -> BlockResult
|
||||||
{
|
{
|
||||||
VERIFY(state() == Thread::Running);
|
VERIFY(state() == Thread::Running);
|
||||||
|
@ -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; }
|
||||||
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<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); }
|
[[nodiscard]] const u8* as_ptr() const { return reinterpret_cast<const u8*>(m_address); }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user