summaryrefslogtreecommitdiff
path: root/sal/osl/unx/pipe.cxx
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2014-12-19 11:07:02 +0100
committerNoel Grandin <noelgrandin@gmail.com>2014-12-19 13:51:34 +0000
commit2ee336fb556ceb1d7e1ee8017c27539da7fe543b (patch)
tree7332ba839b28f112397104596a601c3506bd5973 /sal/osl/unx/pipe.cxx
parent5712983f18e7cdec16ea20a9b3d94a1586de543e (diff)
fdo#39440 sal: reduce scope of local variables
This addresses some cppcheck warnings. Change-Id: Id5f90757571e76a2c05a4cbd37020e1f6a6b2033 Reviewed-on: https://gerrit.libreoffice.org/13544 Reviewed-by: Noel Grandin <noelgrandin@gmail.com> Tested-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'sal/osl/unx/pipe.cxx')
-rw-r--r--sal/osl/unx/pipe.cxx17
1 files changed, 7 insertions, 10 deletions
diff --git a/sal/osl/unx/pipe.cxx b/sal/osl/unx/pipe.cxx
index ecddb6629501..337d41267837 100644
--- a/sal/osl/unx/pipe.cxx
+++ b/sal/osl/unx/pipe.cxx
@@ -115,7 +115,6 @@ oslPipe SAL_CALL osl_createPipe(rtl_uString *ustrPipeName, oslPipeOptions Option
{
oslPipe pPipe=0;
rtl_String* strPipeName=0;
- sal_Char* pszPipeName=0;
if ( ustrPipeName != 0 )
{
@@ -124,7 +123,7 @@ oslPipe SAL_CALL osl_createPipe(rtl_uString *ustrPipeName, oslPipeOptions Option
rtl_uString_getLength(ustrPipeName),
osl_getThreadTextEncoding(),
OUSTRING_TO_OSTRING_CVTFLAGS );
- pszPipeName = rtl_string_getStr(strPipeName);
+ sal_Char* pszPipeName = rtl_string_getStr(strPipeName);
pPipe = osl_psz_createPipe(pszPipeName, Options, Security);
if ( strPipeName != 0 )
@@ -364,11 +363,6 @@ void SAL_CALL osl_releasePipe( oslPipe pPipe )
void SAL_CALL osl_closePipe( oslPipe pPipe )
{
int nRet;
-#if defined(LINUX)
- size_t len;
- struct sockaddr_un addr;
- int fd;
-#endif
int ConnFD;
if( ! pPipe )
@@ -388,11 +382,13 @@ void SAL_CALL osl_closePipe( oslPipe pPipe )
connect to the accepting pipe
*/
#if defined(LINUX)
+ struct sockaddr_un addr;
+
if ( pPipe->m_bIsAccepting )
{
pPipe->m_bIsInShutdown = true;
pPipe->m_Socket = -1;
- fd = socket(AF_UNIX, SOCK_STREAM, 0);
+ int fd = socket(AF_UNIX, SOCK_STREAM, 0);
if ( fd < 0 )
{
OSL_TRACE("socket in osl_destroyPipe failed with error: %s", strerror(errno));
@@ -404,7 +400,7 @@ void SAL_CALL osl_closePipe( oslPipe pPipe )
addr.sun_family = AF_UNIX;
strncpy(addr.sun_path, pPipe->m_Name, sizeof(addr.sun_path) - 1);
- len = sizeof(addr);
+ size_t len = sizeof(addr);
nRet = connect( fd, (struct sockaddr *)&addr, len);
if ( nRet < 0 )
@@ -438,7 +434,7 @@ void SAL_CALL osl_closePipe( oslPipe pPipe )
oslPipe SAL_CALL osl_acceptPipe(oslPipe pPipe)
{
- int s, flags;
+ int s;
oslPipe pAcceptedPipe;
OSL_ASSERT(pPipe);
@@ -485,6 +481,7 @@ oslPipe SAL_CALL osl_acceptPipe(oslPipe pPipe)
}
/* set close-on-exec flag */
+ int flags;
if (!((flags = fcntl(s, F_GETFD, 0)) < 0))
{
flags |= FD_CLOEXEC;