summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Sherlock <chris.sherlock79@gmail.com>2017-07-21 17:18:09 +1000
committerChris Sherlock <chris.sherlock79@gmail.com>2017-07-22 20:08:48 +0200
commit5a883e94f372da0cb2340df5af8cf9b8bc54fc74 (patch)
tree6db815c63000ba74f6f691e6e9c3f27ce48d8230
parente468d9d2e1ef1eda7449787cbb907e83aec0162a (diff)
osl: Windows pipe converted from OSL_ASSERT to assert/SAL_WARNs
Explanation for each conversion: - osl_acceptPipe() - don't worry about an invalid oslPipe sent as function parameter, we check for the error returned by ConnectNamedPipe(), and without a valid pipe we just need to return nullptr - warn if INVALID_HANDLE_VALUE for the file handle, should be handled by ConnectNamedPipe() - createPipeImpl() allocates and initializes memory for the oslPipeImpl structure, if it can't do this then something has been done wrongly - osl_receivePipe() - invalid pipe needs to assert because ResetEvent needs valid pPipe->m_ReadEvent - osl_sendPipe() - invalid pipe needs to assert because ResetEvent needs valid pPipe->m_ReadEvent - osl_writePipe() - really just a thin wrapper around osl_sendPipe() - osl_readPipe() - really just a thin wrapper around osl_receivePipe() Change-Id: I581f8aa996375a8691eafaa384d3f63f0c92b0a2 Reviewed-on: https://gerrit.libreoffice.org/40262 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Chris Sherlock <chris.sherlock79@gmail.com>
-rw-r--r--sal/osl/w32/pipe.cxx23
1 files changed, 13 insertions, 10 deletions
diff --git a/sal/osl/w32/pipe.cxx b/sal/osl/w32/pipe.cxx
index 29bfcb77e756..218719322e27 100644
--- a/sal/osl/w32/pipe.cxx
+++ b/sal/osl/w32/pipe.cxx
@@ -17,8 +17,6 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include <string.h>
-
#include "system.h"
#include <osl/pipe.h>
@@ -28,9 +26,11 @@
#include <osl/conditn.h>
#include <osl/interlck.h>
#include <osl/process.h>
-
#include <rtl/alloc.h>
+#include <cassert>
+#include <string.h>
+
#define PIPESYSTEM "\\\\.\\pipe\\"
#define PIPEPREFIX "OSL_PIPE_"
@@ -288,8 +288,11 @@ oslPipe SAL_CALL osl_acceptPipe(oslPipe pPipe)
rtl_uString* path = nullptr;
rtl_uString* temp = nullptr;
- OSL_ASSERT(pPipe);
- OSL_ASSERT(pPipe->m_File != INVALID_HANDLE_VALUE);
+ SAL_WARN_IF(!pPipe, "sal.osl.pipe", "osl_acceptPipe: invalid pipe");
+ if (!pPipe)
+ return nullptr;
+
+ SAL_WARN_IF(pPipe->m_File == INVALID_HANDLE_VALUE, "sal.osl.pipe", "osl_acceptPipe: invalid handle");
memset(&os, 0, sizeof(OVERLAPPED));
os.hEvent = pPipe->m_AcceptEvent;
@@ -330,7 +333,7 @@ oslPipe SAL_CALL osl_acceptPipe(oslPipe pPipe)
}
pAcceptedPipe = osl_createPipeImpl();
- OSL_ASSERT(pAcceptedPipe);
+ assert(pAcceptedPipe); // should never be the case that an oslPipe cannot be initialized
osl_atomic_increment(&(pAcceptedPipe->m_Reference));
rtl_uString_assign(&pAcceptedPipe->m_Name, pPipe->m_Name);
@@ -361,7 +364,7 @@ sal_Int32 SAL_CALL osl_receivePipe(oslPipe pPipe,
DWORD nBytes;
OVERLAPPED os;
- OSL_ASSERT(pPipe);
+ assert(pPipe);
memset(&os, 0, sizeof(OVERLAPPED));
os.hEvent = pPipe->m_ReadEvent;
@@ -399,7 +402,7 @@ sal_Int32 SAL_CALL osl_sendPipe(oslPipe pPipe,
DWORD nBytes;
OVERLAPPED os;
- OSL_ASSERT(pPipe);
+ assert(pPipe);
memset(&os, 0, sizeof(OVERLAPPED));
os.hEvent = pPipe->m_WriteEvent;
@@ -426,7 +429,7 @@ sal_Int32 SAL_CALL osl_writePipe(oslPipe pPipe, const void *pBuffer , sal_Int32
sal_Int32 BytesSend = 0;
sal_Int32 BytesToSend = n;
- OSL_ASSERT(pPipe);
+ SAL_WARN_IF(!pPipe, "sal.osl.pipe", "osl_writePipe: invalid pipe");
while (BytesToSend > 0)
{
sal_Int32 RetVal;
@@ -451,7 +454,7 @@ sal_Int32 SAL_CALL osl_readPipe(oslPipe pPipe, void *pBuffer, sal_Int32 n)
sal_Int32 BytesRead = 0;
sal_Int32 BytesToRead = n;
- OSL_ASSERT(pPipe);
+ SAL_WARN_IF(!pPipe, "sal.osl.pipe", "osl_readPipe: invalid pipe");
while (BytesToRead > 0)
{
sal_Int32 RetVal;