1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 08:58:11 +00:00

Everywhere: Rename ASSERT => VERIFY

(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED)

Since all of these checks are done in release builds as well,
let's rename them to VERIFY to prevent confusion, as everyone is
used to assertions being compiled out in release.

We can introduce a new ASSERT macro that is specifically for debug
checks, but I'm doing this wholesale conversion first since we've
accumulated thousands of these already, and it's not immediately
obvious which ones are suitable for ASSERT.
This commit is contained in:
Andreas Kling 2021-02-23 20:42:32 +01:00
parent b33a6a443e
commit 5d180d1f99
725 changed files with 3448 additions and 3448 deletions

View file

@ -45,8 +45,8 @@ void Lock::lock(Mode mode)
{
// NOTE: This may be called from an interrupt handler (not an IRQ handler)
// and also from within critical sections!
ASSERT(!Processor::current().in_irq());
ASSERT(mode != Mode::Unlocked);
VERIFY(!Processor::current().in_irq());
VERIFY(mode != Mode::Unlocked);
auto current_thread = Thread::current();
ScopedCritical critical; // in case we're not in a critical section already
for (;;) {
@ -62,15 +62,15 @@ void Lock::lock(Mode mode)
case Mode::Unlocked: {
dbgln_if(LOCK_TRACE_DEBUG, "Lock::lock @ ({}) {}: acquire {}, currently unlocked", this, m_name, mode_to_string(mode));
m_mode = mode;
ASSERT(!m_holder);
ASSERT(m_shared_holders.is_empty());
VERIFY(!m_holder);
VERIFY(m_shared_holders.is_empty());
if (mode == Mode::Exclusive) {
m_holder = current_thread;
} else {
ASSERT(mode == Mode::Shared);
VERIFY(mode == Mode::Shared);
m_shared_holders.set(current_thread, 1);
}
ASSERT(m_times_locked == 0);
VERIFY(m_times_locked == 0);
m_times_locked++;
#if LOCK_DEBUG
current_thread->holding_lock(*this, 1, file, line);
@ -80,10 +80,10 @@ void Lock::lock(Mode mode)
return;
}
case Mode::Exclusive: {
ASSERT(m_holder);
VERIFY(m_holder);
if (m_holder != current_thread)
break;
ASSERT(m_shared_holders.is_empty());
VERIFY(m_shared_holders.is_empty());
if constexpr (LOCK_TRACE_DEBUG) {
if (mode == Mode::Exclusive)
@ -92,8 +92,8 @@ void Lock::lock(Mode mode)
dbgln("Lock::lock @ {} ({}): acquire exclusive (requested {}), currently exclusive, holding: {}", this, m_name, mode_to_string(mode), m_times_locked);
}
ASSERT(mode == Mode::Exclusive || mode == Mode::Shared);
ASSERT(m_times_locked > 0);
VERIFY(mode == Mode::Exclusive || mode == Mode::Shared);
VERIFY(m_times_locked > 0);
m_times_locked++;
#if LOCK_DEBUG
current_thread->holding_lock(*this, 1, file, line);
@ -102,15 +102,15 @@ void Lock::lock(Mode mode)
return;
}
case Mode::Shared: {
ASSERT(!m_holder);
VERIFY(!m_holder);
if (mode != Mode::Shared)
break;
dbgln_if(LOCK_TRACE_DEBUG, "Lock::lock @ {} ({}): acquire {}, currently shared, locks held {}", this, m_name, mode_to_string(mode), m_times_locked);
ASSERT(m_times_locked > 0);
VERIFY(m_times_locked > 0);
m_times_locked++;
ASSERT(!m_shared_holders.is_empty());
VERIFY(!m_shared_holders.is_empty());
auto it = m_shared_holders.find(current_thread);
if (it != m_shared_holders.end())
it->value++;
@ -123,7 +123,7 @@ void Lock::lock(Mode mode)
return;
}
default:
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
m_lock.store(false, AK::memory_order_release);
dbgln_if(LOCK_TRACE_DEBUG, "Lock::lock @ {} ({}) waiting...", this, m_name);
@ -136,7 +136,7 @@ void Lock::unlock()
{
// NOTE: This may be called from an interrupt handler (not an IRQ handler)
// and also from within critical sections!
ASSERT(!Processor::current().in_irq());
VERIFY(!Processor::current().in_irq());
auto current_thread = Thread::current();
ScopedCritical critical; // in case we're not in a critical section already
for (;;) {
@ -149,37 +149,37 @@ void Lock::unlock()
dbgln("Lock::unlock @ {} ({}): release {}, holding: {}", this, m_name, mode_to_string(current_mode), m_times_locked);
}
ASSERT(current_mode != Mode::Unlocked);
VERIFY(current_mode != Mode::Unlocked);
ASSERT(m_times_locked > 0);
VERIFY(m_times_locked > 0);
m_times_locked--;
switch (current_mode) {
case Mode::Exclusive:
ASSERT(m_holder == current_thread);
ASSERT(m_shared_holders.is_empty());
VERIFY(m_holder == current_thread);
VERIFY(m_shared_holders.is_empty());
if (m_times_locked == 0)
m_holder = nullptr;
break;
case Mode::Shared: {
ASSERT(!m_holder);
VERIFY(!m_holder);
auto it = m_shared_holders.find(current_thread);
ASSERT(it != m_shared_holders.end());
VERIFY(it != m_shared_holders.end());
if (it->value > 1) {
it->value--;
} else {
ASSERT(it->value > 0);
VERIFY(it->value > 0);
m_shared_holders.remove(it);
}
break;
}
default:
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
bool unlocked_last = (m_times_locked == 0);
if (unlocked_last) {
ASSERT(current_mode == Mode::Exclusive ? !m_holder : m_shared_holders.is_empty());
VERIFY(current_mode == Mode::Exclusive ? !m_holder : m_shared_holders.is_empty());
m_mode = Mode::Unlocked;
m_queue.should_block(false);
}
@ -204,7 +204,7 @@ auto Lock::force_unlock_if_locked(u32& lock_count_to_restore) -> Mode
{
// NOTE: This may be called from an interrupt handler (not an IRQ handler)
// and also from within critical sections!
ASSERT(!Processor::current().in_irq());
VERIFY(!Processor::current().in_irq());
auto current_thread = Thread::current();
ScopedCritical critical; // in case we're not in a critical section already
for (;;) {
@ -224,7 +224,7 @@ auto Lock::force_unlock_if_locked(u32& lock_count_to_restore) -> Mode
m_holder->holding_lock(*this, -(int)lock_count_to_restore);
#endif
m_holder = nullptr;
ASSERT(m_times_locked > 0);
VERIFY(m_times_locked > 0);
lock_count_to_restore = m_times_locked;
m_times_locked = 0;
m_mode = Mode::Unlocked;
@ -234,7 +234,7 @@ auto Lock::force_unlock_if_locked(u32& lock_count_to_restore) -> Mode
break;
}
case Mode::Shared: {
ASSERT(!m_holder);
VERIFY(!m_holder);
auto it = m_shared_holders.find(current_thread);
if (it == m_shared_holders.end()) {
m_lock.store(false, AK::MemoryOrder::memory_order_release);
@ -245,14 +245,14 @@ auto Lock::force_unlock_if_locked(u32& lock_count_to_restore) -> Mode
dbgln_if(LOCK_RESTORE_DEBUG, "Lock::force_unlock_if_locked @ {}: unlocking exclusive with lock count: {}, total locks: {}",
this, it->value, m_times_locked);
ASSERT(it->value > 0);
VERIFY(it->value > 0);
lock_count_to_restore = it->value;
ASSERT(lock_count_to_restore > 0);
VERIFY(lock_count_to_restore > 0);
#if LOCK_DEBUG
m_holder->holding_lock(*this, -(int)lock_count_to_restore);
#endif
m_shared_holders.remove(it);
ASSERT(m_times_locked >= lock_count_to_restore);
VERIFY(m_times_locked >= lock_count_to_restore);
m_times_locked -= lock_count_to_restore;
if (m_times_locked == 0) {
m_mode = Mode::Unlocked;
@ -269,7 +269,7 @@ auto Lock::force_unlock_if_locked(u32& lock_count_to_restore) -> Mode
break;
}
default:
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
m_queue.wake_one();
return previous_mode;
@ -290,9 +290,9 @@ void Lock::restore_lock(const char* file, int line, Mode mode, u32 lock_count)
void Lock::restore_lock(Mode mode, u32 lock_count)
#endif
{
ASSERT(mode != Mode::Unlocked);
ASSERT(lock_count > 0);
ASSERT(!Processor::current().in_irq());
VERIFY(mode != Mode::Unlocked);
VERIFY(lock_count > 0);
VERIFY(!Processor::current().in_irq());
auto current_thread = Thread::current();
ScopedCritical critical; // in case we're not in a critical section already
for (;;) {
@ -305,10 +305,10 @@ void Lock::restore_lock(Mode mode, u32 lock_count)
dbgln_if(LOCK_RESTORE_DEBUG, "Lock::restore_lock @ {}: restoring {} with lock count {}, was unlocked", this, mode_to_string(mode), lock_count);
ASSERT(m_times_locked == 0);
VERIFY(m_times_locked == 0);
m_times_locked = lock_count;
ASSERT(!m_holder);
ASSERT(m_shared_holders.is_empty());
VERIFY(!m_holder);
VERIFY(m_shared_holders.is_empty());
m_holder = current_thread;
m_queue.should_block(true);
m_lock.store(false, AK::memory_order_release);
@ -325,13 +325,13 @@ void Lock::restore_lock(Mode mode, u32 lock_count)
dbgln_if(LOCK_RESTORE_DEBUG, "Lock::restore_lock @ {}: restoring {} with lock count {}, was {}",
this, mode_to_string(mode), lock_count, mode_to_string(expected_mode));
ASSERT(expected_mode == Mode::Shared || m_times_locked == 0);
VERIFY(expected_mode == Mode::Shared || m_times_locked == 0);
m_times_locked += lock_count;
ASSERT(!m_holder);
ASSERT((expected_mode == Mode::Unlocked) == m_shared_holders.is_empty());
VERIFY(!m_holder);
VERIFY((expected_mode == Mode::Unlocked) == m_shared_holders.is_empty());
auto set_result = m_shared_holders.set(current_thread, lock_count);
// There may be other shared lock holders already, but we should not have an entry yet
ASSERT(set_result == AK::HashSetResult::InsertedNewEntry);
VERIFY(set_result == AK::HashSetResult::InsertedNewEntry);
m_queue.should_block(true);
m_lock.store(false, AK::memory_order_release);
#if LOCK_DEBUG
@ -340,7 +340,7 @@ void Lock::restore_lock(Mode mode, u32 lock_count)
return;
}
default:
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
m_lock.store(false, AK::memory_order_relaxed);
@ -352,7 +352,7 @@ void Lock::restore_lock(Mode mode, u32 lock_count)
void Lock::clear_waiters()
{
ASSERT(m_mode != Mode::Shared);
VERIFY(m_mode != Mode::Shared);
m_queue.wake_all();
}