Skip to content

Commit

Permalink
Remove invalid use of null references (undefined behaviour)
Browse files Browse the repository at this point in the history
Enable the relevant compiler warning as an error, if supported
(-Werror=undefined-bool-conversion).

http://www.gotw.ca/conv/002.htm
http://stackoverflow.com/questions/2165078/a-reference-can-not-be-null-or-it-can-be-null

(cherry picked from commit f2911ac)
(cherry picked from commit 5a50b98)
  • Loading branch information
qris committed Nov 26, 2017
1 parent b7c6a13 commit 447c2cd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
3 changes: 0 additions & 3 deletions lib/common/Timer.cpp
Expand Up @@ -151,7 +151,6 @@ void Timers::AssertInitialised()
void Timers::Add(Timer& rTimer)
{
ASSERT(spTimers);
ASSERT(&rTimer);
BOX_TRACE(TIMER_ID_OF(rTimer) " added to global queue, rescheduling");
spTimers->push_back(&rTimer);
Reschedule();
Expand All @@ -168,8 +167,6 @@ void Timers::Add(Timer& rTimer)
// --------------------------------------------------------------------------
void Timers::Remove(Timer& rTimer)
{
ASSERT(&rTimer);

if(!spTimers)
{
BOX_WARNING(TIMER_ID_OF(rTimer) " was still active after "
Expand Down
9 changes: 5 additions & 4 deletions test/common/testcommon.cpp
Expand Up @@ -312,10 +312,11 @@ int test(int argc, const char *argv[])
// Check that using timer methods without initialisation
// throws an assertion failure. Can only do this in debug mode
#ifndef BOX_RELEASE_BUILD
TEST_CHECK_THROWS(Timers::Add(*(Timer*)NULL),
CommonException, AssertFailed);
TEST_CHECK_THROWS(Timers::Remove(*(Timer*)NULL),
CommonException, AssertFailed);
{
Timer tim(0, "tim");
TEST_CHECK_THROWS(Timers::Add(tim), CommonException, AssertFailed);
Timers::Remove(tim);
}
#endif

// TEST_CHECK_THROWS(Timers::Signal(), CommonException, AssertFailed);
Expand Down

0 comments on commit 447c2cd

Please sign in to comment.