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(
rText, rImage, rImage, pParent, bChildrenOnDemand, TREELIST_APPEND,
aUserData.get()
aUserData.release()
);
aUserData.release();
return p;
}

View file

@ -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:

View file

@ -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)

View file

@ -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() );

View file

@ -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)
{

View file

@ -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();
}

View file

@ -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 (

View file

@ -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();

View file

@ -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 )