basctl/source/basicide/bastype2.cxx | 3 +-- binaryurp/source/reader.cxx | 6 ++---- codemaker/source/javamaker/javatype.cxx | 6 ++---- filter/source/textfilterdetect/filterdetect.cxx | 3 +-- package/source/xstor/xstorage.cxx | 6 ------ package/source/zippackage/ZipPackageStream.cxx | 8 +++----- registry/source/regimpl.cxx | 3 +-- sd/source/ui/tools/SdGlobalResourceContainer.cxx | 5 +---- sw/source/core/crsr/swcrsr.cxx | 6 ++---- ucb/source/ucp/webdav-neon/DAVSessionFactory.cxx | 3 +-- unoidl/source/legacyprovider.cxx | 6 +++--- 11 files changed, 17 insertions(+), 38 deletions(-)
New commits: commit 09978dd1fc18ce1ae707bc9e4ea1d2745ff07b61 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Fri Sep 7 16:07:31 2018 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Sat Sep 8 08:45:51 2018 +0200 clang-tidy bugprone-unused-return-value In OStorage::openEncryptedStream the lines were marked with a TODO until the TODO comment was removed in commit 8083b46285fefc4af751e1b00d20b40bea196ea8 Date: Tue Jun 16 16:15:54 2009 +0000 CWS-TOOLING: integrate CWS fwk103 Since no-one has "fixed" this intended functionality by now, I just removed it. The lines in unoidl/ were introduced by commit 12353c73868d26690aa4ac008ef5e9f2db8bc12c Date: Fri Mar 1 23:23:50 2013 +0100 WIP: Experimental new binary type.rdb format I assume that not throwing these was just an oversight. Change-Id: I26fbcce267f2cc1154a30b8259176f59611dfbd8 Reviewed-on: https://gerrit.libreoffice.org/60161 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/package/source/xstor/xstorage.cxx b/package/source/xstor/xstorage.cxx index 3488e5726150..adc4a3a2d661 100644 --- a/package/source/xstor/xstorage.cxx +++ b/package/source/xstor/xstorage.cxx @@ -3142,9 +3142,6 @@ uno::Reference< io::XStream > SAL_CALL OStorage::openEncryptedStream( throw lang::DisposedException( THROW_WHERE ); } - if ( m_pData->m_nStorageType != embed::StorageFormats::PACKAGE ) - packages::NoEncryptionException(); - if ( ( nOpenMode & embed::ElementModes::WRITE ) && m_pData->m_bReadOnlyWrap ) throw io::IOException( THROW_WHERE ); // TODO: access denied @@ -3231,9 +3228,6 @@ uno::Reference< io::XStream > SAL_CALL OStorage::cloneEncryptedStream( throw lang::DisposedException( THROW_WHERE ); } - if ( m_pData->m_nStorageType != embed::StorageFormats::PACKAGE ) - packages::NoEncryptionException(); - if ( !aEncryptionData.getLength() ) throw lang::IllegalArgumentException( THROW_WHERE, uno::Reference< uno::XInterface >(), 2 ); diff --git a/unoidl/source/legacyprovider.cxx b/unoidl/source/legacyprovider.cxx index eb9462c733f2..b39c08d806d8 100644 --- a/unoidl/source/legacyprovider.cxx +++ b/unoidl/source/legacyprovider.cxx @@ -377,7 +377,7 @@ rtl::Reference< Entity > readEntity( base = reader.getSuperTypeName(0).replace('/', '.'); break; default: - FileFormatException( + throw FileFormatException( key.getRegistryName(), ("legacy format: unexpected number " + OUString::number(reader.getSuperTypeCount()) @@ -397,7 +397,7 @@ rtl::Reference< Entity > readEntity( translateAnnotations(reader.getDocumentation())); } else { if (reader.getSuperTypeCount() != 0) { - FileFormatException( + throw FileFormatException( key.getRegistryName(), ("legacy format: unexpected number " + OUString::number(reader.getSuperTypeCount()) @@ -432,7 +432,7 @@ rtl::Reference< Entity > readEntity( for (sal_uInt16 j = 0; j != n; ++j) { RTConstValue v(reader.getFieldValue(j)); if (v.m_type != RT_TYPE_INT32) { - FileFormatException( + throw FileFormatException( key.getRegistryName(), ("legacy format: unexpected type " + OUString::number(v.m_type) + " of value of field " commit 7764ae70b04058a64a3999529e98d1115ba59d1c Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Fri Sep 7 15:47:40 2018 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Sat Sep 8 08:45:41 2018 +0200 clang bugprone-unused-return-value most of these changes just make the change of ownership when using std::unique_ptr clearer, but there is one definite leak fix in PlainTextFilterDetect::detect Change-Id: I8282a68007222a4fee84004f394bde0cca8569e9 Reviewed-on: https://gerrit.libreoffice.org/60159 Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> Tested-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/basctl/source/basicide/bastype2.cxx b/basctl/source/basicide/bastype2.cxx index 5997980df2ea..d8fe8efdc59a 100644 --- a/basctl/source/basicide/bastype2.cxx +++ b/basctl/source/basicide/bastype2.cxx @@ -701,9 +701,8 @@ SvTreeListEntry* TreeListBox::AddEntry( { SvTreeListEntry* p = InsertEntry( rText, rImage, rImage, pParent, bChildrenOnDemand, TREELIST_APPEND, - aUserData.get() + aUserData.release() ); - aUserData.release(); return p; } diff --git a/binaryurp/source/reader.cxx b/binaryurp/source/reader.cxx index fa5e91be704e..c40aeadea7df 100644 --- a/binaryurp/source/reader.cxx +++ b/binaryurp/source/reader.cxx @@ -335,9 +335,8 @@ void Reader::readMessage(Unmarshal & unmarshal) { bridge_->incrementActiveCalls(); } uno_threadpool_putJob( - bridge_->getThreadPool(), tid.getHandle(), req.get(), &request, + bridge_->getThreadPool(), tid.getHandle(), req.release(), &request, !synchronous); - req.release(); } } @@ -443,9 +442,8 @@ void Reader::readReplyMessage(Unmarshal & unmarshal, sal_uInt8 flags1) { std::unique_ptr< IncomingReply > resp( new IncomingReply(exc, ret, outArgs)); uno_threadpool_putJob( - bridge_->getThreadPool(), tid.getHandle(), resp.get(), nullptr, + bridge_->getThreadPool(), tid.getHandle(), resp.release(), nullptr, false); - resp.release(); break; } case OutgoingRequest::KIND_REQUEST_CHANGE: diff --git a/codemaker/source/javamaker/javatype.cxx b/codemaker/source/javamaker/javatype.cxx index 5530392b278b..944f1a0aca9f 100644 --- a/codemaker/source/javamaker/javatype.cxx +++ b/codemaker/source/javamaker/javatype.cxx @@ -764,8 +764,7 @@ void handleEnumType( std::unique_ptr< ClassFile::Code > blockCode(cf->newCode()); blockCode->instrGetstatic(className, pair.second, classDescriptor); blockCode->instrAreturn(); - blocks.push_back(blockCode.get()); - blockCode.release(); + blocks.push_back(blockCode.release()); } code->instrTableswitch(defCode.get(), min, blocks); for (ClassFile::Code *p : blocks) @@ -783,8 +782,7 @@ void handleEnumType( std::unique_ptr< ClassFile::Code > blockCode(cf->newCode()); blockCode->instrGetstatic(className, pair.second, classDescriptor); blockCode->instrAreturn(); - blocks.emplace_back(pair.first, blockCode.get()); - blockCode.release(); + blocks.emplace_back(pair.first, blockCode.release()); } code->instrLookupswitch(defCode.get(), blocks); for (const std::pair< sal_Int32, ClassFile::Code * >& pair : blocks) diff --git a/filter/source/textfilterdetect/filterdetect.cxx b/filter/source/textfilterdetect/filterdetect.cxx index 3eeb0b1ee485..cb0055c34565 100644 --- a/filter/source/textfilterdetect/filterdetect.cxx +++ b/filter/source/textfilterdetect/filterdetect.cxx @@ -171,8 +171,7 @@ OUString SAL_CALL PlainTextFilterDetect::detect(uno::Sequence<beans::PropertyVal std::unique_ptr<SvMemoryStream> pDecompressedStream(new SvMemoryStream()); if (aCodecGZ.AttemptDecompression(*pInStream, *pDecompressedStream)) { - uno::Reference<io::XStream> xStreamDecompressed(new utl::OStreamWrapper(*pDecompressedStream)); - pDecompressedStream.release(); + uno::Reference<io::XStream> xStreamDecompressed(new utl::OStreamWrapper(std::move(pDecompressedStream))); aMediaDesc[MediaDescriptor::PROP_STREAM()] <<= xStreamDecompressed; aMediaDesc[MediaDescriptor::PROP_INPUTSTREAM()] <<= xStreamDecompressed->getInputStream(); OUString aURL = aMediaDesc.getUnpackedValueOrDefault(MediaDescriptor::PROP_URL(), OUString() ); diff --git a/package/source/zippackage/ZipPackageStream.cxx b/package/source/zippackage/ZipPackageStream.cxx index 5fe4d0ef80c5..5e62b8bf1aff 100644 --- a/package/source/zippackage/ZipPackageStream.cxx +++ b/package/source/zippackage/ZipPackageStream.cxx @@ -727,10 +727,9 @@ bool ZipPackageStream::saveChild( if ( m_bRawStream ) xStream->skipBytes( m_nMagicalHackPos ); - ZipOutputStream::setEntry(pTempEntry); - rZipOut.writeLOC(pTempEntry); // the entry is provided to the ZipOutputStream that will delete it - pAutoTempEntry.release(); + ZipOutputStream::setEntry(pAutoTempEntry.release()); + rZipOut.writeLOC(pTempEntry); uno::Sequence < sal_Int8 > aSeq ( n_ConstBufferSize ); sal_Int32 nLength; @@ -797,9 +796,8 @@ bool ZipPackageStream::saveChild( try { - ZipOutputStream::setEntry(pTempEntry); // the entry is provided to the ZipOutputStream that will delete it - pAutoTempEntry.release(); + ZipOutputStream::setEntry(pAutoTempEntry.release()); if (pTempEntry->nMethod == STORED) { diff --git a/registry/source/regimpl.cxx b/registry/source/regimpl.cxx index a7647b9d512f..ac065a3e65a3 100644 --- a/registry/source/regimpl.cxx +++ b/registry/source/regimpl.cxx @@ -700,8 +700,7 @@ RegError ORegistry::openKey(RegKeyHandle hKey, const OUString& keyName, } std::unique_ptr< ORegKey > p(new ORegKey(path, this)); - i = m_openKeyTable.insert(std::make_pair(path, p.get())).first; - p.release(); + i = m_openKeyTable.insert(std::make_pair(path, p.release())).first; } else { i->second->acquire(); } diff --git a/sd/source/ui/tools/SdGlobalResourceContainer.cxx b/sd/source/ui/tools/SdGlobalResourceContainer.cxx index b6408cdf04be..26ec1df742db 100644 --- a/sd/source/ui/tools/SdGlobalResourceContainer.cxx +++ b/sd/source/ui/tools/SdGlobalResourceContainer.cxx @@ -99,7 +99,7 @@ void SdGlobalResourceContainer::AddResource ( mpImpl->maResources.end(), pResource.get()); if (iResource == mpImpl->maResources.end()) - mpImpl->maResources.push_back(pResource.get()); + mpImpl->maResources.push_back(pResource.release()); else { // Because the given resource is a unique_ptr it is highly unlikely @@ -107,9 +107,6 @@ void SdGlobalResourceContainer::AddResource ( SAL_WARN ( "sd.tools", "SdGlobalResourceContainer:AddResource(): Resource added twice."); } - // We can not put the unique_ptr into the vector so we release the - // unique_ptr and document that we take ownership explicitly. - pResource.release(); } void SdGlobalResourceContainer::AddResource ( diff --git a/sw/source/core/crsr/swcrsr.cxx b/sw/source/core/crsr/swcrsr.cxx index 2b934cb6c576..1b74af2faa58 100644 --- a/sw/source/core/crsr/swcrsr.cxx +++ b/sw/source/core/crsr/swcrsr.cxx @@ -964,7 +964,7 @@ sal_uLong SwCursor::FindAll( SwFindParas& rParas, { // put cursor as copy of current into ring // chaining points always to first created, so forward - std::unique_ptr< SwCursor > pSav( Create( this ) ); // save the current cursor + SwCursor* pSav = Create( this ); // save the current cursor // if already outside of body text search from this position or start at // 1. base section @@ -995,7 +995,6 @@ sal_uLong SwCursor::FindAll( SwFindParas& rParas, DeleteMark(); return 0; } - pSav.release(); if( !( FindRanges::InSelAll & eFndRngs )) { @@ -1021,7 +1020,7 @@ sal_uLong SwCursor::FindAll( SwFindParas& rParas, } else if( FindRanges::InSelAll & eFndRngs ) { - std::unique_ptr< SwCursor> pSav( Create( this ) ); // save the current cursor + SwCursor* pSav = Create( this ); // save the current cursor const SwNode* pSttNd = ( FindRanges::InBodyOnly & eFndRngs ) ? rNds.GetEndOfContent().StartOfSectionNode() @@ -1048,7 +1047,6 @@ sal_uLong SwCursor::FindAll( SwFindParas& rParas, DeleteMark(); return 0; } - pSav.release(); while( GetNext() != this ) delete GetNext(); diff --git a/ucb/source/ucp/webdav-neon/DAVSessionFactory.cxx b/ucb/source/ucp/webdav-neon/DAVSessionFactory.cxx index 434c924d5932..b49a2cad68f1 100644 --- a/ucb/source/ucp/webdav-neon/DAVSessionFactory.cxx +++ b/ucb/source/ucp/webdav-neon/DAVSessionFactory.cxx @@ -70,9 +70,8 @@ rtl::Reference< DAVSession > DAVSessionFactory::createDAVSession( std::unique_ptr< DAVSession > xElement( new NeonSession( this, inUri, rFlags, *m_xProxyDecider.get() ) ); - aIt = m_aMap.emplace( inUri, xElement.get() ).first; + aIt = m_aMap.emplace( inUri, xElement.release() ).first; aIt->second->m_aContainerIt = aIt; - xElement.release(); return aIt->second; } else if ( osl_atomic_increment( &aIt->second->m_nRefCount ) > 1 ) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits