summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2015-01-18 21:37:25 +0100
committerStephan Bergmann <sbergman@redhat.com>2015-01-20 09:06:52 +0100
commit2850b4dc39069d128768084a67b24927f392448a (patch)
tree8fddde4583a7ec37e23151106ada2777e6d79de5
parent17fe7fc590b999005a76475d62821f8ac63f2124 (diff)
Some more loplugin:cstylecast: tools
Change-Id: I2b540c4c0c34823143e13d16559dac7458a38933
-rw-r--r--include/tools/solar.h64
-rw-r--r--tools/source/generic/poly.cxx16
-rw-r--r--tools/source/rc/rc.cxx4
-rw-r--r--tools/source/rc/resmgr.cxx20
-rw-r--r--tools/source/ref/errinf.cxx4
-rw-r--r--tools/source/ref/globname.cxx4
-rw-r--r--tools/source/stream/stream.cxx26
7 files changed, 69 insertions, 69 deletions
diff --git a/include/tools/solar.h b/include/tools/solar.h
index f1ac0a784c30..c8d83ac4c4bc 100644
--- a/include/tools/solar.h
+++ b/include/tools/solar.h
@@ -55,25 +55,25 @@ inline sal_uInt32 SVBT32ToUInt32 ( const SVBT32 p ) { return (sal_uInt32)p[0]
+ ((sal_uInt32)p[3] << 24); }
#if defined OSL_LITENDIAN
inline double SVBT64ToDouble( const SVBT64 p ) { double n;
- ((sal_uInt8*)&n)[0] = p[0];
- ((sal_uInt8*)&n)[1] = p[1];
- ((sal_uInt8*)&n)[2] = p[2];
- ((sal_uInt8*)&n)[3] = p[3];
- ((sal_uInt8*)&n)[4] = p[4];
- ((sal_uInt8*)&n)[5] = p[5];
- ((sal_uInt8*)&n)[6] = p[6];
- ((sal_uInt8*)&n)[7] = p[7];
+ reinterpret_cast<sal_uInt8*>(&n)[0] = p[0];
+ reinterpret_cast<sal_uInt8*>(&n)[1] = p[1];
+ reinterpret_cast<sal_uInt8*>(&n)[2] = p[2];
+ reinterpret_cast<sal_uInt8*>(&n)[3] = p[3];
+ reinterpret_cast<sal_uInt8*>(&n)[4] = p[4];
+ reinterpret_cast<sal_uInt8*>(&n)[5] = p[5];
+ reinterpret_cast<sal_uInt8*>(&n)[6] = p[6];
+ reinterpret_cast<sal_uInt8*>(&n)[7] = p[7];
return n; }
#else
inline double SVBT64ToDouble( const SVBT64 p ) { double n;
- ((sal_uInt8*)&n)[0] = p[7];
- ((sal_uInt8*)&n)[1] = p[6];
- ((sal_uInt8*)&n)[2] = p[5];
- ((sal_uInt8*)&n)[3] = p[4];
- ((sal_uInt8*)&n)[4] = p[3];
- ((sal_uInt8*)&n)[5] = p[2];
- ((sal_uInt8*)&n)[6] = p[1];
- ((sal_uInt8*)&n)[7] = p[0];
+ reinterpret_cast<sal_uInt8*>(&n)[0] = p[7];
+ reinterpret_cast<sal_uInt8*>(&n)[1] = p[6];
+ reinterpret_cast<sal_uInt8*>(&n)[2] = p[5];
+ reinterpret_cast<sal_uInt8*>(&n)[3] = p[4];
+ reinterpret_cast<sal_uInt8*>(&n)[4] = p[3];
+ reinterpret_cast<sal_uInt8*>(&n)[5] = p[2];
+ reinterpret_cast<sal_uInt8*>(&n)[6] = p[1];
+ reinterpret_cast<sal_uInt8*>(&n)[7] = p[0];
return n; }
#endif
@@ -84,23 +84,23 @@ inline void UInt32ToSVBT32 ( sal_uInt32 n, SVBT32 p ) { p[0] = (sal_uInt8)
p[2] = (sal_uInt8)(n >> 16);
p[3] = (sal_uInt8)(n >> 24); }
#if defined OSL_LITENDIAN
-inline void DoubleToSVBT64( double n, SVBT64 p ) { p[0] = ((sal_uInt8*)&n)[0];
- p[1] = ((sal_uInt8*)&n)[1];
- p[2] = ((sal_uInt8*)&n)[2];
- p[3] = ((sal_uInt8*)&n)[3];
- p[4] = ((sal_uInt8*)&n)[4];
- p[5] = ((sal_uInt8*)&n)[5];
- p[6] = ((sal_uInt8*)&n)[6];
- p[7] = ((sal_uInt8*)&n)[7]; }
+inline void DoubleToSVBT64( double n, SVBT64 p ) { p[0] = reinterpret_cast<sal_uInt8*>(&n)[0];
+ p[1] = reinterpret_cast<sal_uInt8*>(&n)[1];
+ p[2] = reinterpret_cast<sal_uInt8*>(&n)[2];
+ p[3] = reinterpret_cast<sal_uInt8*>(&n)[3];
+ p[4] = reinterpret_cast<sal_uInt8*>(&n)[4];
+ p[5] = reinterpret_cast<sal_uInt8*>(&n)[5];
+ p[6] = reinterpret_cast<sal_uInt8*>(&n)[6];
+ p[7] = reinterpret_cast<sal_uInt8*>(&n)[7]; }
#else
-inline void DoubleToSVBT64( double n, SVBT64 p ) { p[0] = ((sal_uInt8*)&n)[7];
- p[1] = ((sal_uInt8*)&n)[6];
- p[2] = ((sal_uInt8*)&n)[5];
- p[3] = ((sal_uInt8*)&n)[4];
- p[4] = ((sal_uInt8*)&n)[3];
- p[5] = ((sal_uInt8*)&n)[2];
- p[6] = ((sal_uInt8*)&n)[1];
- p[7] = ((sal_uInt8*)&n)[0]; }
+inline void DoubleToSVBT64( double n, SVBT64 p ) { p[0] = reinterpret_cast<sal_uInt8*>(&n)[7];
+ p[1] = reinterpret_cast<sal_uInt8*>(&n)[6];
+ p[2] = reinterpret_cast<sal_uInt8*>(&n)[5];
+ p[3] = reinterpret_cast<sal_uInt8*>(&n)[4];
+ p[4] = reinterpret_cast<sal_uInt8*>(&n)[3];
+ p[5] = reinterpret_cast<sal_uInt8*>(&n)[2];
+ p[6] = reinterpret_cast<sal_uInt8*>(&n)[1];
+ p[7] = reinterpret_cast<sal_uInt8*>(&n)[0]; }
#endif
#endif
diff --git a/tools/source/generic/poly.cxx b/tools/source/generic/poly.cxx
index 5df7ef3db1ff..f104a33263c8 100644
--- a/tools/source/generic/poly.cxx
+++ b/tools/source/generic/poly.cxx
@@ -61,7 +61,7 @@ ImplPolygon::ImplPolygon( sal_uInt16 nInitSize, bool bFlags )
{
if ( nInitSize )
{
- mpPointAry = (Point*)new char[(sal_uIntPtr)nInitSize*sizeof(Point)];
+ mpPointAry = reinterpret_cast<Point*>(new char[(sal_uIntPtr)nInitSize*sizeof(Point)]);
memset( mpPointAry, 0, (sal_uIntPtr)nInitSize*sizeof(Point) );
}
else
@@ -83,7 +83,7 @@ ImplPolygon::ImplPolygon( const ImplPolygon& rImpPoly )
{
if ( rImpPoly.mnPoints )
{
- mpPointAry = (Point*)new char[(sal_uIntPtr)rImpPoly.mnPoints*sizeof(Point)];
+ mpPointAry = reinterpret_cast<Point*>(new char[(sal_uIntPtr)rImpPoly.mnPoints*sizeof(Point)]);
memcpy( mpPointAry, rImpPoly.mpPointAry, (sal_uIntPtr)rImpPoly.mnPoints*sizeof(Point) );
if( rImpPoly.mpFlagAry )
@@ -108,7 +108,7 @@ ImplPolygon::ImplPolygon( sal_uInt16 nInitSize, const Point* pInitAry, const sal
{
if ( nInitSize )
{
- mpPointAry = (Point*)new char[(sal_uIntPtr)nInitSize*sizeof(Point)];
+ mpPointAry = reinterpret_cast<Point*>(new char[(sal_uIntPtr)nInitSize*sizeof(Point)]);
memcpy( mpPointAry, pInitAry, (sal_uIntPtr)nInitSize*sizeof( Point ) );
if( pInitFlags )
@@ -133,7 +133,7 @@ ImplPolygon::~ImplPolygon()
{
if ( mpPointAry )
{
- delete[] (char*) mpPointAry;
+ delete[] reinterpret_cast<char*>(mpPointAry);
}
if( mpFlagAry )
@@ -149,7 +149,7 @@ void ImplPolygon::ImplSetSize( sal_uInt16 nNewSize, bool bResize )
if ( nNewSize )
{
- pNewAry = (Point*)new char[(sal_uIntPtr)nNewSize*sizeof(Point)];
+ pNewAry = reinterpret_cast<Point*>(new char[(sal_uIntPtr)nNewSize*sizeof(Point)]);
if ( bResize )
{
@@ -172,7 +172,7 @@ void ImplPolygon::ImplSetSize( sal_uInt16 nNewSize, bool bResize )
pNewAry = NULL;
if ( mpPointAry )
- delete[] (char*) mpPointAry;
+ delete[] reinterpret_cast<char*>(mpPointAry);
// ggf. FlagArray beruecksichtigen
if( mpFlagAry )
@@ -236,7 +236,7 @@ void ImplPolygon::ImplSplit( sal_uInt16 nPos, sal_uInt16 nSpace, ImplPolygon* pI
const sal_uInt16 nSecPos = nPos + nSpace;
const sal_uInt16 nRest = mnPoints - nPos;
- Point* pNewAry = (Point*) new char[ (sal_uIntPtr) nNewSize * sizeof( Point ) ];
+ Point* pNewAry = reinterpret_cast<Point*>(new char[ (sal_uIntPtr) nNewSize * sizeof( Point ) ]);
memcpy( pNewAry, mpPointAry, nPos * sizeof( Point ) );
@@ -246,7 +246,7 @@ void ImplPolygon::ImplSplit( sal_uInt16 nPos, sal_uInt16 nSpace, ImplPolygon* pI
memset( pNewAry + nPos, 0, nSpaceSize );
memcpy( pNewAry + nSecPos, mpPointAry + nPos, nRest * sizeof( Point ) );
- delete[] (char*) mpPointAry;
+ delete[] reinterpret_cast<char*>(mpPointAry);
// consider FlagArray
if( mpFlagAry )
diff --git a/tools/source/rc/rc.cxx b/tools/source/rc/rc.cxx
index cefccad9dc40..b26628edbd67 100644
--- a/tools/source/rc/rc.cxx
+++ b/tools/source/rc/rc.cxx
@@ -65,8 +65,8 @@ OUString ResId::toString() const
// String loading
RSHEADER_TYPE * pResHdr = (RSHEADER_TYPE*)pResMgr->GetClass();
- sal_Int32 nStringLen = rtl_str_getLength( (char*)(pResHdr+1) );
- OUString sRet((const char*)(pResHdr+1), nStringLen, RTL_TEXTENCODING_UTF8);
+ sal_Int32 nStringLen = rtl_str_getLength( reinterpret_cast<char*>(pResHdr+1) );
+ OUString sRet(reinterpret_cast<char*>(pResHdr+1), nStringLen, RTL_TEXTENCODING_UTF8);
sal_uInt32 nSize = sizeof( RSHEADER_TYPE )
+ sal::static_int_cast< sal_uInt32 >(nStringLen) + 1;
diff --git a/tools/source/rc/resmgr.cxx b/tools/source/rc/resmgr.cxx
index 5cf16607f6c0..27d0cd71b9d0 100644
--- a/tools/source/rc/resmgr.cxx
+++ b/tools/source/rc/resmgr.cxx
@@ -755,15 +755,15 @@ static RSHEADER_TYPE* LocalResource( const ImpRCStack* pStack,
if ( pStack->pResource && pStack->pClassRes )
{
- pTmp = (RSHEADER_TYPE*)
- ((sal_uInt8*)pStack->pResource + pStack->pResource->GetLocalOff());
- pEnd = (RSHEADER_TYPE*)
- ((sal_uInt8*)pStack->pResource + pStack->pResource->GetGlobOff());
+ pTmp = reinterpret_cast<RSHEADER_TYPE*>
+ (reinterpret_cast<sal_uInt8*>(pStack->pResource) + pStack->pResource->GetLocalOff());
+ pEnd = reinterpret_cast<RSHEADER_TYPE*>
+ (reinterpret_cast<sal_uInt8*>(pStack->pResource) + pStack->pResource->GetGlobOff());
while ( pTmp != pEnd )
{
if ( pTmp->GetRT() == nRTType && pTmp->GetId() == nId )
return pTmp;
- pTmp = (RSHEADER_TYPE*)((sal_uInt8*)pTmp + pTmp->GetGlobOff());
+ pTmp = reinterpret_cast<RSHEADER_TYPE*>(reinterpret_cast<sal_uInt8*>(pTmp) + pTmp->GetGlobOff());
}
}
@@ -1113,7 +1113,7 @@ void ResMgr::PopContext( const Resource* pResObj )
#ifdef DBG_UTIL
if ( DbgIsResource() && !(pTop->Flags & RC_NOTFOUND) )
{
- void* pRes = (sal_uInt8*)pTop->pResource +
+ void* pRes = reinterpret_cast<sal_uInt8*>(pTop->pResource) +
pTop->pResource->GetLocalOff();
if ( pTop->pClassRes != pRes )
@@ -1215,13 +1215,13 @@ sal_uInt32 ResMgr::GetByteString( OString& rStr, const sal_uInt8* pStr )
{
sal_uInt32 nLen=0;
sal_uInt32 nRet = GetStringSize( pStr, nLen );
- rStr = OString( (const sal_Char*)pStr, nLen );
+ rStr = OString( reinterpret_cast<const char*>(pStr), nLen );
return nRet;
}
sal_uInt32 ResMgr::GetStringSize( const sal_uInt8* pStr, sal_uInt32& nLen )
{
- nLen = static_cast< sal_uInt32 >( strlen( (const char*)pStr ) );
+ nLen = static_cast< sal_uInt32 >( strlen( reinterpret_cast<const char*>(pStr) ) );
return GetStringSize( nLen );
}
@@ -1257,7 +1257,7 @@ void* ResMgr::Increment( sal_uInt32 nSize )
sal_uInt32 nLocalOff = pRes->GetLocalOff();
if ( (pRes->GetGlobOff() == nLocalOff) &&
- (((char*)pRes + nLocalOff) == rStack.pClassRes) &&
+ ((reinterpret_cast<char*>(pRes) + nLocalOff) == rStack.pClassRes) &&
(rStack.Flags & RC_AUTORELEASE))
{
PopContext( rStack.pResObj );
@@ -1608,7 +1608,7 @@ OUString SimpleResMgr::ReadString( sal_uInt32 nId )
}
// sal_uIntPtr nLen = pResHeader->GetLocalOff() - sizeof(RSHEADER_TYPE);
- ResMgr::GetString( sReturn, (const sal_uInt8*)(pResHeader+1) );
+ ResMgr::GetString( sReturn, reinterpret_cast<sal_uInt8*>(pResHeader+1) );
// not necessary with the current implementation which holds the string table permanently, but to be sure ....
// note: pFallback cannot be NULL here and is either the fallback or m_pResImpl
diff --git a/tools/source/ref/errinf.cxx b/tools/source/ref/errinf.cxx
index f291a330ea67..ff9ab0ed32ff 100644
--- a/tools/source/ref/errinf.cxx
+++ b/tools/source/ref/errinf.cxx
@@ -319,14 +319,14 @@ sal_uInt16 ErrorHandler::HandleError_Impl(
delete pInfo;
if(!pData->bIsWindowDsp)
{
- (*(BasicDisplayErrorFunc*)pData->pDsp)(aErr,aAction);
+ (*reinterpret_cast<BasicDisplayErrorFunc*>(pData->pDsp))(aErr,aAction);
return 0;
}
else
{
if (nFlags != USHRT_MAX)
nErrFlags = nFlags;
- return (*(WindowDisplayErrorFunc*)pData->pDsp)(
+ return (*reinterpret_cast<WindowDisplayErrorFunc*>(pData->pDsp))(
pParent, nErrFlags, aErr, aAction);
}
}
diff --git a/tools/source/ref/globname.cxx b/tools/source/ref/globname.cxx
index 5bb60de6a057..fe9604821aec 100644
--- a/tools/source/ref/globname.cxx
+++ b/tools/source/ref/globname.cxx
@@ -117,7 +117,7 @@ SvStream& WriteSvGlobalName( SvStream& rOStr, const SvGlobalName & rObj )
rOStr.WriteUInt32( rObj.pImp->szData.Data1 );
rOStr.WriteUInt16( rObj.pImp->szData.Data2 );
rOStr.WriteUInt16( rObj.pImp->szData.Data3 );
- rOStr.Write( (sal_Char *)&rObj.pImp->szData.Data4, 8 );
+ rOStr.Write( &rObj.pImp->szData.Data4, 8 );
return rOStr;
}
@@ -127,7 +127,7 @@ SvStream& operator >> ( SvStream& rStr, SvGlobalName & rObj )
rStr.ReadUInt32( rObj.pImp->szData.Data1 );
rStr.ReadUInt16( rObj.pImp->szData.Data2 );
rStr.ReadUInt16( rObj.pImp->szData.Data3 );
- rStr.Read( (sal_Char *)&rObj.pImp->szData.Data4, 8 );
+ rStr.Read( &rObj.pImp->szData.Data4, 8 );
return rStr;
}
diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx
index 19ebddf20a96..47f0dae26943 100644
--- a/tools/source/stream/stream.cxx
+++ b/tools/source/stream/stream.cxx
@@ -134,14 +134,14 @@ inline static void SwapDouble( double& r )
if( bIoRead && sizeof(datatype)<=nBufFree) \
{ \
for (std::size_t i = 0; i < sizeof(datatype); i++) \
- ((char *)&value)[i] = pBufPos[i]; \
+ reinterpret_cast<char *>(&value)[i] = pBufPos[i]; \
nBufActualPos += sizeof(datatype); \
pBufPos += sizeof(datatype); \
nBufFree -= sizeof(datatype); \
} \
else \
{ \
- Read( (char*)&value, sizeof(datatype) ); \
+ Read( &value, sizeof(datatype) ); \
} \
@@ -149,7 +149,7 @@ inline static void SwapDouble( double& r )
if( bIoWrite && sizeof(datatype) <= nBufFree) \
{ \
for (std::size_t i = 0; i < sizeof(datatype); i++) \
- pBufPos[i] = ((char *)&value)[i]; \
+ pBufPos[i] = reinterpret_cast<char const *>(&value)[i]; \
nBufFree -= sizeof(datatype); \
nBufActualPos += sizeof(datatype); \
if( nBufActualPos > nBufActualLen ) \
@@ -159,7 +159,7 @@ inline static void SwapDouble( double& r )
} \
else \
{ \
- Write( (char*)&value, sizeof(datatype) ); \
+ Write( &value, sizeof(datatype) ); \
} \
// class SvLockBytes
@@ -605,7 +605,7 @@ bool SvStream::ReadUniStringLine( OUString& rStr, sal_Int32 nMaxCodepointsToRead
while( !bEnd && !GetError() ) // Don't test for EOF as we
// are reading block-wise!
{
- sal_uInt16 nLen = (sal_uInt16)Read( (char*)buf, sizeof(buf)-sizeof(sal_Unicode) );
+ sal_uInt16 nLen = (sal_uInt16)Read( buf, sizeof(buf)-sizeof(sal_Unicode) );
nLen /= sizeof(sal_Unicode);
if ( !nLen )
{
@@ -664,7 +664,7 @@ bool SvStream::ReadUniStringLine( OUString& rStr, sal_Int32 nMaxCodepointsToRead
if ( bEnd && (c=='\r' || c=='\n') ) // special treatment for DOS files
{
sal_Unicode cTemp;
- Read( (char*)&cTemp, sizeof(cTemp) );
+ Read( &cTemp, sizeof(cTemp) );
if ( bSwap )
SwapUShort( cTemp );
if( cTemp == c || (cTemp != '\n' && cTemp != '\r') )
@@ -733,7 +733,7 @@ sal_Size write_uInt16s_FromOUString(SvStream& rStrm, const OUString& rStr,
DBG_ASSERT( sizeof(sal_Unicode) == sizeof(sal_uInt16), "write_uInt16s_FromOUString: swapping sizeof(sal_Unicode) not implemented" );
sal_Size nWritten;
if (!rStrm.IsEndianSwap())
- nWritten = rStrm.Write( (char*)rStr.getStr(), nUnits * sizeof(sal_Unicode) );
+ nWritten = rStrm.Write( rStr.getStr(), nUnits * sizeof(sal_Unicode) );
else
{
sal_Size nLen = nUnits;
@@ -747,7 +747,7 @@ sal_Size write_uInt16s_FromOUString(SvStream& rStrm, const OUString& rStr,
SwapUShort( *p );
p++;
}
- nWritten = rStrm.Write( (char*)pTmp, nLen * sizeof(sal_Unicode) );
+ nWritten = rStrm.Write( pTmp, nLen * sizeof(sal_Unicode) );
if ( pTmp != aBuf )
delete [] pTmp;
}
@@ -968,7 +968,7 @@ SvStream& SvStream::ReadSChar( signed char& r )
nBufFree -= sizeof(signed char);
}
else
- Read( (char*)&r, sizeof(signed char) );
+ Read( &r, sizeof(signed char) );
return *this;
}
@@ -1000,7 +1000,7 @@ SvStream& SvStream::ReadUChar( unsigned char& r )
nBufFree -= sizeof(char);
}
else
- Read( (char*)&r, sizeof(char) );
+ Read( &r, sizeof(char) );
return *this;
}
@@ -1135,7 +1135,7 @@ SvStream& SvStream::WriteSChar( signed char v )
bIsDirty = true;
}
else
- Write( (char*)&v, sizeof(signed char) );
+ Write( &v, sizeof(signed char) );
return *this;
}
@@ -1173,7 +1173,7 @@ SvStream& SvStream::WriteUChar( unsigned char v )
bIsDirty = true;
}
else
- Write( (char*)&v, sizeof(char) );
+ Write( &v, sizeof(char) );
return *this;
}
@@ -1550,7 +1550,7 @@ sal_Size SvStream::CryptAndWriteBuffer( const void* pStart, sal_Size nLen)
pTemp[n] = aCh;
}
// *************************
- nCount += PutData( (char*)pTemp, nBufCount );
+ nCount += PutData( pTemp, nBufCount );
pDataPtr += nBufCount;
}
while ( nLen );