tdf#43157 - salhelper: timer.cxx change OSL_ASSERT to assert

There are a number of instances where OSL_ASSERT are just not
necessary. Also, we need to change from testing if something
is/is not equal to nullptr and just use the simpler form.

Change-Id: I7e0b7deb12f0189030f66dd14ab23287341c82b7
Reviewed-on: https://gerrit.libreoffice.org/38507
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Chris Sherlock <chris.sherlock79@gmail.com>
This commit is contained in:
Chris Sherlock
2017-06-07 23:07:19 +10:00
parent a5dba7dbec
commit 3b0f8ece47

View File

@@ -19,7 +19,6 @@
#include <salhelper/timer.hxx>
#include <salhelper/simplereferenceobject.hxx>
#include <osl/diagnose.h>
#include <osl/thread.hxx>
#include <osl/conditn.hxx>
#include <osl/mutex.hxx>
@@ -106,38 +105,27 @@ void Timer::start()
TimerManager *pManager = TimerManager::getTimerManager();
OSL_ASSERT(pManager);
if (pManager != nullptr)
{
if (pManager)
pManager->registerTimer(this);
}
}
}
void Timer::stop()
{
TimerManager *pManager = TimerManager::getTimerManager();
OSL_ASSERT(pManager);
if (pManager != nullptr)
{
if (pManager)
pManager->unregisterTimer(this);
}
}
sal_Bool Timer::isTicking() const
{
TimerManager *pManager = TimerManager::getTimerManager();
OSL_ASSERT(pManager);
if (pManager)
return pManager->lookupTimer(this);
else
return false;
}
sal_Bool Timer::isExpired() const
@@ -151,16 +139,10 @@ sal_Bool Timer::isExpired() const
sal_Bool Timer::expiresBefore(const Timer* pTimer) const
{
OSL_ASSERT(pTimer);
if (pTimer != nullptr)
{
if (pTimer)
return m_aExpired < pTimer->m_aExpired;
}
else
{
return false;
}
}
void Timer::setAbsoluteTime(const TTimeValue& Time)
@@ -242,12 +224,10 @@ TimerManager::TimerManager()
{
osl::MutexGuard Guard(theTimerManagerMutex::get());
OSL_ASSERT(m_pManager == nullptr);
assert(m_pManager == nullptr);
m_pManager = this;
m_pHead= nullptr;
m_notEmpty.reset();
// start thread
@@ -258,7 +238,7 @@ TimerManager::~TimerManager()
{
osl::MutexGuard Guard(theTimerManagerMutex::get());
if ( m_pManager == this )
if (m_pManager == this)
m_pManager = nullptr;
}
@@ -279,12 +259,8 @@ TimerManager* TimerManager::getTimerManager()
void TimerManager::registerTimer(Timer* pTimer)
{
OSL_ASSERT(pTimer);
if ( pTimer == nullptr )
{
if (!pTimer)
return;
}
osl::MutexGuard Guard(m_Lock);
@@ -318,12 +294,8 @@ void TimerManager::registerTimer(Timer* pTimer)
void TimerManager::unregisterTimer(Timer* pTimer)
{
OSL_ASSERT(pTimer);
if ( pTimer == nullptr )
{
if (!pTimer)
return;
}
// lock access
osl::MutexGuard Guard(m_Lock);
@@ -344,12 +316,8 @@ void TimerManager::unregisterTimer(Timer* pTimer)
bool TimerManager::lookupTimer(const Timer* pTimer)
{
OSL_ASSERT(pTimer);
if ( pTimer == nullptr )
{
if (!pTimer)
return false;
}
// lock access
osl::MutexGuard Guard(m_Lock);
@@ -358,20 +326,17 @@ bool TimerManager::lookupTimer(const Timer* pTimer)
for (Timer* pIter = m_pHead; pIter != nullptr; pIter= pIter->m_pNext)
{
if (pIter == pTimer)
{
return true;
}
}
return false;
}
void TimerManager::checkForTimeout()
{
m_Lock.acquire();
if ( m_pHead == nullptr )
if (!m_pHead)
{
m_Lock.release();
return;
@@ -391,7 +356,7 @@ void TimerManager::checkForTimeout()
pTimer->onShot();
// restart timer if specified
if ( ! pTimer->m_aRepeatDelta.isEmpty() )
if (!pTimer->m_aRepeatDelta.isEmpty())
{
TTimeValue Now;