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.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin 2018-09-07 15:47:40 +02:00
parent 37d5bf82ea
commit 7764ae70b0
9 changed files with 14 additions and 29 deletions

View file

@ -701,9 +701,8 @@ SvTreeListEntry* TreeListBox::AddEntry(
{ {
SvTreeListEntry* p = InsertEntry( SvTreeListEntry* p = InsertEntry(
rText, rImage, rImage, pParent, bChildrenOnDemand, TREELIST_APPEND, rText, rImage, rImage, pParent, bChildrenOnDemand, TREELIST_APPEND,
aUserData.get() aUserData.release()
); );
aUserData.release();
return p; return p;
} }

View file

@ -335,9 +335,8 @@ void Reader::readMessage(Unmarshal & unmarshal) {
bridge_->incrementActiveCalls(); bridge_->incrementActiveCalls();
} }
uno_threadpool_putJob( uno_threadpool_putJob(
bridge_->getThreadPool(), tid.getHandle(), req.get(), &request, bridge_->getThreadPool(), tid.getHandle(), req.release(), &request,
!synchronous); !synchronous);
req.release();
} }
} }
@ -443,9 +442,8 @@ void Reader::readReplyMessage(Unmarshal & unmarshal, sal_uInt8 flags1) {
std::unique_ptr< IncomingReply > resp( std::unique_ptr< IncomingReply > resp(
new IncomingReply(exc, ret, outArgs)); new IncomingReply(exc, ret, outArgs));
uno_threadpool_putJob( uno_threadpool_putJob(
bridge_->getThreadPool(), tid.getHandle(), resp.get(), nullptr, bridge_->getThreadPool(), tid.getHandle(), resp.release(), nullptr,
false); false);
resp.release();
break; break;
} }
case OutgoingRequest::KIND_REQUEST_CHANGE: case OutgoingRequest::KIND_REQUEST_CHANGE:

View file

@ -764,8 +764,7 @@ void handleEnumType(
std::unique_ptr< ClassFile::Code > blockCode(cf->newCode()); std::unique_ptr< ClassFile::Code > blockCode(cf->newCode());
blockCode->instrGetstatic(className, pair.second, classDescriptor); blockCode->instrGetstatic(className, pair.second, classDescriptor);
blockCode->instrAreturn(); blockCode->instrAreturn();
blocks.push_back(blockCode.get()); blocks.push_back(blockCode.release());
blockCode.release();
} }
code->instrTableswitch(defCode.get(), min, blocks); code->instrTableswitch(defCode.get(), min, blocks);
for (ClassFile::Code *p : blocks) for (ClassFile::Code *p : blocks)
@ -783,8 +782,7 @@ void handleEnumType(
std::unique_ptr< ClassFile::Code > blockCode(cf->newCode()); std::unique_ptr< ClassFile::Code > blockCode(cf->newCode());
blockCode->instrGetstatic(className, pair.second, classDescriptor); blockCode->instrGetstatic(className, pair.second, classDescriptor);
blockCode->instrAreturn(); blockCode->instrAreturn();
blocks.emplace_back(pair.first, blockCode.get()); blocks.emplace_back(pair.first, blockCode.release());
blockCode.release();
} }
code->instrLookupswitch(defCode.get(), blocks); code->instrLookupswitch(defCode.get(), blocks);
for (const std::pair< sal_Int32, ClassFile::Code * >& pair : blocks) for (const std::pair< sal_Int32, ClassFile::Code * >& pair : blocks)

View file

@ -171,8 +171,7 @@ OUString SAL_CALL PlainTextFilterDetect::detect(uno::Sequence<beans::PropertyVal
std::unique_ptr<SvMemoryStream> pDecompressedStream(new SvMemoryStream()); std::unique_ptr<SvMemoryStream> pDecompressedStream(new SvMemoryStream());
if (aCodecGZ.AttemptDecompression(*pInStream, *pDecompressedStream)) if (aCodecGZ.AttemptDecompression(*pInStream, *pDecompressedStream))
{ {
uno::Reference<io::XStream> xStreamDecompressed(new utl::OStreamWrapper(*pDecompressedStream)); uno::Reference<io::XStream> xStreamDecompressed(new utl::OStreamWrapper(std::move(pDecompressedStream)));
pDecompressedStream.release();
aMediaDesc[MediaDescriptor::PROP_STREAM()] <<= xStreamDecompressed; aMediaDesc[MediaDescriptor::PROP_STREAM()] <<= xStreamDecompressed;
aMediaDesc[MediaDescriptor::PROP_INPUTSTREAM()] <<= xStreamDecompressed->getInputStream(); aMediaDesc[MediaDescriptor::PROP_INPUTSTREAM()] <<= xStreamDecompressed->getInputStream();
OUString aURL = aMediaDesc.getUnpackedValueOrDefault(MediaDescriptor::PROP_URL(), OUString() ); OUString aURL = aMediaDesc.getUnpackedValueOrDefault(MediaDescriptor::PROP_URL(), OUString() );

View file

@ -727,10 +727,9 @@ bool ZipPackageStream::saveChild(
if ( m_bRawStream ) if ( m_bRawStream )
xStream->skipBytes( m_nMagicalHackPos ); xStream->skipBytes( m_nMagicalHackPos );
ZipOutputStream::setEntry(pTempEntry);
rZipOut.writeLOC(pTempEntry);
// the entry is provided to the ZipOutputStream that will delete it // 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 ); uno::Sequence < sal_Int8 > aSeq ( n_ConstBufferSize );
sal_Int32 nLength; sal_Int32 nLength;
@ -797,9 +796,8 @@ bool ZipPackageStream::saveChild(
try try
{ {
ZipOutputStream::setEntry(pTempEntry);
// the entry is provided to the ZipOutputStream that will delete it // the entry is provided to the ZipOutputStream that will delete it
pAutoTempEntry.release(); ZipOutputStream::setEntry(pAutoTempEntry.release());
if (pTempEntry->nMethod == STORED) if (pTempEntry->nMethod == STORED)
{ {

View file

@ -700,8 +700,7 @@ RegError ORegistry::openKey(RegKeyHandle hKey, const OUString& keyName,
} }
std::unique_ptr< ORegKey > p(new ORegKey(path, this)); std::unique_ptr< ORegKey > p(new ORegKey(path, this));
i = m_openKeyTable.insert(std::make_pair(path, p.get())).first; i = m_openKeyTable.insert(std::make_pair(path, p.release())).first;
p.release();
} else { } else {
i->second->acquire(); i->second->acquire();
} }

View file

@ -99,7 +99,7 @@ void SdGlobalResourceContainer::AddResource (
mpImpl->maResources.end(), mpImpl->maResources.end(),
pResource.get()); pResource.get());
if (iResource == mpImpl->maResources.end()) if (iResource == mpImpl->maResources.end())
mpImpl->maResources.push_back(pResource.get()); mpImpl->maResources.push_back(pResource.release());
else else
{ {
// Because the given resource is a unique_ptr it is highly unlikely // Because the given resource is a unique_ptr it is highly unlikely
@ -107,9 +107,6 @@ void SdGlobalResourceContainer::AddResource (
SAL_WARN ( "sd.tools", SAL_WARN ( "sd.tools",
"SdGlobalResourceContainer:AddResource(): Resource added twice."); "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 ( void SdGlobalResourceContainer::AddResource (

View file

@ -964,7 +964,7 @@ sal_uLong SwCursor::FindAll( SwFindParas& rParas,
{ {
// put cursor as copy of current into ring // put cursor as copy of current into ring
// chaining points always to first created, so forward // 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 // if already outside of body text search from this position or start at
// 1. base section // 1. base section
@ -995,7 +995,6 @@ sal_uLong SwCursor::FindAll( SwFindParas& rParas,
DeleteMark(); DeleteMark();
return 0; return 0;
} }
pSav.release();
if( !( FindRanges::InSelAll & eFndRngs )) if( !( FindRanges::InSelAll & eFndRngs ))
{ {
@ -1021,7 +1020,7 @@ sal_uLong SwCursor::FindAll( SwFindParas& rParas,
} }
else if( FindRanges::InSelAll & eFndRngs ) 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 ) const SwNode* pSttNd = ( FindRanges::InBodyOnly & eFndRngs )
? rNds.GetEndOfContent().StartOfSectionNode() ? rNds.GetEndOfContent().StartOfSectionNode()
@ -1048,7 +1047,6 @@ sal_uLong SwCursor::FindAll( SwFindParas& rParas,
DeleteMark(); DeleteMark();
return 0; return 0;
} }
pSav.release();
while( GetNext() != this ) while( GetNext() != this )
delete GetNext(); delete GetNext();

View file

@ -70,9 +70,8 @@ rtl::Reference< DAVSession > DAVSessionFactory::createDAVSession(
std::unique_ptr< DAVSession > xElement( std::unique_ptr< DAVSession > xElement(
new NeonSession( this, inUri, rFlags, *m_xProxyDecider.get() ) ); 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; aIt->second->m_aContainerIt = aIt;
xElement.release();
return aIt->second; return aIt->second;
} }
else if ( osl_atomic_increment( &aIt->second->m_nRefCount ) > 1 ) else if ( osl_atomic_increment( &aIt->second->m_nRefCount ) > 1 )