summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Sherlock <chris.sherlock79@gmail.com>2017-06-24 13:09:03 +1000
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-06-25 11:52:41 +0200
commit7c6ccc424eec53cac72a9fc81913f6ad780d91aa (patch)
treeb26a7ebcac0e34943d4c2e02c77462f6782d37ef
parentb376eec5c70b5fced2e2bdc205191381b66948a7 (diff)
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@collabora.co.uk> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--sal/osl/unx/file.cxx13
-rw-r--r--sal/osl/w32/file.cxx20
2 files changed, 19 insertions, 14 deletions
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;