mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-07 19:57:45 +03: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
Notes:
sideshowbarker
2024-07-17 22:44:51 +09:00
Author: https://github.com/Hendiadyoin1 Commit: https://github.com/SerenityOS/serenity/commit/e5cf395a54b Pull-request: https://github.com/SerenityOS/serenity/pull/11201 Reviewed-by: https://github.com/bgianfo Reviewed-by: https://github.com/davidot
@ -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…
Reference in New Issue
Block a user