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.
This commit is contained in:
Patrick Ohly 2014-06-25 11:48:12 +00:00
parent 16db5644c6
commit 764e9eee79
2 changed files with 9 additions and 2 deletions

View File

@ -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);

View File

@ -435,6 +435,7 @@ class ClientTest : private boost::noncopyable {
* registerTests() and remains valid until the client is deleted
*/
void *factory;
void freeFactory();
};
/**