diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2018-08-09 16:30:57 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-08-10 08:21:55 +0200 |
commit | d977e02ec6350115c39f03d588539e8bd423a1c3 (patch) | |
tree | bd624f4037b1d498cde385e56d48e383335c32ce /basic | |
parent | 76dd6bb9cc6dff0f59cdfce87b61210be6476965 (diff) |
unnecessary null check before dynamic_cast, in various
Change-Id: I76ad0b3152030c29ee28f6a6cc80d0832188d02b
Reviewed-on: https://gerrit.libreoffice.org/58774
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'basic')
-rw-r--r-- | basic/source/classes/eventatt.cxx | 3 | ||||
-rw-r--r-- | basic/source/classes/sb.cxx | 2 | ||||
-rw-r--r-- | basic/source/classes/sbxmod.cxx | 8 | ||||
-rw-r--r-- | basic/source/runtime/methods.cxx | 3 | ||||
-rw-r--r-- | basic/source/runtime/methods1.cxx | 4 | ||||
-rw-r--r-- | basic/source/sbx/sbxobj.cxx | 2 |
6 files changed, 10 insertions, 12 deletions
diff --git a/basic/source/classes/eventatt.cxx b/basic/source/classes/eventatt.cxx index 15f2617dfe48..f76f694adb43 100644 --- a/basic/source/classes/eventatt.cxx +++ b/basic/source/classes/eventatt.cxx @@ -321,9 +321,8 @@ css::uno::Reference< css::container::XNameContainer > implFindDialogLibForDialog css::uno::Reference< css::container::XNameContainer > aRetDlgLib; SbxVariable* pDlgLibContVar = pBasic->Find("DialogLibraries", SbxClassType::Object); - if( pDlgLibContVar && dynamic_cast<const SbUnoObject*>( pDlgLibContVar) != nullptr ) + if( auto pDlgLibContUnoObj = dynamic_cast<SbUnoObject*>( pDlgLibContVar) ) { - SbUnoObject* pDlgLibContUnoObj = static_cast<SbUnoObject*>(static_cast<SbxBase*>(pDlgLibContVar)); Any aDlgLibContAny = pDlgLibContUnoObj->getUnoAny(); Reference< XLibraryContainer > xDlgLibContNameAccess( aDlgLibContAny, UNO_QUERY ); diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx index 82e7b377af55..13f366c8d6c4 100644 --- a/basic/source/classes/sb.cxx +++ b/basic/source/classes/sb.cxx @@ -681,7 +681,7 @@ SbClassModuleObject::SbClassModuleObject( SbModule* pClassModule ) // Search for own copy of ImplMethod SbxVariable* p = pMethods->Find( pImplMethod->GetName(), SbxClassType::Method ); - SbMethod* pImplMethodCopy = p ? dynamic_cast<SbMethod*>( p ) : nullptr; + SbMethod* pImplMethodCopy = dynamic_cast<SbMethod*>( p ); if( !pImplMethodCopy ) { OSL_FAIL( "Found no ImplMethod copy" ); diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx index bf1a90c7b70e..c26df9c906ee 100644 --- a/basic/source/classes/sbxmod.cxx +++ b/basic/source/classes/sbxmod.cxx @@ -499,7 +499,7 @@ void SbModule::StartDefinitions() SbMethod* SbModule::GetMethod( const OUString& rName, SbxDataType t ) { SbxVariable* p = pMethods->Find( rName, SbxClassType::Method ); - SbMethod* pMeth = p ? dynamic_cast<SbMethod*>( p ) : nullptr; + SbMethod* pMeth = dynamic_cast<SbMethod*>( p ); if( p && !pMeth ) { pMethods->Remove( p ); @@ -537,7 +537,7 @@ SbMethod* SbModule::FindMethod( const OUString& rName, SbxClassType t ) SbProperty* SbModule::GetProperty( const OUString& rName, SbxDataType t ) { SbxVariable* p = pProps->Find( rName, SbxClassType::Property ); - SbProperty* pProp = p ? dynamic_cast<SbProperty*>( p ) : nullptr; + SbProperty* pProp = dynamic_cast<SbProperty*>( p ); if( p && !pProp ) { pProps->Remove( p ); @@ -556,7 +556,7 @@ SbProperty* SbModule::GetProperty( const OUString& rName, SbxDataType t ) void SbModule::GetProcedureProperty( const OUString& rName, SbxDataType t ) { SbxVariable* p = pProps->Find( rName, SbxClassType::Property ); - SbProcedureProperty* pProp = p ? dynamic_cast<SbProcedureProperty*>( p ) : nullptr; + SbProcedureProperty* pProp = dynamic_cast<SbProcedureProperty*>( p ); if( p && !pProp ) { pProps->Remove( p ); @@ -574,7 +574,7 @@ void SbModule::GetProcedureProperty( const OUString& rName, SbxDataType t ) void SbModule::GetIfaceMapperMethod( const OUString& rName, SbMethod* pImplMeth ) { SbxVariable* p = pMethods->Find( rName, SbxClassType::Method ); - SbIfaceMapperMethod* pMapperMethod = p ? dynamic_cast<SbIfaceMapperMethod*>( p ) : nullptr; + SbIfaceMapperMethod* pMapperMethod = dynamic_cast<SbIfaceMapperMethod*>( p ); if( p && !pMapperMethod ) { pMethods->Remove( p ); diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx index 4a1a6b66cd29..b9bdbec05748 100644 --- a/basic/source/runtime/methods.cxx +++ b/basic/source/runtime/methods.cxx @@ -2370,8 +2370,7 @@ void SbRtl_IsObject(StarBASIC *, SbxArray & rPar, bool) bool bObject = pVar->IsObject(); SbxBase* pObj = (bObject ? pVar->GetObject() : nullptr); - SbUnoClass* pUnoClass; - if( pObj && ( pUnoClass=dynamic_cast<SbUnoClass*>( pObj) ) != nullptr ) + if( auto pUnoClass = dynamic_cast<SbUnoClass*>( pObj) ) { bObject = pUnoClass->getUnoClass().is(); } diff --git a/basic/source/runtime/methods1.cxx b/basic/source/runtime/methods1.cxx index 4b59ea081c28..7f5ab0233096 100644 --- a/basic/source/runtime/methods1.cxx +++ b/basic/source/runtime/methods1.cxx @@ -123,7 +123,7 @@ void SbRtl_CallByName(StarBASIC *, SbxArray & rPar, bool) SbxObject* pObj = nullptr; if( pObjVar ) pObj = dynamic_cast<SbxObject*>( pObjVar ); - if( !pObj && pObjVar && dynamic_cast<const SbxVariable*>( pObjVar) != nullptr ) + if( !pObj && dynamic_cast<const SbxVariable*>( pObjVar) ) { SbxBase* pObjVarObj = static_cast<SbxVariable*>(pObjVar)->GetObject(); pObj = dynamic_cast<SbxObject*>( pObjVarObj ); @@ -864,7 +864,7 @@ void SbRtl_FindPropertyObject(StarBASIC *, SbxArray & rPar, bool) { pObj = dynamic_cast<SbxObject*>( pObjVar ); } - if( !pObj && pObjVar && dynamic_cast<const SbxVariable*>( pObjVar) != nullptr ) + if( !pObj && dynamic_cast<const SbxVariable*>( pObjVar) ) { SbxBase* pObjVarObj = static_cast<SbxVariable*>(pObjVar)->GetObject(); pObj = dynamic_cast<SbxObject*>( pObjVarObj ); diff --git a/basic/source/sbx/sbxobj.cxx b/basic/source/sbx/sbxobj.cxx index b0cf727672ff..a9bee2a803ed 100644 --- a/basic/source/sbx/sbxobj.cxx +++ b/basic/source/sbx/sbxobj.cxx @@ -290,7 +290,7 @@ SbxVariable* SbxObject::Find( const OUString& rName, SbxClassType t ) bool SbxObject::Call( const OUString& rName, SbxArray* pParam ) { SbxVariable* pMeth = FindQualified( rName, SbxClassType::DontCare); - if( pMeth && dynamic_cast<const SbxMethod*>( pMeth) != nullptr ) + if( dynamic_cast<const SbxMethod*>( pMeth) ) { // FindQualified() might have struck already! if( pParam ) |