summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorsb <sb@openoffice.org>2009-10-29 15:48:48 +0100
committersb <sb@openoffice.org>2009-10-29 15:48:48 +0100
commit925a3a281e9fe4bc6d1f62d8c1ade83e46bf87f9 (patch)
treec8cd9884bdd893f5f86bbe11affcd5fd95457a78 /sal
parent40a156995c9a39cd5de0efaa0ddcc163515bf70a (diff)
sb116: #i106384# avoid GCC warnings produced if -fno-strict-aliasing were removed (patch by cmc)
Diffstat (limited to 'sal')
-rw-r--r--sal/inc/rtl/math.hxx23
-rw-r--r--sal/osl/unx/process.c4
-rw-r--r--sal/osl/unx/socket.c19
-rw-r--r--sal/rtl/source/bootstrap.cxx4
-rw-r--r--sal/rtl/source/math.cxx9
5 files changed, 39 insertions, 20 deletions
diff --git a/sal/inc/rtl/math.hxx b/sal/inc/rtl/math.hxx
index 5760340cc6a4..dbd4a2172246 100644
--- a/sal/inc/rtl/math.hxx
+++ b/sal/inc/rtl/math.hxx
@@ -357,17 +357,30 @@ inline bool isSignBitSet(double d)
*/
inline void setInf(double * pd, bool bNegative)
{
- reinterpret_cast< sal_math_Double * >(pd)->w32_parts.msw
- = bNegative ? 0xFFF00000 : 0x7FF00000;
- reinterpret_cast< sal_math_Double * >(pd)->w32_parts.lsw = 0;
+ union
+ {
+ double sd;
+ sal_math_Double md;
+ };
+ sd = *pd;
+ md.w32_parts.msw = bNegative ? 0xFFF00000 : 0x7FF00000;
+ md.w32_parts.lsw = 0;
+ *pd = sd;
}
/** Set a QNAN.
*/
inline void setNan(double * pd)
{
- reinterpret_cast< sal_math_Double * >(pd)->w32_parts.msw = 0x7FFFFFFF;
- reinterpret_cast< sal_math_Double * >(pd)->w32_parts.lsw = 0xFFFFFFFF;
+ union
+ {
+ double sd;
+ sal_math_Double md;
+ };
+ sd = *pd;
+ md.w32_parts.msw = 0x7FFFFFFF;
+ md.w32_parts.lsw = 0xFFFFFFFF;
+ *pd = sd;
}
/** If a value is a valid argument for sin(), cos(), tan().
diff --git a/sal/osl/unx/process.c b/sal/osl/unx/process.c
index 453d00091c63..abda0b73d856 100644
--- a/sal/osl/unx/process.c
+++ b/sal/osl/unx/process.c
@@ -269,7 +269,7 @@ static sal_Bool sendFdPipe(int PipeFD, int SocketFD)
cmptr->cmsg_level = SOL_SOCKET;
cmptr->cmsg_type = SCM_RIGHTS;
cmptr->cmsg_len = CONTROLLEN;
- *(int*)CMSG_DATA(cmptr) = SocketFD;
+ memcpy(CMSG_DATA(cmptr), &SocketFD, sizeof(int));
#endif
@@ -360,7 +360,7 @@ static oslSocket receiveFdPipe(int PipeFD)
( msghdr.msg_controllen == CONTROLLEN ) )
{
OSL_TRACE("receiveFdPipe : received '%i' bytes\n",nRead);
- newfd = *(int*)CMSG_DATA(cmptr);
+ memcpy(&newfd, CMSG_DATA(cmptr), sizeof(int));
}
#endif
else
diff --git a/sal/osl/unx/socket.c b/sal/osl/unx/socket.c
index 310dd57592f5..4306347af873 100644
--- a/sal/osl/unx/socket.c
+++ b/sal/osl/unx/socket.c
@@ -1869,10 +1869,13 @@ void SAL_CALL osl_closeSocket(oslSocket pSocket)
if ( pSocket->m_bIsAccepting == sal_True )
{
int nConnFD;
- struct sockaddr aSockAddr;
- socklen_t nSockLen = sizeof(aSockAddr);
+ union {
+ struct sockaddr aSockAddr;
+ struct sockaddr_in aSockAddrIn;
+ } s;
+ socklen_t nSockLen = sizeof(s.aSockAddr);
- nRet = getsockname(nFD, &aSockAddr, &nSockLen);
+ nRet = getsockname(nFD, &s.aSockAddr, &nSockLen);
#if OSL_DEBUG_LEVEL > 1
if ( nRet < 0 )
{
@@ -1880,13 +1883,11 @@ void SAL_CALL osl_closeSocket(oslSocket pSocket)
}
#endif /* OSL_DEBUG_LEVEL */
- if ( aSockAddr.sa_family == AF_INET )
+ if ( s.aSockAddr.sa_family == AF_INET )
{
- struct sockaddr_in* pSockAddrIn = (struct sockaddr_in*) &aSockAddr;
-
- if ( pSockAddrIn->sin_addr.s_addr == htonl(INADDR_ANY) )
+ if ( s.aSockAddrIn.sin_addr.s_addr == htonl(INADDR_ANY) )
{
- pSockAddrIn->sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+ s.aSockAddrIn.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
}
nConnFD = socket(AF_INET, SOCK_STREAM, 0);
@@ -1897,7 +1898,7 @@ void SAL_CALL osl_closeSocket(oslSocket pSocket)
}
#endif /* OSL_DEBUG_LEVEL */
- nRet = connect(nConnFD, &aSockAddr, sizeof(aSockAddr));
+ nRet = connect(nConnFD, &s.aSockAddr, sizeof(s.aSockAddr));
#if OSL_DEBUG_LEVEL > 1
if ( nRet < 0 )
{
diff --git a/sal/rtl/source/bootstrap.cxx b/sal/rtl/source/bootstrap.cxx
index 23dab839d558..769251a6c4ec 100644
--- a/sal/rtl/source/bootstrap.cxx
+++ b/sal/rtl/source/bootstrap.cxx
@@ -820,8 +820,8 @@ void SAL_CALL rtl_bootstrap_set (
rtl_uString * pValue
) SAL_THROW_EXTERN_C()
{
- OUString const & name = *reinterpret_cast< OUString const * >( &pName );
- OUString const & value = *reinterpret_cast< OUString const * >( &pValue );
+ const OUString name( pName );
+ const OUString value( pValue );
osl::MutexGuard guard( osl::Mutex::getGlobalMutex() );
diff --git a/sal/rtl/source/math.cxx b/sal/rtl/source/math.cxx
index a255ca21b13a..012046c9e5c8 100644
--- a/sal/rtl/source/math.cxx
+++ b/sal/rtl/source/math.cxx
@@ -879,8 +879,13 @@ inline double stringToDouble(CharT const * pBegin, CharT const * pEnd,
rtl::math::setNan( &fVal );
if (bSign)
{
- reinterpret_cast< sal_math_Double * >(&fVal)->w32_parts.msw
- |= 0x80000000; // create negative NaN
+ union {
+ double sd;
+ sal_math_Double md;
+ } m;
+ m.sd = fVal;
+ m.md.w32_parts.msw |= 0x80000000; // create negative NaN
+ fVal = m.sd;
bSign = false; // don't negate again
}
// Eat any further digits: