[Libreoffice-commits] core.git: sal/osl
Chris Sherlock
chris.sherlock79 at gmail.com
Fri Jul 21 06:56:34 UTC 2017
sal/osl/unx/pipe.cxx | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
New commits:
commit fa987cbb813cfd729fe490f2f1258b7c8d7fb174
Author: Chris Sherlock <chris.sherlock79 at gmail.com>
Date: Sun Jul 16 08:46:19 2017 +1000
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 at gmail.com>
Tested-by: Chris Sherlock <chris.sherlock79 at gmail.com>
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;
More information about the Libreoffice-commits
mailing list