Kernel: Collapse blocking logic for exclusive Mutex' restore_lock()

Clang-tidy pointed out that the `need_to_block = true;` block was
duplicate, and if we collapse these if statements, we should do so
fully.
This commit is contained in:
Hendiadyoin1 2021-12-15 14:58:12 +01:00 committed by Brian Gianforcaro
parent 1ad4a190b5
commit e5cf395a54

View file

@ -329,12 +329,8 @@ void Mutex::restore_lock(Mode mode, u32 lock_count, [[maybe_unused]] LockLocatio
switch (mode) {
case Mode::Exclusive: {
auto previous_mode = m_mode;
bool need_to_block = false;
if (m_mode == Mode::Exclusive && m_holder != current_thread)
need_to_block = true;
else if (m_mode == Mode::Shared && (m_shared_holders.size() != 1 || !m_shared_holders.contains(current_thread)))
need_to_block = true;
if (need_to_block) {
if ((m_mode == Mode::Exclusive && m_holder != current_thread)
|| (m_mode == Mode::Shared && (m_shared_holders.size() != 1 || !m_shared_holders.contains(current_thread)))) {
block(*current_thread, Mode::Exclusive, lock, lock_count);
did_block = true;
// If we blocked then m_mode should have been updated to what we requested