From 04cf6de098f0677b2623377c20983f229f0156be Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Sun, 17 Mar 2019 21:36:10 +0300 Subject: [PATCH] tdf#120703 PVS: remove redundant static casts V572 It is odd that the object which was created using 'new' operator is immediately cast to another type. Change-Id: I6d1523e71b3e06be1cf41abaabb44e49fe11cd8e Reviewed-on: https://gerrit.libreoffice.org/69369 Tested-by: Jenkins Reviewed-by: Mike Kaganski --- basctl/source/basicide/moduldl2.cxx | 3 +-- comphelper/source/container/namecontainer.cxx | 2 +- cppuhelper/source/propshlp.cxx | 2 +- embeddedobj/source/msole/olevisual.cxx | 4 ++-- package/source/xstor/owriteablestream.cxx | 2 +- sfx2/source/notify/globalevents.cxx | 4 +--- svl/source/fsstor/fsstorage.cxx | 8 ++++---- toolkit/source/controls/geometrycontrolmodel.cxx | 2 +- ucb/source/ucp/file/prov.cxx | 2 +- uui/source/passwordcontainer.cxx | 4 ++-- 10 files changed, 15 insertions(+), 18 deletions(-) diff --git a/basctl/source/basicide/moduldl2.cxx b/basctl/source/basicide/moduldl2.cxx index 8ccae470425e..5a763aa465b9 100644 --- a/basctl/source/basicide/moduldl2.cxx +++ b/basctl/source/basicide/moduldl2.cxx @@ -1194,10 +1194,9 @@ void LibPage::ExportAsPackage( const OUString& aLibName ) implExportLib( aLibName, aTmpPath, xDummyHandler ); Reference< XCommandEnvironment > xCmdEnv = - static_cast( new OLibCommandEnvironment( Reference< task::XInteractionHandler >( - xHandler, UNO_QUERY ) ) ); + xHandler, UNO_QUERY)); ::ucbhelper::Content sourceContent( aSourcePath, xCmdEnv, comphelper::getProcessComponentContext() ); diff --git a/comphelper/source/container/namecontainer.cxx b/comphelper/source/container/namecontainer.cxx index fa8343c60d49..0f905fac9124 100644 --- a/comphelper/source/container/namecontainer.cxx +++ b/comphelper/source/container/namecontainer.cxx @@ -155,7 +155,7 @@ Type SAL_CALL NameContainer::getElementType() Reference< XNameContainer > comphelper::NameContainer_createInstance( const Type& aType ) { - return static_cast(new NameContainer( aType )); + return new NameContainer(aType); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/source/propshlp.cxx b/cppuhelper/source/propshlp.cxx index bd1cbe62a62a..312ad4411e79 100644 --- a/cppuhelper/source/propshlp.cxx +++ b/cppuhelper/source/propshlp.cxx @@ -248,7 +248,7 @@ void OPropertySetHelper::disposing() Reference < XPropertySetInfo > OPropertySetHelper::createPropertySetInfo( IPropertyArrayHelper & rProperties ) { - return static_cast< XPropertySetInfo * >( new OPropertySetHelperInfo_Impl( rProperties ) ); + return new OPropertySetHelperInfo_Impl(rProperties); } // XPropertySet diff --git a/embeddedobj/source/msole/olevisual.cxx b/embeddedobj/source/msole/olevisual.cxx index 6fe1bc40bb8c..879d0b0ce9ec 100644 --- a/embeddedobj/source/msole/olevisual.cxx +++ b/embeddedobj/source/msole/olevisual.cxx @@ -367,8 +367,8 @@ embed::VisualRepresentation SAL_CALL OleEmbeddedObject::getPreferredVisualRepres if ( aVisReplSeq.getLength() ) { m_xCachedVisualRepresentation = GetNewFilledTempStream_Impl( - uno::Reference< io::XInputStream > ( static_cast< io::XInputStream* > ( - new ::comphelper::SequenceInputStream( aVisReplSeq ) ) ) ); + uno::Reference< io::XInputStream >( + new ::comphelper::SequenceInputStream(aVisReplSeq))); } return aVisualRepr; diff --git a/package/source/xstor/owriteablestream.cxx b/package/source/xstor/owriteablestream.cxx index 5b271decc1c9..5f27ba5d7774 100644 --- a/package/source/xstor/owriteablestream.cxx +++ b/package/source/xstor/owriteablestream.cxx @@ -806,7 +806,7 @@ void OWriteStream_Impl::Commit() uno::Reference< io::XInputStream > xInStream; try { - xInStream.set( static_cast< io::XInputStream* >( new OSelfTerminateFileStream( m_xContext, m_aTempURL ) ), uno::UNO_QUERY ); + xInStream = new OSelfTerminateFileStream(m_xContext, m_aTempURL); } catch( const uno::Exception& ) { diff --git a/sfx2/source/notify/globalevents.cxx b/sfx2/source/notify/globalevents.cxx index 3cc3cc05500f..844fd7a676bd 100644 --- a/sfx2/source/notify/globalevents.cxx +++ b/sfx2/source/notify/globalevents.cxx @@ -319,9 +319,7 @@ uno::Reference< container::XEnumeration > SAL_CALL SfxGlobalEvents_Impl::createE { models[i] <<= m_lModels[i]; } - uno::Reference< container::XEnumeration > xEnum( - static_cast( - new ::comphelper::OAnyEnumeration(models))); + uno::Reference xEnum(new ::comphelper::OAnyEnumeration(models)); aLock.clear(); // <- SAFE diff --git a/svl/source/fsstor/fsstorage.cxx b/svl/source/fsstor/fsstorage.cxx index d3eae55b363b..c1727b93d3cd 100644 --- a/svl/source/fsstor/fsstorage.cxx +++ b/svl/source/fsstor/fsstorage.cxx @@ -369,7 +369,7 @@ uno::Reference< io::XStream > SAL_CALL FSStorage::openStreamElement( ::ucbhelper::Content aResultContent( aFileURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), xDummyEnv, comphelper::getProcessComponentContext() ); uno::Reference< io::XInputStream > xInStream = aResultContent.openStream(); - xResult = static_cast< io::XStream* >( new OFSInputStreamContainer( xInStream ) ); + xResult = new OFSInputStreamContainer(xInStream); } } catch( embed::InvalidStorageException& ) @@ -1124,7 +1124,7 @@ uno::Reference< embed::XExtendedStorageStream > SAL_CALL FSStorage::openStreamEl uno::Reference< io::XStream > xStream = xSimpleFileAccess->openFileReadWrite( aFileURL ); - xResult = static_cast< io::XStream* >( new OFSStreamContainer( xStream ) ); + xResult = new OFSStreamContainer(xStream); } else { @@ -1135,7 +1135,7 @@ uno::Reference< embed::XExtendedStorageStream > SAL_CALL FSStorage::openStreamEl { uno::Reference< io::XStream > xStream = uno::Reference < io::XStream >( new ::utl::OStreamWrapper( std::move(pStream) ) ); - xResult = static_cast< io::XStream* >( new OFSStreamContainer( xStream ) ); + xResult = new OFSStreamContainer(xStream); } } @@ -1156,7 +1156,7 @@ uno::Reference< embed::XExtendedStorageStream > SAL_CALL FSStorage::openStreamEl ::ucbhelper::Content aResultContent( aFileURL, xDummyEnv, comphelper::getProcessComponentContext() ); uno::Reference< io::XInputStream > xInStream = aResultContent.openStream(); - xResult = static_cast< io::XStream* >( new OFSInputStreamContainer( xInStream ) ); + xResult = new OFSInputStreamContainer(xInStream); } } catch( embed::InvalidStorageException& ) diff --git a/toolkit/source/controls/geometrycontrolmodel.cxx b/toolkit/source/controls/geometrycontrolmodel.cxx index 8f576dc7c312..fedcd4dc1d29 100644 --- a/toolkit/source/controls/geometrycontrolmodel.cxx +++ b/toolkit/source/controls/geometrycontrolmodel.cxx @@ -420,7 +420,7 @@ Reference< XNameContainer > SAL_CALL OGeometryControlModel_Base::getEvents() { if( !mxEventContainer.is() ) - mxEventContainer = static_cast(new toolkit::ScriptEventContainer()); + mxEventContainer = new toolkit::ScriptEventContainer(); return mxEventContainer; } diff --git a/ucb/source/ucp/file/prov.cxx b/ucb/source/ucp/file/prov.cxx index a5b4c0d49c1f..197f45279caf 100644 --- a/ucb/source/ucp/file/prov.cxx +++ b/ucb/source/ucp/file/prov.cxx @@ -154,7 +154,7 @@ Reference< XInterface > SAL_CALL FileProvider::CreateInstance( const Reference< XMultiServiceFactory >& xMultiServiceFactory ) { - XServiceInfo* xP = static_cast(new FileProvider( comphelper::getComponentContext(xMultiServiceFactory) )); + XServiceInfo* xP = new FileProvider(comphelper::getComponentContext(xMultiServiceFactory)); return Reference< XInterface >::query( xP ); } diff --git a/uui/source/passwordcontainer.cxx b/uui/source/passwordcontainer.cxx index 82ee8ddf8b32..ef8fef56a10f 100644 --- a/uui/source/passwordcontainer.cxx +++ b/uui/source/passwordcontainer.cxx @@ -406,8 +406,8 @@ static uno::Reference< uno::XInterface > PasswordContainerInteractionHandler_CreateInstance( const uno::Reference< lang::XMultiServiceFactory> & rSMgr ) { - lang::XServiceInfo * pX = static_cast< lang::XServiceInfo * >( - new PasswordContainerInteractionHandler( comphelper::getComponentContext(rSMgr) ) ); + lang::XServiceInfo* pX + = new PasswordContainerInteractionHandler(comphelper::getComponentContext(rSMgr)); return uno::Reference< uno::XInterface >::query( pX ); }