Kaydet (Commit) bb209f2f authored tarafından Noel Grandin's avatar Noel Grandin

Revert "clang bugprone-unused-return-value"

comment from sberg:
  aren't these changes broken in general, when the called function
  may throw an exception before it takes ownership of the passed-in pointer?

So revert, except for
  (a) PlainTextFilterDetect::detect, which was definitely a leak
  (b) SwCursor::FindAll, where unique_ptr was being unnecessarily used

This reverts commit 7764ae70.

Change-Id: I555e651b44e245b031729013d2ce88d26e8a357e
Reviewed-on: https://gerrit.libreoffice.org/60301Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
Tested-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst a1949a41
......@@ -701,8 +701,9 @@ SvTreeListEntry* TreeListBox::AddEntry(
{
SvTreeListEntry* p = InsertEntry(
rText, rImage, rImage, pParent, bChildrenOnDemand, TREELIST_APPEND,
aUserData.release()
aUserData.get()
);
aUserData.release();
return p;
}
......
......@@ -335,8 +335,9 @@ void Reader::readMessage(Unmarshal & unmarshal) {
bridge_->incrementActiveCalls();
}
uno_threadpool_putJob(
bridge_->getThreadPool(), tid.getHandle(), req.release(), &request,
bridge_->getThreadPool(), tid.getHandle(), req.get(), &request,
!synchronous);
req.release();
}
}
......@@ -442,8 +443,9 @@ 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.release(), nullptr,
bridge_->getThreadPool(), tid.getHandle(), resp.get(), nullptr,
false);
resp.release();
break;
}
case OutgoingRequest::KIND_REQUEST_CHANGE:
......
......@@ -764,7 +764,8 @@ void handleEnumType(
std::unique_ptr< ClassFile::Code > blockCode(cf->newCode());
blockCode->instrGetstatic(className, pair.second, classDescriptor);
blockCode->instrAreturn();
blocks.push_back(blockCode.release());
blocks.push_back(blockCode.get());
blockCode.release();
}
code->instrTableswitch(defCode.get(), min, blocks);
for (ClassFile::Code *p : blocks)
......@@ -782,7 +783,8 @@ void handleEnumType(
std::unique_ptr< ClassFile::Code > blockCode(cf->newCode());
blockCode->instrGetstatic(className, pair.second, classDescriptor);
blockCode->instrAreturn();
blocks.emplace_back(pair.first, blockCode.release());
blocks.emplace_back(pair.first, blockCode.get());
blockCode.release();
}
code->instrLookupswitch(defCode.get(), blocks);
for (const std::pair< sal_Int32, ClassFile::Code * >& pair : blocks)
......
......@@ -727,9 +727,10 @@ bool ZipPackageStream::saveChild(
if ( m_bRawStream )
xStream->skipBytes( m_nMagicalHackPos );
// the entry is provided to the ZipOutputStream that will delete it
ZipOutputStream::setEntry(pAutoTempEntry.release());
ZipOutputStream::setEntry(pTempEntry);
rZipOut.writeLOC(pTempEntry);
// the entry is provided to the ZipOutputStream that will delete it
pAutoTempEntry.release();
uno::Sequence < sal_Int8 > aSeq ( n_ConstBufferSize );
sal_Int32 nLength;
......@@ -796,8 +797,9 @@ bool ZipPackageStream::saveChild(
try
{
ZipOutputStream::setEntry(pTempEntry);
// the entry is provided to the ZipOutputStream that will delete it
ZipOutputStream::setEntry(pAutoTempEntry.release());
pAutoTempEntry.release();
if (pTempEntry->nMethod == STORED)
{
......
......@@ -700,7 +700,8 @@ 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.release())).first;
i = m_openKeyTable.insert(std::make_pair(path, p.get())).first;
p.release();
} else {
i->second->acquire();
}
......
......@@ -99,7 +99,7 @@ void SdGlobalResourceContainer::AddResource (
mpImpl->maResources.end(),
pResource.get());
if (iResource == mpImpl->maResources.end())
mpImpl->maResources.push_back(pResource.release());
mpImpl->maResources.push_back(pResource.get());
else
{
// Because the given resource is a unique_ptr it is highly unlikely
......@@ -107,6 +107,9 @@ 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 (
......
......@@ -70,8 +70,9 @@ rtl::Reference< DAVSession > DAVSessionFactory::createDAVSession(
std::unique_ptr< DAVSession > xElement(
new NeonSession( this, inUri, rFlags, *m_xProxyDecider.get() ) );
aIt = m_aMap.emplace( inUri, xElement.release() ).first;
aIt = m_aMap.emplace( inUri, xElement.get() ).first;
aIt->second->m_aContainerIt = aIt;
xElement.release();
return aIt->second;
}
else if ( osl_atomic_increment( &aIt->second->m_nRefCount ) > 1 )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment