diff options
author | Patrick Ohly <patrick.ohly@intel.com> | 2014-06-25 11:48:12 +0000 |
---|---|---|
committer | Patrick Ohly <patrick.ohly@intel.com> | 2014-07-03 11:20:10 +0200 |
commit | 764e9eee792dfe1a3e3227c30b6b93e9d9c79479 (patch) | |
tree | 1de00c5a5c41b58f50897d0c4c75f62c45730b05 | |
parent | 16db5644c67b2b117b60b68d350234881741e1e3 (diff) |
testing: fix cppcheck ClientTest::registerTests() warning
cppcheck warns that "factory" might get overwritten. Probably
never happened becaued registerTests() is only called once, but
let's fix it anyway.
-rw-r--r-- | test/ClientTest.cpp | 10 | ||||
-rw-r--r-- | test/ClientTest.h | 1 |
2 files changed, 9 insertions, 2 deletions
diff --git a/test/ClientTest.cpp b/test/ClientTest.cpp index 21c418bb..9fadd5e9 100644 --- a/test/ClientTest.cpp +++ b/test/ClientTest.cpp @@ -6654,6 +6654,7 @@ private: void ClientTest::registerTests() { + freeFactory(); factory = (void *)new ClientTestFactory(*this); CppUnit::TestFactoryRegistry::getRegistry().registerFactory((CppUnit::TestFactory *)factory); } @@ -6665,15 +6666,20 @@ ClientTest::ClientTest(int serverSleepSec, const std::string &serverLog) : { } -ClientTest::~ClientTest() +void ClientTest::freeFactory() { if(factory) { CppUnit::TestFactoryRegistry::getRegistry().unregisterFactory((CppUnit::TestFactory *)factory); delete (CppUnit::TestFactory *)factory; - factory = 0; + factory = NULL; } } +ClientTest::~ClientTest() +{ + freeFactory(); +} + void ClientTest::registerCleanup(Cleanup_t cleanup) { cleanupSet.insert(cleanup); diff --git a/test/ClientTest.h b/test/ClientTest.h index e23b25ad..dfa4626c 100644 --- a/test/ClientTest.h +++ b/test/ClientTest.h @@ -435,6 +435,7 @@ class ClientTest : private boost::noncopyable { * registerTests() and remains valid until the client is deleted */ void *factory; + void freeFactory(); }; /** |