diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2015-01-17 19:01:27 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2015-01-20 09:06:50 +0100 |
commit | b70b4e644b5bb5356509505855418453dc621cfc (patch) | |
tree | 0a2441aa91947032d398b688f73553ff4d5a4afb /sal/rtl | |
parent | 2e160b1e0e5b28b8a6ddfa07fc6ffff1c6e590bc (diff) |
Some more loplugin:cstylecast: sal
Change-Id: Ie54d340478412e62b87d66e287fd8a3963e97898
Diffstat (limited to 'sal/rtl')
-rw-r--r-- | sal/rtl/alloc_global.cxx | 6 | ||||
-rw-r--r-- | sal/rtl/bootstrap.cxx | 4 | ||||
-rw-r--r-- | sal/rtl/byteseq.cxx | 2 | ||||
-rw-r--r-- | sal/rtl/digest.cxx | 6 | ||||
-rw-r--r-- | sal/rtl/logfile.cxx | 22 | ||||
-rw-r--r-- | sal/rtl/random.cxx | 8 | ||||
-rw-r--r-- | sal/rtl/strtmpl.cxx | 20 | ||||
-rw-r--r-- | sal/rtl/uuid.cxx | 8 |
8 files changed, 41 insertions, 35 deletions
diff --git a/sal/rtl/alloc_global.cxx b/sal/rtl/alloc_global.cxx index d040f1515baa..a18527106f24 100644 --- a/sal/rtl/alloc_global.cxx +++ b/sal/rtl/alloc_global.cxx @@ -116,7 +116,7 @@ try_alloc: if (addr != 0) { - ((sal_Size*)(addr))[0] = size; + reinterpret_cast<sal_Size*>(addr)[0] = size; p = addr + RTL_MEMALIGN; } else if (gp_alloc_arena == 0) @@ -139,7 +139,7 @@ void SAL_CALL rtl_freeMemory_CUSTOM (void * p) SAL_THROW_EXTERN_C() if (p != 0) { char * addr = (char*)(p) - RTL_MEMALIGN; - sal_Size size = ((sal_Size*)(addr))[0]; + sal_Size size = reinterpret_cast<sal_Size*>(addr)[0]; if (size <= RTL_MEMORY_CACHED_LIMIT) rtl_cache_free(g_alloc_table[(size - 1) >> RTL_MEMALIGN_SHIFT], addr); @@ -157,7 +157,7 @@ void * SAL_CALL rtl_reallocateMemory_CUSTOM (void * p, sal_Size n) SAL_THROW_EXT if (p != 0) { void * p_old = p; - sal_Size n_old = ((sal_Size*)( (char*)(p) - RTL_MEMALIGN ))[0] - RTL_MEMALIGN; + sal_Size n_old = reinterpret_cast<sal_Size*>( (char*)(p) - RTL_MEMALIGN )[0] - RTL_MEMALIGN; p = rtl_allocateMemory (n); if (p != 0) diff --git a/sal/rtl/bootstrap.cxx b/sal/rtl/bootstrap.cxx index a62daffbd4ac..e2ff943afe3a 100644 --- a/sal/rtl/bootstrap.cxx +++ b/sal/rtl/bootstrap.cxx @@ -365,9 +365,9 @@ Bootstrap_Impl::Bootstrap_Impl( OUString const & rIniName ) { rtl::ByteSequence seq; - while (osl_File_E_None == osl_readLine(handle , (sal_Sequence **)&seq)) + while (osl_File_E_None == osl_readLine(handle , reinterpret_cast<sal_Sequence **>(&seq))) { - OString line( (const sal_Char *) seq.getConstArray(), seq.getLength() ); + OString line( reinterpret_cast<const char *>(seq.getConstArray()), seq.getLength() ); sal_Int32 nIndex = line.indexOf('='); if (nIndex >= 1) { diff --git a/sal/rtl/byteseq.cxx b/sal/rtl/byteseq.cxx index f0f190125dce..cd25a62a25e0 100644 --- a/sal/rtl/byteseq.cxx +++ b/sal/rtl/byteseq.cxx @@ -234,7 +234,7 @@ sal_Bool SAL_CALL rtl_byte_sequence_equals( sal_Sequence *pSequence1 , sal_Seque const sal_Int8 *SAL_CALL rtl_byte_sequence_getConstArray( sal_Sequence *pSequence ) SAL_THROW_EXTERN_C() { - return ((const sal_Int8*)(pSequence->elements)); + return reinterpret_cast<sal_Int8*>(pSequence->elements); } sal_Int32 SAL_CALL rtl_byte_sequence_getLength( sal_Sequence *pSequence ) diff --git a/sal/rtl/digest.cxx b/sal/rtl/digest.cxx index b35700e7cefb..205db64f76b4 100644 --- a/sal/rtl/digest.cxx +++ b/sal/rtl/digest.cxx @@ -802,7 +802,7 @@ rtlDigestError SAL_CALL rtl_digest_updateMD5 ( if (ctx->m_nDatLen) { - sal_uInt8 *p = (sal_uInt8 *)(ctx->m_pData) + ctx->m_nDatLen; + sal_uInt8 *p = reinterpret_cast<sal_uInt8 *>(ctx->m_pData) + ctx->m_nDatLen; sal_uInt32 n = DIGEST_CBLOCK_MD5 - ctx->m_nDatLen; if (nDatLen < n) @@ -1286,7 +1286,7 @@ rtlDigestError SAL_CALL rtl_digest_updateSHA ( if (ctx->m_nDatLen) { - sal_uInt8 *p = (sal_uInt8 *)(ctx->m_pData) + ctx->m_nDatLen; + sal_uInt8 *p = reinterpret_cast<sal_uInt8 *>(ctx->m_pData) + ctx->m_nDatLen; sal_uInt32 n = DIGEST_CBLOCK_SHA - ctx->m_nDatLen; if (nDatLen < n) @@ -1476,7 +1476,7 @@ rtlDigestError SAL_CALL rtl_digest_updateSHA1 ( if (ctx->m_nDatLen) { - sal_uInt8 *p = (sal_uInt8 *)(ctx->m_pData) + ctx->m_nDatLen; + sal_uInt8 *p = reinterpret_cast<sal_uInt8 *>(ctx->m_pData) + ctx->m_nDatLen; sal_uInt32 n = DIGEST_CBLOCK_SHA - ctx->m_nDatLen; if (nDatLen < n) diff --git a/sal/rtl/logfile.cxx b/sal/rtl/logfile.cxx index a78eb084ffab..637f2eb8640e 100644 --- a/sal/rtl/logfile.cxx +++ b/sal/rtl/logfile.cxx @@ -125,16 +125,16 @@ Logger::Logger(): aFile(0), buffer(0) if( nConverted > 0 ) { - sal_Int64 nWritten; - osl_writeFile( aFile, buffer, nConverted , (sal_uInt64 *)&nWritten ); + sal_uInt64 nWritten; + osl_writeFile( aFile, buffer, nConverted , &nWritten ); } } nConverted = sprintf (buffer, "Process id is %" SAL_PRIuUINT32 "\n", aProcessId); if( nConverted ) { - sal_Int64 nWritten; - osl_writeFile( aFile, buffer, nConverted, (sal_uInt64 *)&nWritten ); + sal_uInt64 nWritten; + osl_writeFile( aFile, buffer, nConverted, &nWritten ); } } else @@ -150,10 +150,13 @@ Logger::~Logger() { if( buffer ) { - sal_Int64 nWritten, nConverted = + sal_Int64 nConverted = sprintf( buffer, "closing log file at %06" SAL_PRIuUINT32, osl_getGlobalTimer() ); if( nConverted > 0 ) - osl_writeFile( aFile, buffer, nConverted, (sal_uInt64 *)&nWritten ); + { + sal_uInt64 nWritten; + osl_writeFile( aFile, buffer, nConverted, &nWritten ); + } osl_closeFile( aFile ); rtl_freeMemory( buffer ); } @@ -171,12 +174,15 @@ extern "C" void SAL_CALL rtl_logfile_trace ( const char *pszFormat, ... ) va_list args; va_start(args, pszFormat); { - sal_Int64 nConverted, nWritten; + sal_Int64 nConverted; MutexGuard guard( logger.mutex ); nConverted = vsnprintf( logger.buffer , g_BUFFERSIZE, pszFormat, args ); nConverted = (nConverted > g_BUFFERSIZE ? g_BUFFERSIZE : nConverted ); if( nConverted > 0 ) - osl_writeFile( logger.aFile, logger.buffer, nConverted, (sal_uInt64*)&nWritten ); + { + sal_uInt64 nWritten; + osl_writeFile( logger.aFile, logger.buffer, nConverted, &nWritten ); + } } va_end(args); } diff --git a/sal/rtl/random.cxx b/sal/rtl/random.cxx index 53cce865e822..851dbffb1dda 100644 --- a/sal/rtl/random.cxx +++ b/sal/rtl/random.cxx @@ -131,22 +131,22 @@ static bool __rtl_random_initPool (RandomPool_Impl *pImpl) tid = osl::Thread::getCurrentIdentifier(); tid = RTL_RANDOM_RNG_2(RTL_RANDOM_RNG_1(tid)); - __rtl_random_seedPool (pImpl, (sal_uInt8*)&tid, sizeof(tid)); + __rtl_random_seedPool (pImpl, reinterpret_cast<sal_uInt8*>(&tid), sizeof(tid)); osl_getSystemTime (&tv); tv.Seconds = RTL_RANDOM_RNG_2(tv.Seconds); tv.Nanosec = RTL_RANDOM_RNG_2(tv.Nanosec); - __rtl_random_seedPool (pImpl, (sal_uInt8*)&tv, sizeof(tv)); + __rtl_random_seedPool (pImpl, reinterpret_cast<sal_uInt8*>(&tv), sizeof(tv)); rd.m_nX = (sal_Int16)(((tid >> 1) << 1) + 1); rd.m_nY = (sal_Int16)(((tv.Seconds >> 1) << 1) + 1); rd.m_nZ = (sal_Int16)(((tv.Nanosec >> 1) << 1) + 1); - __rtl_random_seedPool (pImpl, (sal_uInt8*)&rd, sizeof(rd)); + __rtl_random_seedPool (pImpl, reinterpret_cast<sal_uInt8*>(&rd), sizeof(rd)); while (pImpl->m_nData < RTL_RANDOM_SIZE_POOL) { seed = __rtl_random_data (&rd); - __rtl_random_seedPool (pImpl, (sal_uInt8*)&seed, sizeof(seed)); + __rtl_random_seedPool (pImpl, reinterpret_cast<sal_uInt8*>(&seed), sizeof(seed)); } return true; } diff --git a/sal/rtl/strtmpl.cxx b/sal/rtl/strtmpl.cxx index 1a1e74f8827f..8bea7db482ea 100644 --- a/sal/rtl/strtmpl.cxx +++ b/sal/rtl/strtmpl.cxx @@ -69,7 +69,7 @@ sal_Int32 SAL_CALL IMPL_RTL_STRNAME( getLength )( const IMPL_RTL_STRCODE* pStr ) if (sizeof(IMPL_RTL_STRCODE) == sizeof(wchar_t)) { // take advantage of builtin optimisations - return wcslen((wchar_t*)pStr); + return wcslen(reinterpret_cast<wchar_t const *>(pStr)); } else { @@ -94,7 +94,7 @@ sal_Int32 SAL_CALL IMPL_RTL_STRNAME( compare )( const IMPL_RTL_STRCODE* pStr1, if (sizeof(IMPL_RTL_STRCODE) == sizeof(wchar_t)) { // take advantage of builtin optimisations - return wcscmp((wchar_t*)pStr1, (wchar_t*)pStr2); + return wcscmp(reinterpret_cast<wchar_t const *>(pStr1), reinterpret_cast<wchar_t const *>(pStr2)); } else { @@ -130,7 +130,7 @@ sal_Int32 SAL_CALL IMPL_RTL_STRNAME( compare_WithLength )( const IMPL_RTL_STRCOD { // take advantage of builtin optimisations sal_Int32 nMin = std::min(nStr1Len, nStr2Len); - sal_Int32 nRet = wcsncmp((wchar_t*)pStr1, (wchar_t*)pStr2, nMin); + sal_Int32 nRet = wcsncmp(reinterpret_cast<wchar_t const *>(pStr1), reinterpret_cast<wchar_t const *>(pStr2), nMin); return nRet == 0 ? nStr1Len - nStr2Len : nRet; } else @@ -172,7 +172,7 @@ sal_Int32 SAL_CALL IMPL_RTL_STRNAME( shortenedCompare_WithLength )( const IMPL_R { // take advantage of builtin optimisations sal_Int32 nMin = std::min(std::min(nStr1Len, nStr2Len), nShortenedLength); - sal_Int32 nRet = wcsncmp((wchar_t*)pStr1, (wchar_t*)pStr2, nMin); + sal_Int32 nRet = wcsncmp(reinterpret_cast<wchar_t const *>(pStr1), reinterpret_cast<wchar_t const *>(pStr2), nMin); if (nRet == 0 && nShortenedLength > std::min(nStr1Len, nStr2Len)) return nStr1Len - nStr2Len; return nRet; @@ -340,8 +340,8 @@ sal_Int32 SAL_CALL IMPL_RTL_STRNAME( indexOfChar )( const IMPL_RTL_STRCODE* pStr if (sizeof(IMPL_RTL_STRCODE) == sizeof(wchar_t)) { // take advantage of builtin optimisations - wchar_t* p = wcschr((wchar_t*)pStr, (wchar_t)c); - return p ? p - (wchar_t*)pStr : -1; + wchar_t* p = wcschr(reinterpret_cast<wchar_t const *>(pStr), (wchar_t)c); + return p ? p - reinterpret_cast<wchar_t const *>(pStr) : -1; } else { @@ -399,8 +399,8 @@ sal_Int32 SAL_CALL IMPL_RTL_STRNAME( lastIndexOfChar )( const IMPL_RTL_STRCODE* if (sizeof(IMPL_RTL_STRCODE) == sizeof(wchar_t)) { // take advantage of builtin optimisations - wchar_t* p = wcsrchr((wchar_t*)pStr, (wchar_t)c); - return p ? p - (wchar_t*)pStr : -1; + wchar_t* p = wcsrchr(reinterpret_cast<wchar_t const *>(pStr), (wchar_t)c); + return p ? p - reinterpret_cast<wchar_t const *>(pStr) : -1; } else { @@ -443,8 +443,8 @@ sal_Int32 SAL_CALL IMPL_RTL_STRNAME( indexOfStr )( const IMPL_RTL_STRCODE* pStr, if (sizeof(IMPL_RTL_STRCODE) == sizeof(wchar_t)) { // take advantage of builtin optimisations - wchar_t* p = wcsstr((wchar_t*)pStr, (wchar_t*)pSubStr); - return p ? p - (wchar_t*)pStr : -1; + wchar_t* p = wcsstr(reinterpret_cast<wchar_t const *>(pStr), reinterpret_cast<wchar_t const *>(pSubStr)); + return p ? p - reinterpret_cast<wchar_t const *>(pStr) : -1; } else { diff --git a/sal/rtl/uuid.cxx b/sal/rtl/uuid.cxx index ea850546f36c..8eb0566e9e2f 100644 --- a/sal/rtl/uuid.cxx +++ b/sal/rtl/uuid.cxx @@ -27,7 +27,7 @@ #define SWAP_INT32_TO_NETWORK(x)\ { sal_uInt32 y = x;\ - sal_uInt8 *p = (sal_uInt8 * )&(x); \ + sal_uInt8 *p = reinterpret_cast<sal_uInt8 *>(&(x)); \ p[0] = (sal_uInt8) ( ( y >> 24 ) & 0xff );\ p[1] = (sal_uInt8) ( ( y >> 16 ) & 0xff );\ p[2] = (sal_uInt8) ( ( y >> 8 ) & 0xff );\ @@ -35,20 +35,20 @@ } #define SWAP_INT16_TO_NETWORK(x)\ { sal_uInt16 y = x;\ - sal_uInt8 *p = (sal_uInt8 * )&(x); \ + sal_uInt8 *p = reinterpret_cast<sal_uInt8 *>(&(x)); \ p[0] = (sal_uInt8) ( ( y >> 8 ) & 0xff );\ p[1] = (sal_uInt8) ( ( y ) & 0xff);\ } #define SWAP_NETWORK_TO_INT16(x)\ { sal_uInt16 y = x;\ - sal_uInt8 *p = (sal_uInt8 * )&(y);\ + sal_uInt8 *p = reinterpret_cast<sal_uInt8 *>(&(y));\ x = ( ( ((sal_uInt16)p[0]) & 0xff) << 8 ) |\ ( ( (sal_uInt16)p[1]) & 0xff);\ } #define SWAP_NETWORK_TO_INT32(x)\ { sal_uInt32 y = x;\ - sal_uInt8 *p = (sal_uInt8 * )&(y); \ + sal_uInt8 *p = reinterpret_cast<sal_uInt8 *>(&(y)); \ x = ( ( ((sal_uInt32)p[0]) & 0xff) << 24 ) |\ ( ( ((sal_uInt32)p[1]) & 0xff) << 16 ) |\ ( ( ((sal_uInt32)p[2]) & 0xff) << 8 ) |\ |