mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 08:34:57 +00:00
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:
parent
1ad4a190b5
commit
e5cf395a54
1 changed files with 2 additions and 6 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue