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>
This commit is contained in:
parent
e0f990b96f
commit
fa987cbb81
1 changed files with 9 additions and 9 deletions
|
@ -31,6 +31,8 @@
|
||||||
#include "sockimpl.hxx"
|
#include "sockimpl.hxx"
|
||||||
#include "secimpl.hxx"
|
#include "secimpl.hxx"
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
#define PIPEDEFAULTPATH "/tmp"
|
#define PIPEDEFAULTPATH "/tmp"
|
||||||
#define PIPEALTERNATEPATH "/var/tmp"
|
#define PIPEALTERNATEPATH "/var/tmp"
|
||||||
|
|
||||||
|
@ -397,11 +399,11 @@ oslPipe SAL_CALL osl_acceptPipe(oslPipe pPipe)
|
||||||
int s;
|
int s;
|
||||||
oslPipe pAcceptedPipe;
|
oslPipe pAcceptedPipe;
|
||||||
|
|
||||||
OSL_ASSERT(pPipe);
|
SAL_WARN_IF(!pPipe, "sal.osl.pipe", "invalid pipe");
|
||||||
if (!pPipe)
|
if (!pPipe)
|
||||||
return nullptr;
|
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)
|
#if defined(CLOSESOCKET_DOESNT_WAKE_UP_ACCEPT)
|
||||||
pPipe->m_bIsAccepting = true;
|
pPipe->m_bIsAccepting = true;
|
||||||
|
@ -430,7 +432,7 @@ oslPipe SAL_CALL osl_acceptPipe(oslPipe pPipe)
|
||||||
/* alloc memory */
|
/* alloc memory */
|
||||||
pAcceptedPipe = createPipeImpl();
|
pAcceptedPipe = createPipeImpl();
|
||||||
|
|
||||||
OSL_ASSERT(pAcceptedPipe);
|
assert(pAcceptedPipe); // should never be the case that an oslPipe cannot be initialized
|
||||||
if (!pAcceptedPipe)
|
if (!pAcceptedPipe)
|
||||||
{
|
{
|
||||||
close(s);
|
close(s);
|
||||||
|
@ -457,8 +459,7 @@ sal_Int32 SAL_CALL osl_receivePipe(oslPipe pPipe,
|
||||||
{
|
{
|
||||||
int nRet = 0;
|
int nRet = 0;
|
||||||
|
|
||||||
OSL_ASSERT(pPipe);
|
SAL_WARN_IF(!pPipe, "sal.osl.pipe", "osl_receivePipe: invalid pipe");
|
||||||
|
|
||||||
if (!pPipe)
|
if (!pPipe)
|
||||||
{
|
{
|
||||||
SAL_WARN("sal.osl.pipe", "osl_receivePipe: Invalid socket");
|
SAL_WARN("sal.osl.pipe", "osl_receivePipe: Invalid socket");
|
||||||
|
@ -480,8 +481,7 @@ sal_Int32 SAL_CALL osl_sendPipe(oslPipe pPipe,
|
||||||
{
|
{
|
||||||
int nRet=0;
|
int nRet=0;
|
||||||
|
|
||||||
OSL_ASSERT(pPipe);
|
SAL_WARN_IF(!pPipe, "sal.osl.pipe", "osl_sendPipe: invalid pipe");
|
||||||
|
|
||||||
if (!pPipe)
|
if (!pPipe)
|
||||||
{
|
{
|
||||||
SAL_WARN("sal.osl.pipe", "osl_sendPipe: Invalid socket");
|
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 BytesSend = 0;
|
||||||
sal_Int32 BytesToSend = n;
|
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)
|
while (BytesToSend > 0)
|
||||||
{
|
{
|
||||||
sal_Int32 RetVal;
|
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 BytesRead = 0;
|
||||||
sal_Int32 BytesToRead = n;
|
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)
|
while (BytesToRead > 0)
|
||||||
{
|
{
|
||||||
sal_Int32 RetVal;
|
sal_Int32 RetVal;
|
||||||
|
|
Loading…
Reference in a new issue