Kaydet (Commit) 5a883e94 authored tarafından Chris Sherlock's avatar Chris Sherlock

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/40262Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarChris Sherlock <chris.sherlock79@gmail.com>
üst e468d9d2
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment