diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2018-08-30 15:06:34 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2018-08-30 18:49:45 +0200 |
commit | 416a543824caa01a07ab96f1764769d4f234f213 (patch) | |
tree | e3d56366e24ffc765e015ff22082fd4ac22b991e | |
parent | 81fac013cb365d711ad78a566ee1b5b13480b013 (diff) |
Remove redundant asserts after new
Also remove SlideSorter::CreateController which only calls new;
fix a memory leak in osl_Security's MyTestPlugInImpl::initialize
Change-Id: I70b6e888984f8543adbf879162e752556d2b3f0e
Reviewed-on: https://gerrit.libreoffice.org/59805
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r-- | sal/qa/osl/security/osl_Security.cxx | 6 | ||||
-rw-r--r-- | salhelper/qa/test_api.cxx | 5 | ||||
-rw-r--r-- | sd/source/ui/inc/SlideSorter.hxx | 6 | ||||
-rw-r--r-- | sd/source/ui/slidesorter/shell/SlideSorter.cxx | 14 |
4 files changed, 4 insertions, 27 deletions
diff --git a/sal/qa/osl/security/osl_Security.cxx b/sal/qa/osl/security/osl_Security.cxx index a1dff025ce70..94a0dcf6a1d1 100644 --- a/sal/qa/osl/security/osl_Security.cxx +++ b/sal/qa/osl/security/osl_Security.cxx @@ -418,11 +418,9 @@ void MyTestPlugInImpl::initialize( CPPUNIT_NS::TestFactoryRegistry *, // Create buffers for the SID and the domain name. PSID pSid = static_cast<PSID>(new BYTE[dwSidBufferSize]); - CPPUNIT_ASSERT_MESSAGE("# creating SID buffer failed.\n", pSid!= nullptr ); memset( pSid, 0, dwSidBufferSize); wszDomainName = new WCHAR[dwDomainBufferSize]; - CPPUNIT_ASSERT_MESSAGE("# creating Domain name buffer failed.\n", wszDomainName != nullptr ); memset(wszDomainName, 0, dwDomainBufferSize*sizeof(WCHAR)); // Obtain the SID for the account name passed. @@ -454,9 +452,8 @@ void MyTestPlugInImpl::initialize( CPPUNIT_NS::TestFactoryRegistry *, { // Reallocate memory for the SID buffer. wprintf(L"# The SID buffer was too small. It will be reallocated.\n"); - FreeSid( pSid); + delete[] static_cast<BYTE*>(pSid); pSid = static_cast<PSID>(new BYTE[cbSid]); - CPPUNIT_ASSERT_MESSAGE("# re-creating SID buffer failed.\n", pSid!= nullptr ); memset( pSid, 0, cbSid); dwSidBufferSize = cbSid; } @@ -466,7 +463,6 @@ void MyTestPlugInImpl::initialize( CPPUNIT_NS::TestFactoryRegistry *, wprintf(L"# The domain name buffer was too small. It will be reallocated.\n"); delete [] wszDomainName; wszDomainName = new WCHAR[cchDomainName]; - CPPUNIT_ASSERT_MESSAGE("# re-creating domain name buffer failed.\n", wszDomainName!= nullptr ); memset(wszDomainName, 0, cchDomainName*sizeof(WCHAR)); dwDomainBufferSize = cchDomainName; } diff --git a/salhelper/qa/test_api.cxx b/salhelper/qa/test_api.cxx index badde099e117..56cc571dd6b4 100644 --- a/salhelper/qa/test_api.cxx +++ b/salhelper/qa/test_api.cxx @@ -220,15 +220,14 @@ void Test::testSimpleReferenceObject() { void Test::testDerivedCondition() { osl::Mutex mutex; + // Next line tests that new doesn't throw std::unique_ptr< salhelper::Condition > p(new DerivedCondition(mutex)); - CPPUNIT_ASSERT(dynamic_cast< DerivedCondition * >(p.get()) != nullptr); } void Test::testDerivedConditionWaiterTimedout() { + // Next line tests that new doesn't throw std::unique_ptr< salhelper::ConditionWaiter::timedout > p( new DerivedConditionWaiterTimedout); - CPPUNIT_ASSERT( - dynamic_cast< DerivedConditionWaiterTimedout * >(p.get()) != nullptr); try { throw DerivedConditionWaiterTimedout(); } catch (salhelper::ConditionWaiter::timedout &) { diff --git a/sd/source/ui/inc/SlideSorter.hxx b/sd/source/ui/inc/SlideSorter.hxx index 9ae38c845a14..8b83e8cf9f3c 100644 --- a/sd/source/ui/inc/SlideSorter.hxx +++ b/sd/source/ui/inc/SlideSorter.hxx @@ -198,12 +198,6 @@ private: */ model::SlideSorterModel* CreateModel(); - /** Create the controller for the view shell. When called from the default - implementation of CreateModelViewController() then both the view and - the controller do exist. Test their pointers when in doubt. - */ - controller::SlideSorterController* CreateController(); - bool mbIsValid; std::unique_ptr<controller::SlideSorterController> mpSlideSorterController; diff --git a/sd/source/ui/slidesorter/shell/SlideSorter.cxx b/sd/source/ui/slidesorter/shell/SlideSorter.cxx index bcc71fbb3667..56daffae9add 100644 --- a/sd/source/ui/slidesorter/shell/SlideSorter.cxx +++ b/sd/source/ui/slidesorter/shell/SlideSorter.cxx @@ -302,12 +302,7 @@ void SlideSorter::CreateModelViewController() "Can not create model for slide browser"); mpSlideSorterView.reset(new view::SlideSorterView (*this)); - DBG_ASSERT (mpSlideSorterView.get()!=nullptr, - "Can not create view for slide browser"); - - mpSlideSorterController.reset(CreateController()); - DBG_ASSERT (mpSlideSorterController.get()!=nullptr, - "Can not create controller for slide browser"); + mpSlideSorterController.reset(new controller::SlideSorterController(*this)); // Now that model, view, and controller are constructed, do the // initialization that relies on all three being in place. @@ -329,13 +324,6 @@ model::SlideSorterModel* SlideSorter::CreateModel() return nullptr; } -controller::SlideSorterController* SlideSorter::CreateController() -{ - controller::SlideSorterController* pController - = new controller::SlideSorterController (*this); - return pController; -} - void SlideSorter::ArrangeGUIElements ( const Point& rOffset, const Size& rSize) |