diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2022-07-18 11:28:34 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2022-07-18 13:09:51 +0200 |
commit | fd2e907e448991e5c8b54acbe7e31bff24c8e875 (patch) | |
tree | fb5fcca1568589e4f430259ae3f451bf7eaf148b /package | |
parent | aaebfb9baf53e4ed221a9bb8e1772fcbb7b921ab (diff) |
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 <sbergman@redhat.com>
Diffstat (limited to 'package')
-rw-r--r-- | package/source/xstor/owriteablestream.cxx | 12 | ||||
-rw-r--r-- | package/source/xstor/owriteablestream.hxx | 2 |
2 files changed, 8 insertions, 6 deletions
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 <memory> #include <sal/config.h> + +#include <cassert> +#include <memory> #include <sal/log.hxx> #include <com/sun/star/packages/NoEncryptionException.hpp> @@ -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<sal_Int8> 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; }; |