summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Sherlock <chris.sherlock79@gmail.com>2017-07-16 08:46:19 +1000
committerChris Sherlock <chris.sherlock79@gmail.com>2017-07-21 08:55:44 +0200
commitfa987cbb813cfd729fe490f2f1258b7c8d7fb174 (patch)
tree84a9ed2e320dd3dfeef12f6671b9ddcff22a0591
parente0f990b96f901be00ba5b7dc6a671e6162c914cf (diff)
osl: Unix 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 an error gets flagged in Unix normally, so it might not be a programming error - definitely assert on an empty name, that's a definite programming error and should never, ever occur - createPipeImpl() allocates and initializes memory for the oslPipeImpl structure, if it can't do this then something has been done wrongly - osl_receivePipe() - invalid oslPipe sent as function parameter might not be a programming error, give a warning but don't assert - osl_sendPipe() - invalid oslPipe sent as function parameter might not be a programming error, give a warning but don't assert - osl_writePipe() - really just a thin wrapper around osl_sendPipe(), which detects and handles invalid pipes - osl_readPipe() - really just a thin wrapper around osl_receivePipe(), which detects and handles invalid pipes Change-Id: I4923265b4c648852743c406b682d43ffb9ac6537 Reviewed-on: https://gerrit.libreoffice.org/40003 Reviewed-by: Chris Sherlock <chris.sherlock79@gmail.com> Tested-by: Chris Sherlock <chris.sherlock79@gmail.com>
-rw-r--r--sal/osl/unx/pipe.cxx18
1 files changed, 9 insertions, 9 deletions
diff --git a/sal/osl/unx/pipe.cxx b/sal/osl/unx/pipe.cxx
index 5909c34001db..bbb47368eff9 100644
--- a/sal/osl/unx/pipe.cxx
+++ b/sal/osl/unx/pipe.cxx
@@ -31,6 +31,8 @@
#include "sockimpl.hxx"
#include "secimpl.hxx"
+#include <cassert>
+
#define PIPEDEFAULTPATH "/tmp"
#define PIPEALTERNATEPATH "/var/tmp"
@@ -397,11 +399,11 @@ oslPipe SAL_CALL osl_acceptPipe(oslPipe pPipe)
int s;
oslPipe pAcceptedPipe;
- OSL_ASSERT(pPipe);
+ SAL_WARN_IF(!pPipe, "sal.osl.pipe", "invalid pipe");
if (!pPipe)
return nullptr;
- OSL_ASSERT(strlen(pPipe->m_Name) > 0);
+ assert(strlen(pPipe->m_Name) > 0); // you cannot have an empty pipe name
#if defined(CLOSESOCKET_DOESNT_WAKE_UP_ACCEPT)
pPipe->m_bIsAccepting = true;
@@ -430,7 +432,7 @@ oslPipe SAL_CALL osl_acceptPipe(oslPipe pPipe)
/* alloc memory */
pAcceptedPipe = createPipeImpl();
- OSL_ASSERT(pAcceptedPipe);
+ assert(pAcceptedPipe); // should never be the case that an oslPipe cannot be initialized
if (!pAcceptedPipe)
{
close(s);
@@ -457,8 +459,7 @@ sal_Int32 SAL_CALL osl_receivePipe(oslPipe pPipe,
{
int nRet = 0;
- OSL_ASSERT(pPipe);
-
+ SAL_WARN_IF(!pPipe, "sal.osl.pipe", "osl_receivePipe: invalid pipe");
if (!pPipe)
{
SAL_WARN("sal.osl.pipe", "osl_receivePipe: Invalid socket");
@@ -480,8 +481,7 @@ sal_Int32 SAL_CALL osl_sendPipe(oslPipe pPipe,
{
int nRet=0;
- OSL_ASSERT(pPipe);
-
+ SAL_WARN_IF(!pPipe, "sal.osl.pipe", "osl_sendPipe: invalid pipe");
if (!pPipe)
{
SAL_WARN("sal.osl.pipe", "osl_sendPipe: Invalid socket");
@@ -508,7 +508,7 @@ sal_Int32 SAL_CALL osl_writePipe(oslPipe pPipe, const void *pBuffer, sal_Int32 n
sal_Int32 BytesSend = 0;
sal_Int32 BytesToSend = n;
- OSL_ASSERT(pPipe);
+ SAL_WARN_IF(!pPipe, "sal.osl.pipe", "osl_writePipe: invalid pipe"); // osl_sendPipe detects invalid pipe
while (BytesToSend > 0)
{
sal_Int32 RetVal;
@@ -533,7 +533,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"); // osl_receivePipe detects invalid pipe
while (BytesToRead > 0)
{
sal_Int32 RetVal;