From fd2e907e448991e5c8b54acbe7e31bff24c8e875 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Mon, 18 Jul 2022 11:28:34 +0200 Subject: comphelper::ByteWriter::writeSomeBytes always writes all bytes ...so rename it to writeBytes for clarity, and drop the redundant return value. Also clarify that it has a narrow interface and requires nBytesToWrite to be non-negative. Change-Id: I76dee83fecd6350f473f55dcffb950c16aa22d93 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137169 Tested-by: Jenkins Reviewed-by: Stephan Bergmann --- package/source/xstor/owriteablestream.cxx | 12 +++++++----- package/source/xstor/owriteablestream.hxx | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'package/source') diff --git a/package/source/xstor/owriteablestream.cxx b/package/source/xstor/owriteablestream.cxx index 6ecdb35b848f..e380d971c770 100644 --- a/package/source/xstor/owriteablestream.cxx +++ b/package/source/xstor/owriteablestream.cxx @@ -17,8 +17,10 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include #include + +#include +#include #include #include @@ -2099,8 +2101,10 @@ void SAL_CALL OWriteStream::writeBytes( const uno::Sequence< sal_Int8 >& aData ) ModifyParentUnlockMutex_Impl( aGuard ); } -sal_Int32 OWriteStream::writeSomeBytes( const sal_Int8* pData, sal_Int32 nBytesToWrite ) +void OWriteStream::writeBytes( const sal_Int8* pData, sal_Int32 nBytesToWrite ) { + assert(nBytesToWrite >= 0); + osl::ClearableMutexGuard aGuard(m_pData->m_xSharedMutex->GetMutex()); // the write method makes initialization itself, since it depends from the aData length @@ -2162,7 +2166,7 @@ sal_Int32 OWriteStream::writeSomeBytes( const sal_Int8* pData, sal_Int32 nBytesT if (xOutputTunnel) pByteWriter = reinterpret_cast< comphelper::ByteWriter* >( xOutputTunnel->getSomething( comphelper::ByteWriter::getUnoTunnelId() ) ); if (pByteWriter) - nBytesToWrite = pByteWriter->writeSomeBytes(pData, nBytesToWrite); + pByteWriter->writeBytes(pData, nBytesToWrite); else { uno::Sequence aData(pData, nBytesToWrite); @@ -2171,8 +2175,6 @@ sal_Int32 OWriteStream::writeSomeBytes( const sal_Int8* pData, sal_Int32 nBytesT m_pImpl->m_bHasDataToFlush = true; ModifyParentUnlockMutex_Impl( aGuard ); - - return nBytesToWrite; } sal_Int64 SAL_CALL OWriteStream::getSomething( const css::uno::Sequence< sal_Int8 >& rIdentifier ) diff --git a/package/source/xstor/owriteablestream.hxx b/package/source/xstor/owriteablestream.hxx index bd429cb03c2f..9fa6c6ea0e59 100644 --- a/package/source/xstor/owriteablestream.hxx +++ b/package/source/xstor/owriteablestream.hxx @@ -351,7 +351,7 @@ public: virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override; // comphelper::ByteWriter - virtual sal_Int32 writeSomeBytes(const sal_Int8* aData, sal_Int32 nBytesToWrite) override; + virtual void writeBytes(const sal_Int8* aData, sal_Int32 nBytesToWrite) override; }; -- cgit v1.2.3