summaryrefslogtreecommitdiff
path: root/comphelper
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-07-11 09:57:47 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-07-11 12:55:47 +0200
commit00850e3fa71cc9ebeacad65f54a98b9a79a8b183 (patch)
tree69fef16ff20bb6e8b74d093bb3a31201bb72ceb8 /comphelper
parentce795510d3de7beb6bcd39954280bc3b5778ec6e (diff)
clean up UNO available() implementations
There seems to be some confusion here. available() is actually the number of bytes that can be read without blocking, but most implementations seems to be just returning the number of bytes remaining in the stream. Since we're doing that, let's do it properly. (*) some of them were just casting, instead of clamping, which will return wrong values sometimes. (*) FileStreamWrapper_Impl/OInputStreamWrapper/OTempFileService were doing unnecessary work, instead of just asking the underlying SvStream for it's remaining size Change-Id: I3ef26e0363e989ed3e00be0fdb993e1cdeb7819f Reviewed-on: https://gerrit.libreoffice.org/57264 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'comphelper')
-rw-r--r--comphelper/source/streaming/memorystream.cxx2
-rw-r--r--comphelper/source/streaming/oslfile2streamwrap.cxx3
2 files changed, 2 insertions, 3 deletions
diff --git a/comphelper/source/streaming/memorystream.cxx b/comphelper/source/streaming/memorystream.cxx
index b85701c30321..39b2fa0a63c5 100644
--- a/comphelper/source/streaming/memorystream.cxx
+++ b/comphelper/source/streaming/memorystream.cxx
@@ -150,7 +150,7 @@ void SAL_CALL UNOMemoryStream::skipBytes( sal_Int32 nBytesToSkip )
sal_Int32 SAL_CALL UNOMemoryStream::available()
{
- return static_cast< sal_Int32 >( maData.size() ) - mnCursor;
+ return std::min<sal_Int64>( SAL_MAX_INT32, maData.size() - mnCursor);
}
void SAL_CALL UNOMemoryStream::closeInput()
diff --git a/comphelper/source/streaming/oslfile2streamwrap.cxx b/comphelper/source/streaming/oslfile2streamwrap.cxx
index 342c4a907e08..198ff1ecea12 100644
--- a/comphelper/source/streaming/oslfile2streamwrap.cxx
+++ b/comphelper/source/streaming/oslfile2streamwrap.cxx
@@ -120,8 +120,7 @@ sal_Int32 SAL_CALL OSLInputStreamWrapper::available()
eError = m_pFile->setPos(osl_Pos_Absolut, nPos);
if (eError != FileBase::E_None)
throw css::io::NotConnectedException(OUString(),static_cast<css::uno::XWeak*>(this));
- return sal::static_int_cast< sal_Int32 >(
- std::max(nAvailable, sal::static_int_cast< sal_uInt64 >(SAL_MAX_INT32)));
+ return std::min<sal_Int64>(nAvailable, SAL_MAX_INT32);
}