[Libreoffice-commits] core.git: sal/osl
Chris Sherlock
chris.sherlock79 at gmail.com
Sun Jun 25 09:53:02 UTC 2017
sal/osl/unx/file.cxx | 13 +++++++------
sal/osl/w32/file.cxx | 20 ++++++++++++--------
2 files changed, 19 insertions(+), 14 deletions(-)
New commits:
commit 7c6ccc424eec53cac72a9fc81913f6ad780d91aa
Author: Chris Sherlock <chris.sherlock79 at gmail.com>
Date: Sat Jun 24 13:09:03 2017 +1000
tdf#43157 - osl: convert OSL_PRECONDs in w32 & unx file.cxx
Change-Id: Ic914d9240e6b06b7e6550fe311fd69e310254bd5
Reviewed-on: https://gerrit.libreoffice.org/39197
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sal/osl/unx/file.cxx b/sal/osl/unx/file.cxx
index 85ce42135db4..4ed11ec8192f 100644
--- a/sal/osl/unx/file.cxx
+++ b/sal/osl/unx/file.cxx
@@ -190,7 +190,7 @@ FileHandle_Impl::Allocator::Allocator()
size_t const pagesize = FileHandle_Impl::getpagesize();
if (pagesize != size_t(-1))
{
- m_cache = rtl_cache_create (
+ m_cache = rtl_cache_create (
"osl_file_buffer_cache", pagesize, 0, nullptr, nullptr, nullptr, nullptr, nullptr, 0);
if (m_cache != nullptr)
m_bufsiz = pagesize;
@@ -204,7 +204,8 @@ FileHandle_Impl::Allocator::~Allocator()
void FileHandle_Impl::Allocator::allocate (sal_uInt8 ** ppBuffer, size_t * pnSize)
{
- OSL_PRECOND((nullptr != ppBuffer) && (nullptr != pnSize), "FileHandle_Impl::Allocator::allocate(): contract violation");
+ SAL_WARN_IF((!ppBuffer) || (!pnSize), "sal.osl", "FileHandle_Impl::Allocator::allocate(): contract violation");
+ assert(ppBuffer && pnSize);
if ((ppBuffer != nullptr) && (pnSize != nullptr))
{
*ppBuffer = static_cast< sal_uInt8* >(rtl_cache_alloc(m_cache));
@@ -340,11 +341,11 @@ oslFileError FileHandle_Impl::readAt (
size_t nBytesRequested,
sal_uInt64 * pBytesRead)
{
- OSL_PRECOND((m_state & STATE_SEEKABLE), "FileHandle_Impl::readAt(): not seekable");
+ SAL_WARN_IF(!(m_state & STATE_SEEKABLE), "sal.osl", "FileHandle_Impl::readAt(): not seekable");
if (!(m_state & STATE_SEEKABLE))
return osl_File_E_SPIPE;
- OSL_PRECOND((m_state & STATE_READABLE), "FileHandle_Impl::readAt(): not readable");
+ SAL_WARN_IF(!(m_state & STATE_READABLE), "sal.osl", "FileHandle_Impl::readAt(): not readable");
if (!(m_state & STATE_READABLE))
return osl_File_E_BADF;
@@ -388,11 +389,11 @@ oslFileError FileHandle_Impl::writeAt (
size_t nBytesToWrite,
sal_uInt64 * pBytesWritten)
{
- OSL_PRECOND((m_state & STATE_SEEKABLE), "FileHandle_Impl::writeAt(): not seekable");
+ SAL_WARN_IF(!(m_state & STATE_SEEKABLE), "sal.osl", "FileHandle_Impl::writeAt(): not seekable");
if (!(m_state & STATE_SEEKABLE))
return osl_File_E_SPIPE;
- OSL_PRECOND((m_state & STATE_WRITEABLE), "FileHandle_Impl::writeAt(): not writeable");
+ SAL_WARN_IF(!(m_state & STATE_WRITEABLE), "sal.osl", "FileHandle_Impl::writeAt(): not writeable");
if (!(m_state & STATE_WRITEABLE))
return osl_File_E_BADF;
diff --git a/sal/osl/w32/file.cxx b/sal/osl/w32/file.cxx
index b00b15daf18d..a2fea0ce1fed 100644
--- a/sal/osl/w32/file.cxx
+++ b/sal/osl/w32/file.cxx
@@ -178,10 +178,12 @@ FileHandle_Impl::Allocator::~Allocator()
m_cache = nullptr;
}
-void FileHandle_Impl::Allocator::allocate (sal_uInt8 ** ppBuffer, SIZE_T * pnSize)
+void FileHandle_Impl::Allocator::allocate (sal_uInt8 **ppBuffer, SIZE_T * pnSize)
{
- OSL_PRECOND((ppBuffer) && (pnSize), "FileHandle_Impl::Allocator::allocate(): contract violation");
+ SAL_WARN_IF((!ppBuffer) || (!pnSize), "sal.osl", "FileHandle_Impl::Allocator::allocate(): contract violation");
+ assert((ppBuffer) && (pnSize));
*ppBuffer = static_cast< sal_uInt8* >(rtl_cache_alloc(m_cache));
+
*pnSize = m_bufsiz;
}
@@ -194,13 +196,15 @@ void FileHandle_Impl::Allocator::deallocate (sal_uInt8 * pBuffer)
FileHandle_Impl::Guard::Guard(LPCRITICAL_SECTION pMutex)
: m_mutex (pMutex)
{
- OSL_PRECOND (m_mutex != nullptr, "FileHandle_Impl::Guard::Guard(): null pointer.");
+ SAL_WARN_IF(!(m_mutex), "sal.osl", "FileHandle_Impl::Guard::Guard(): null pointer.");
+ assert(m_mutex);
::EnterCriticalSection (m_mutex);
}
FileHandle_Impl::Guard::~Guard()
{
- OSL_PRECOND (m_mutex != nullptr, "FileHandle_Impl::Guard::~Guard(): null pointer.");
+ SAL_WARN_IF(!(m_mutex), "sal.osl", "FileHandle_Impl::Guard::~Guard(): null pointer.");
+ assert(m_mutex);
::LeaveCriticalSection (m_mutex);
}
@@ -285,11 +289,11 @@ oslFileError FileHandle_Impl::readAt(
DWORD nBytesRequested,
sal_uInt64 * pBytesRead)
{
- OSL_PRECOND(m_state & STATE_SEEKABLE, "FileHandle_Impl::readAt(): not seekable");
+ SAL_WARN_IF(!(m_state & STATE_SEEKABLE), "sal.osl", "FileHandle_Impl::readAt(): not seekable");
if (!(m_state & STATE_SEEKABLE))
return osl_File_E_SPIPE;
- OSL_PRECOND(m_state & STATE_READABLE, "FileHandle_Impl::readAt(): not readable");
+ SAL_WARN_IF(!(m_state & STATE_READABLE), "sal.osl", "FileHandle_Impl::readAt(): not readable");
if (!(m_state & STATE_READABLE))
return osl_File_E_BADF;
@@ -316,11 +320,11 @@ oslFileError FileHandle_Impl::writeAt(
DWORD nBytesToWrite,
sal_uInt64 * pBytesWritten)
{
- OSL_PRECOND(m_state & STATE_SEEKABLE, "FileHandle_Impl::writeAt(): not seekable");
+ SAL_WARN_IF(!(m_state & STATE_SEEKABLE), "sal.osl", "FileHandle_Impl::writeAt(): not seekable");
if (!(m_state & STATE_SEEKABLE))
return osl_File_E_SPIPE;
- OSL_PRECOND(m_state & STATE_WRITEABLE, "FileHandle_Impl::writeAt(): not writeable");
+ SAL_WARN_IF(!(m_state & STATE_WRITEABLE), "sal.osl", "FileHandle_Impl::writeAt(): not writeable");
if (!(m_state & STATE_WRITEABLE))
return osl_File_E_BADF;
More information about the Libreoffice-commits
mailing list