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( ...@@ -701,8 +701,9 @@ SvTreeListEntry* TreeListBox::AddEntry(
{ {
SvTreeListEntry* p = InsertEntry( SvTreeListEntry* p = InsertEntry(
rText, rImage, rImage, pParent, bChildrenOnDemand, TREELIST_APPEND, rText, rImage, rImage, pParent, bChildrenOnDemand, TREELIST_APPEND,
aUserData.release() aUserData.get()
); );
aUserData.release();
return p; return p;
} }
......
...@@ -335,8 +335,9 @@ void Reader::readMessage(Unmarshal & unmarshal) { ...@@ -335,8 +335,9 @@ void Reader::readMessage(Unmarshal & unmarshal) {
bridge_->incrementActiveCalls(); bridge_->incrementActiveCalls();
} }
uno_threadpool_putJob( uno_threadpool_putJob(
bridge_->getThreadPool(), tid.getHandle(), req.release(), &request, bridge_->getThreadPool(), tid.getHandle(), req.get(), &request,
!synchronous); !synchronous);
req.release();
} }
} }
...@@ -442,8 +443,9 @@ void Reader::readReplyMessage(Unmarshal & unmarshal, sal_uInt8 flags1) { ...@@ -442,8 +443,9 @@ 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.release(), nullptr, bridge_->getThreadPool(), tid.getHandle(), resp.get(), nullptr,
false); false);
resp.release();
break; break;
} }
case OutgoingRequest::KIND_REQUEST_CHANGE: case OutgoingRequest::KIND_REQUEST_CHANGE:
......
...@@ -764,7 +764,8 @@ void handleEnumType( ...@@ -764,7 +764,8 @@ 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.release()); blocks.push_back(blockCode.get());
blockCode.release();
} }
code->instrTableswitch(defCode.get(), min, blocks); code->instrTableswitch(defCode.get(), min, blocks);
for (ClassFile::Code *p : blocks) for (ClassFile::Code *p : blocks)
...@@ -782,7 +783,8 @@ void handleEnumType( ...@@ -782,7 +783,8 @@ 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.release()); blocks.emplace_back(pair.first, blockCode.get());
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)
......
...@@ -727,9 +727,10 @@ bool ZipPackageStream::saveChild( ...@@ -727,9 +727,10 @@ bool ZipPackageStream::saveChild(
if ( m_bRawStream ) if ( m_bRawStream )
xStream->skipBytes( m_nMagicalHackPos ); xStream->skipBytes( m_nMagicalHackPos );
// the entry is provided to the ZipOutputStream that will delete it ZipOutputStream::setEntry(pTempEntry);
ZipOutputStream::setEntry(pAutoTempEntry.release());
rZipOut.writeLOC(pTempEntry); rZipOut.writeLOC(pTempEntry);
// the entry is provided to the ZipOutputStream that will delete it
pAutoTempEntry.release();
uno::Sequence < sal_Int8 > aSeq ( n_ConstBufferSize ); uno::Sequence < sal_Int8 > aSeq ( n_ConstBufferSize );
sal_Int32 nLength; sal_Int32 nLength;
...@@ -796,8 +797,9 @@ bool ZipPackageStream::saveChild( ...@@ -796,8 +797,9 @@ 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
ZipOutputStream::setEntry(pAutoTempEntry.release()); pAutoTempEntry.release();
if (pTempEntry->nMethod == STORED) if (pTempEntry->nMethod == STORED)
{ {
......
...@@ -700,7 +700,8 @@ RegError ORegistry::openKey(RegKeyHandle hKey, const OUString& keyName, ...@@ -700,7 +700,8 @@ 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.release())).first; i = m_openKeyTable.insert(std::make_pair(path, p.get())).first;
p.release();
} else { } else {
i->second->acquire(); i->second->acquire();
} }
......
...@@ -99,7 +99,7 @@ void SdGlobalResourceContainer::AddResource ( ...@@ -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.release()); mpImpl->maResources.push_back(pResource.get());
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,6 +107,9 @@ void SdGlobalResourceContainer::AddResource ( ...@@ -107,6 +107,9 @@ 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 (
......
...@@ -70,8 +70,9 @@ rtl::Reference< DAVSession > DAVSessionFactory::createDAVSession( ...@@ -70,8 +70,9 @@ 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.release() ).first; aIt = m_aMap.emplace( inUri, xElement.get() ).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 )
......
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