1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:47:44 +00:00

Kernel: Fix some trivial clang-tidy warnings in Thread.{cpp,h}

This commit is contained in:
Andreas Kling 2021-08-22 10:44:43 +02:00
parent cd52eb3103
commit 3e3f760808
2 changed files with 11 additions and 22 deletions

View file

@ -61,7 +61,7 @@ Thread::Thread(NonnullRefPtr<Process> process, NonnullOwnPtr<Memory::Region> ker
: m_process(move(process)) : m_process(move(process))
, m_kernel_stack_region(move(kernel_stack_region)) , m_kernel_stack_region(move(kernel_stack_region))
, m_name(move(name)) , m_name(move(name))
, m_block_timer(block_timer) , m_block_timer(move(block_timer))
{ {
bool is_first_thread = m_process->add_thread(*this); bool is_first_thread = m_process->add_thread(*this);
if (is_first_thread) { if (is_first_thread) {
@ -142,7 +142,7 @@ Thread::~Thread()
{ {
{ {
// We need to explicitly remove ourselves from the thread list // We need to explicitly remove ourselves from the thread list
// here. We may get pre-empted in the middle of destructing this // here. We may get preempted in the middle of destructing this
// thread, which causes problems if the thread list is iterated. // thread, which causes problems if the thread list is iterated.
// Specifically, if this is the last thread of a process, checking // Specifically, if this is the last thread of a process, checking
// block conditions would access m_process, which would be in // block conditions would access m_process, which would be in
@ -252,7 +252,7 @@ u32 Thread::unblock_from_lock(Kernel::Mutex& lock)
set_state(Thread::Runnable); set_state(Thread::Runnable);
}; };
if (Processor::current().in_irq()) { if (Processor::current().in_irq()) {
Processor::current().deferred_call_queue([do_unblock = move(do_unblock), self = make_weak_ptr()]() { Processor::deferred_call_queue([do_unblock = move(do_unblock), self = make_weak_ptr()]() {
if (auto this_thread = self.strong_ref()) if (auto this_thread = self.strong_ref())
do_unblock(); do_unblock();
}); });
@ -273,7 +273,7 @@ void Thread::unblock_from_blocker(Blocker& blocker)
unblock(); unblock();
}; };
if (Processor::current().in_irq()) { if (Processor::current().in_irq()) {
Processor::current().deferred_call_queue([do_unblock = move(do_unblock), self = make_weak_ptr()]() { Processor::deferred_call_queue([do_unblock = move(do_unblock), self = make_weak_ptr()]() {
if (auto this_thread = self.strong_ref()) if (auto this_thread = self.strong_ref())
do_unblock(); do_unblock();
}); });
@ -599,12 +599,8 @@ void Thread::check_dispatch_pending_signal()
} }
} }
switch (result) { if (result == DispatchSignalResult::Yield) {
case DispatchSignalResult::Yield:
yield_without_releasing_big_lock(); yield_without_releasing_big_lock();
break;
default:
break;
} }
} }
@ -787,8 +783,9 @@ static DefaultSignalAction default_signal_action(u8 signal)
case SIGTTIN: case SIGTTIN:
case SIGTTOU: case SIGTTOU:
return DefaultSignalAction::Stop; return DefaultSignalAction::Stop;
default:
VERIFY_NOT_REACHED();
} }
VERIFY_NOT_REACHED();
} }
bool Thread::should_ignore_signal(u8 signal) const bool Thread::should_ignore_signal(u8 signal) const
@ -1021,7 +1018,7 @@ RegisterState& Thread::get_register_dump_from_stack()
auto* trap = current_trap(); auto* trap = current_trap();
// We should *always* have a trap. If we don't we're probably a kernel // We should *always* have a trap. If we don't we're probably a kernel
// thread that hasn't been pre-empted. If we want to support this, we // thread that hasn't been preempted. If we want to support this, we
// need to capture the registers probably into m_regs and return it // need to capture the registers probably into m_regs and return it
VERIFY(trap); VERIFY(trap);

View file

@ -151,7 +151,6 @@ class Thread
friend class Mutex; friend class Mutex;
friend class Process; friend class Process;
friend class ProtectedProcessBase;
friend class Scheduler; friend class Scheduler;
friend struct ThreadReadyQueue; friend struct ThreadReadyQueue;
@ -161,8 +160,6 @@ public:
return Processor::current_thread(); return Processor::current_thread();
} }
static void initialize();
static KResultOr<NonnullRefPtr<Thread>> try_create(NonnullRefPtr<Process>); static KResultOr<NonnullRefPtr<Thread>> try_create(NonnullRefPtr<Process>);
~Thread(); ~Thread();
@ -253,11 +250,6 @@ public:
} }
} }
[[nodiscard]] bool timed_out() const
{
return m_type == InterruptedByTimeout;
}
private: private:
Type m_type; Type m_type;
}; };
@ -696,7 +688,7 @@ public:
}; };
typedef Vector<FDInfo, FD_SETSIZE> FDVector; typedef Vector<FDInfo, FD_SETSIZE> FDVector;
SelectBlocker(FDVector& fds); explicit SelectBlocker(FDVector& fds);
virtual ~SelectBlocker(); virtual ~SelectBlocker();
virtual bool unblock(bool, void*) override; virtual bool unblock(bool, void*) override;
@ -750,7 +742,7 @@ public:
friend class WaitBlocker; friend class WaitBlocker;
public: public:
WaitBlockCondition(Process& process) explicit WaitBlockCondition(Process& process)
: m_process(process) : m_process(process)
{ {
} }
@ -1296,7 +1288,7 @@ private:
mutable RecursiveSpinlock m_block_lock; mutable RecursiveSpinlock m_block_lock;
NonnullRefPtr<Process> m_process; NonnullRefPtr<Process> m_process;
ThreadID m_tid { -1 }; ThreadID m_tid { -1 };
ThreadRegisters m_regs; ThreadRegisters m_regs {};
DebugRegisterState m_debug_register_state {}; DebugRegisterState m_debug_register_state {};
TrapFrame* m_current_trap { nullptr }; TrapFrame* m_current_trap { nullptr };
u32 m_saved_critical { 1 }; u32 m_saved_critical { 1 };