From 5a3bb76cd384fa3760fe8481ce008791258595ad Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Fri, 12 Jan 2018 20:17:51 +0100 Subject: More loplugin:cstylecast: sal auto-rewrite with "Enable loplugin:cstylecast for some more cases" plus solenv/clang-format/reformat-formatted-files Change-Id: I7d89b011464ba5d2dd12e04d5fc9f65cb4daebde --- include/rtl/math.hxx | 4 +- include/rtl/string.hxx | 2 +- include/rtl/ustring.hxx | 2 +- sal/cppunittester/cppunittester.cxx | 4 +- sal/osl/unx/file.cxx | 18 ++-- sal/osl/unx/file_misc.cxx | 4 +- sal/osl/unx/file_volume.cxx | 12 +-- sal/osl/unx/pipe.cxx | 4 +- sal/osl/unx/process.cxx | 10 +-- sal/osl/unx/readwrite_helper.cxx | 4 +- sal/osl/unx/security.cxx | 4 +- sal/osl/unx/socket.cxx | 10 +-- sal/osl/unx/tempfile.cxx | 2 +- sal/osl/unx/time.cxx | 16 ++-- sal/qa/OStringBuffer/rtl_OStringBuffer.cxx | 100 +++++++++++------------ sal/qa/osl/process/osl_Thread.cxx | 84 +++++++++---------- sal/qa/rtl/digest/rtl_digest.cxx | 2 +- sal/qa/rtl/textenc/rtl_textcvt.cxx | 12 +-- sal/rtl/alloc_arena.cxx | 14 ++-- sal/rtl/alloc_arena.hxx | 8 +- sal/rtl/alloc_cache.cxx | 8 +- sal/rtl/alloc_impl.hxx | 6 +- sal/rtl/cipher.cxx | 58 ++++++------- sal/rtl/digest.cxx | 64 +++++++-------- sal/rtl/hash.cxx | 4 +- sal/rtl/locale.cxx | 4 +- sal/rtl/random.cxx | 14 ++-- sal/rtl/string.cxx | 10 +-- sal/rtl/strtmpl.cxx | 28 +++---- sal/rtl/ustrbuf.cxx | 8 +- sal/rtl/ustring.cxx | 56 ++++++------- sal/rtl/uuid.cxx | 24 +++--- sal/textenc/convertbig5hkscs.cxx | 12 +-- sal/textenc/converter.cxx | 4 +- sal/textenc/converteuctw.cxx | 13 ++- sal/textenc/convertgb18030.cxx | 13 ++- sal/textenc/convertiso2022cn.cxx | 15 ++-- sal/textenc/convertiso2022jp.cxx | 8 +- sal/textenc/convertiso2022kr.cxx | 6 +- sal/textenc/convertsimple.cxx | 2 +- sal/textenc/handleundefinedunicodetotextchar.cxx | 2 +- sal/textenc/tcvtbyte.cxx | 8 +- sal/textenc/tcvtmb.cxx | 25 +++--- sal/textenc/tcvtutf7.cxx | 10 +-- sal/textenc/tcvtutf8.cxx | 8 +- sal/textenc/textcvt.cxx | 4 +- 46 files changed, 363 insertions(+), 367 deletions(-) diff --git a/include/rtl/math.hxx b/include/rtl/math.hxx index 4cd21eae91fb..a965c7b38bca 100644 --- a/include/rtl/math.hxx +++ b/include/rtl/math.hxx @@ -181,7 +181,7 @@ inline double stringToDouble(rtl::OString const & rString, cDecSeparator, cGroupSeparator, pStatus, &pEnd); if (pParsedEnd != NULL) - *pParsedEnd = (sal_Int32)(pEnd - pBegin); + *pParsedEnd = static_cast(pEnd - pBegin); return fResult; } @@ -200,7 +200,7 @@ inline double stringToDouble(rtl::OUString const & rString, cDecSeparator, cGroupSeparator, pStatus, &pEnd); if (pParsedEnd != NULL) - *pParsedEnd = (sal_Int32)(pEnd - pBegin); + *pParsedEnd = static_cast(pEnd - pBegin); return fResult; } diff --git a/include/rtl/string.hxx b/include/rtl/string.hxx index ead2af45863e..de073293256a 100644 --- a/include/rtl/string.hxx +++ b/include/rtl/string.hxx @@ -1864,7 +1864,7 @@ struct OStringHash persistently, as its computation may change in later revisions. */ size_t operator()( const OString& rString ) const - { return (size_t)rString.hashCode(); } + { return static_cast(rString.hashCode()); } }; /** Equality functor for classic c-strings (i.e., null-terminated char* strings). */ diff --git a/include/rtl/ustring.hxx b/include/rtl/ustring.hxx index f5aa1312b000..1731bb905c76 100644 --- a/include/rtl/ustring.hxx +++ b/include/rtl/ustring.hxx @@ -3610,7 +3610,7 @@ struct OUStringHash persistently, as its computation may change in later revisions. */ size_t operator()(const OUString& rString) const - { return (size_t)rString.hashCode(); } + { return static_cast(rString.hashCode()); } }; /* ======================================================================= */ diff --git a/sal/cppunittester/cppunittester.cxx b/sal/cppunittester/cppunittester.cxx index 7d61bd399fbd..ed46fdd3adc1 100644 --- a/sal/cppunittester/cppunittester.cxx +++ b/sal/cppunittester/cppunittester.cxx @@ -339,8 +339,8 @@ public: double get_time(timeval* time) { - double nTime = (double)time->tv_sec; - nTime += ((double)time->tv_usec)/1000000.0; + double nTime = static_cast(time->tv_sec); + nTime += static_cast(time->tv_usec)/1000000.0; return nTime; } diff --git a/sal/osl/unx/file.cxx b/sal/osl/unx/file.cxx index 86d513a73225..5d0af4d774be 100644 --- a/sal/osl/unx/file.cxx +++ b/sal/osl/unx/file.cxx @@ -289,7 +289,7 @@ oslFileError FileHandle_Impl::setPos(sal_uInt64 uPos) sal_uInt64 FileHandle_Impl::getSize() const { - off_t const bufend = std::max((off_t)0, m_bufptr) + m_buflen; + off_t const bufend = std::max(off_t(0), m_bufptr) + m_buflen; return std::max(m_size, sal::static_int_cast< sal_uInt64 >(bufend)); } @@ -309,23 +309,23 @@ oslFileError FileHandle_Impl::setSize(sal_uInt64 uSize) } /* Save current position */ - off_t const nCurPos = lseek(m_fd, (off_t)0, SEEK_CUR); - if (nCurPos == (off_t)-1) + off_t const nCurPos = lseek(m_fd, off_t(0), SEEK_CUR); + if (nCurPos == off_t(-1)) return result; /* Try 'expand' via 'lseek()' and 'write()' */ - if (lseek(m_fd, (off_t)(nSize - 1), SEEK_SET) == -1) + if (lseek(m_fd, static_cast(nSize - 1), SEEK_SET) == -1) return result; - if (write(m_fd, "", (size_t)1) == -1) + if (write(m_fd, "", size_t(1)) == -1) { /* Failure. Restore saved position */ - (void) lseek(m_fd, (off_t)nCurPos, SEEK_SET); + (void) lseek(m_fd, static_cast(nCurPos), SEEK_SET); return result; } /* Success. Restore saved position */ - if (lseek(m_fd, (off_t)nCurPos, SEEK_SET) == -1) + if (lseek(m_fd, static_cast(nCurPos), SEEK_SET) == -1) return result; } @@ -354,13 +354,13 @@ oslFileError FileHandle_Impl::readAt( m_offset = nOffset; - if ((sal_uInt64) m_offset >= m_size) + if (static_cast(m_offset) >= m_size) { nBytes = 0; } else { - nBytes = std::min(nBytesRequested, (size_t) (m_size - m_offset)); + nBytes = std::min(nBytesRequested, static_cast(m_size - m_offset)); memmove(pBuffer, m_buffer + m_offset, nBytes); m_offset += nBytes; } diff --git a/sal/osl/unx/file_misc.cxx b/sal/osl/unx/file_misc.cxx index 5f7bdc5b010b..59bd82571733 100644 --- a/sal/osl/unx/file_misc.cxx +++ b/sal/osl/unx/file_misc.cxx @@ -746,7 +746,7 @@ static oslFileError osl_psz_copyFile( const sal_Char* pszPath, const sal_Char* p return osl_File_E_ISDIR; } - nSourceSize=(size_t)aFileStat.st_size; + nSourceSize=static_cast(aFileStat.st_size); nMode=aFileStat.st_mode; nAcTime=aFileStat.st_atime; nModTime=aFileStat.st_mtime; @@ -974,7 +974,7 @@ static int oslDoCopyFile(const sal_Char* pszSourceFileName, const sal_Char* pszD break; // We know nRead <= nToRead, so it must fit in a size_t - nRemains -= (size_t) nRead; + nRemains -= static_cast(nRead); } while( nRemains ); } diff --git a/sal/osl/unx/file_volume.cxx b/sal/osl/unx/file_volume.cxx index 5dc41cc0f7ea..103202b12310 100644 --- a/sal/osl/unx/file_volume.cxx +++ b/sal/osl/unx/file_volume.cxx @@ -161,7 +161,7 @@ oslFileError osl_getVolumeInformation( rtl_uString* ustrDirectoryURL, oslVolumeI # define OSL_detail_NTFS_SUPER_MAGIC 0x5346544e # define OSL_detail_STATFS_STRUCT struct statfs # define OSL_detail_STATFS(dir, sfs) statfs((dir), (sfs)) -# define OSL_detail_STATFS_BLKSIZ(a) ((sal_uInt64)((a).f_bsize)) +# define OSL_detail_STATFS_BLKSIZ(a) (static_cast((a).f_bsize)) # define OSL_detail_STATFS_IS_NFS(a) (OSL_detail_NFS_SUPER_MAGIC == (a).f_type) # define OSL_detail_STATFS_IS_SMB(a) (OSL_detail_SMB_SUPER_MAGIC == (a).f_type) # define OSL_detail_STATFS_ISREMOTE(a) (OSL_detail_STATFS_IS_NFS((a)) || OSL_detail_STATFS_IS_SMB((a))) @@ -250,7 +250,7 @@ static oslFileError osl_psz_getVolumeInformation ( (uFieldMask & osl_VolumeInfo_Mask_UsedSpace)) { pInfo->uTotalSpace = OSL_detail_STATFS_BLKSIZ(sfs); - pInfo->uTotalSpace *= (sal_uInt64)(sfs.f_blocks); + pInfo->uTotalSpace *= static_cast(sfs.f_blocks); pInfo->uValidFields |= osl_VolumeInfo_Mask_TotalSpace; } @@ -260,9 +260,9 @@ static oslFileError osl_psz_getVolumeInformation ( pInfo->uFreeSpace = OSL_detail_STATFS_BLKSIZ(sfs); if (getuid() == 0) - pInfo->uFreeSpace *= (sal_uInt64)(sfs.f_bfree); + pInfo->uFreeSpace *= static_cast(sfs.f_bfree); else - pInfo->uFreeSpace *= (sal_uInt64)(sfs.f_bavail); + pInfo->uFreeSpace *= static_cast(sfs.f_bavail); pInfo->uValidFields |= osl_VolumeInfo_Mask_FreeSpace; } @@ -300,7 +300,7 @@ static oslFileError osl_psz_getVolumeInformation ( long nLen = pathconf(pszDirectory, _PC_NAME_MAX); if (nLen > 0) { - pInfo->uMaxNameLength = (sal_uInt32)nLen; + pInfo->uMaxNameLength = static_cast(nLen); pInfo->uValidFields |= osl_VolumeInfo_Mask_MaxNameLength; } } @@ -311,7 +311,7 @@ static oslFileError osl_psz_getVolumeInformation ( long nLen = pathconf (pszDirectory, _PC_PATH_MAX); if (nLen > 0) { - pInfo->uMaxPathLength = (sal_uInt32)nLen; + pInfo->uMaxPathLength = static_cast(nLen); pInfo->uValidFields |= osl_VolumeInfo_Mask_MaxPathLength; } } diff --git a/sal/osl/unx/pipe.cxx b/sal/osl/unx/pipe.cxx index f4eca10fbd08..0c68255dbb1d 100644 --- a/sal/osl/unx/pipe.cxx +++ b/sal/osl/unx/pipe.cxx @@ -145,10 +145,10 @@ cpyBootstrapSocketPath(sal_Char *name, size_t len) { if (pStrValue->length > 0) { - size_t nCopy = (len-1 < (size_t)pStrValue->length) ? len-1 : (size_t)pStrValue->length; + size_t nCopy = (len-1 < static_cast(pStrValue->length)) ? len-1 : static_cast(pStrValue->length); strncpy (name, pStrValue->buffer, nCopy); name[nCopy] = '\0'; - bRet = (size_t)pStrValue->length < len; + bRet = static_cast(pStrValue->length) < len; } rtl_string_release(pStrValue); } diff --git a/sal/osl/unx/process.cxx b/sal/osl/unx/process.cxx index f65eb831c910..d3c1e096d8a8 100644 --- a/sal/osl/unx/process.cxx +++ b/sal/osl/unx/process.cxx @@ -169,7 +169,7 @@ static void ChildStatusProc(void *pData) if (channel[0] != -1) close(channel[0]); - if ((data.m_uid != (uid_t)-1) && ((data.m_uid != getuid()) || (data.m_gid != getgid()))) + if ((data.m_uid != uid_t(-1)) && ((data.m_uid != getuid()) || (data.m_gid != getgid()))) { OSL_ASSERT(geteuid() == 0); /* must be root */ @@ -183,7 +183,7 @@ static void ChildStatusProc(void *pData) if (data.m_pszDir) chstatus = chdir(data.m_pszDir); - if (chstatus == 0 && ((data.m_uid == (uid_t)-1) || ((data.m_uid == getuid()) && (data.m_gid == getgid())))) + if (chstatus == 0 && ((data.m_uid == uid_t(-1)) || ((data.m_uid == getuid()) && (data.m_gid == getgid())))) { int i; for (i = 0; data.m_pszEnv[i] != nullptr; i++) @@ -621,7 +621,7 @@ oslProcessError osl_psz_executeProcess(sal_Char *pszImageName, Data.m_name = static_cast(Security)->m_pPasswd.pw_name; } else - Data.m_uid = (uid_t)-1; + Data.m_uid = uid_t(-1); Data.m_pProcImpl = static_cast(malloc(sizeof(oslProcessImpl))); Data.m_pProcImpl->m_pid = 0; @@ -713,7 +713,7 @@ oslProcess SAL_CALL osl_getProcess(oslProcessIdentifier Ident) /* check if it is one of our child processes */ while (pChild != nullptr) { - if (Ident == (sal_uInt32) pChild->m_pid) + if (Ident == static_cast(pChild->m_pid)) break; pChild = pChild->m_pnext; @@ -1066,7 +1066,7 @@ oslProcessError SAL_CALL osl_getProcessInfo(oslProcess Process, oslProcessData F if (clktck < 0) { return osl_Process_E_Unknown; } - hz = (unsigned long) clktck; + hz = static_cast(clktck); userseconds = procstat.utime/hz; systemseconds = procstat.stime/hz; diff --git a/sal/osl/unx/readwrite_helper.cxx b/sal/osl/unx/readwrite_helper.cxx index c661eacd013f..c920f339aa61 100644 --- a/sal/osl/unx/readwrite_helper.cxx +++ b/sal/osl/unx/readwrite_helper.cxx @@ -18,7 +18,7 @@ bool safeWrite(int fd, void* data, sal_uInt32 dataSize) unsigned char* dataToWrite = static_cast(data); // Check for overflow as we convert a signed to an unsigned. - OSL_ASSERT(dataSize == (sal_uInt32)nToWrite); + OSL_ASSERT(dataSize == static_cast(nToWrite)); while ( nToWrite ) { sal_Int32 nWritten = write(fd, dataToWrite, nToWrite); if ( nWritten < 0 ) { @@ -43,7 +43,7 @@ bool safeRead( int fd, void* buffer, sal_uInt32 count ) unsigned char* bufferForReading = static_cast(buffer); // Check for overflow as we convert a signed to an unsigned. - OSL_ASSERT(count == (sal_uInt32)nToRead); + OSL_ASSERT(count == static_cast(nToRead)); while ( nToRead ) { sal_Int32 nRead = read(fd, bufferForReading, nToRead); if ( nRead < 0 ) { diff --git a/sal/osl/unx/security.cxx b/sal/osl/unx/security.cxx index cc69dfb5044b..e0d0ad210ed1 100644 --- a/sal/osl/unx/security.cxx +++ b/sal/osl/unx/security.cxx @@ -62,9 +62,9 @@ static bool sysconf_SC_GETPW_R_SIZE_MAX(std::size_t * value) { way and always set EINVAL, so be resilient here: */ return false; } - SAL_WARN_IF( m < 0 || (unsigned long) m >= std::numeric_limits::max(), "sal.osl", + SAL_WARN_IF( m < 0 || static_cast(m) >= std::numeric_limits::max(), "sal.osl", "m < 0 || (unsigned long) m >= std::numeric_limits::max()"); - *value = (std::size_t) m; + *value = static_cast(m); return true; #else /* some platforms like Mac OS X 1.3 do not define _SC_GETPW_R_SIZE_MAX: */ diff --git a/sal/osl/unx/socket.cxx b/sal/osl/unx/socket.cxx index 7f2a6a43a2ae..0ab10f3b07ac 100644 --- a/sal/osl/unx/socket.cxx +++ b/sal/osl/unx/socket.cxx @@ -108,7 +108,7 @@ static oslAddrFamily osl_AddrFamilyFromNative(sal_uInt32 nativeType) } #define FAMILY_FROM_NATIVE(y) osl_AddrFamilyFromNative(y) -#define FAMILY_TO_NATIVE(x) (short)FamilyMap[x] +#define FAMILY_TO_NATIVE(x) static_cast(FamilyMap[x]) static const sal_uInt32 ProtocolMap[]= { 0, /* osl_Socket_ProtocolIp */ @@ -326,7 +326,7 @@ static oslSocketAddr createSocketAddrWithFamily( pInetAddr->sin_family = FAMILY_TO_NATIVE(osl_Socket_FamilyInet); pInetAddr->sin_addr.s_addr = nAddr; - pInetAddr->sin_port = (sal_uInt16)(port&0xffff); + pInetAddr->sin_port = static_cast(port&0xffff); break; } default: @@ -582,7 +582,7 @@ static bool isFullQualifiedDomainName (const sal_Char *pHostName) * is a name which contains a dot '.' in it ( would * match as well for 'hostname.' but is good enough * for now )*/ - return strchr( pHostName, (int)'.' ) != nullptr; + return strchr( pHostName, int('.') ) != nullptr; } static sal_Char* getFullQualifiedDomainName (const sal_Char *pHostName) @@ -1080,7 +1080,7 @@ sal_Bool SAL_CALL osl_setInetPortOfSocketAddr(oslSocketAddr pAddr, sal_Int32 Por struct sockaddr_in* pSystemInetAddr= reinterpret_cast(&pAddr->m_sockaddr); if ( pSystemInetAddr->sin_family == FAMILY_TO_NATIVE(osl_Socket_FamilyInet)) { - pSystemInetAddr->sin_port= htons((short)Port); + pSystemInetAddr->sin_port= htons(static_cast(Port)); return true; } } @@ -2001,7 +2001,7 @@ sal_Int32 SAL_CALL osl_getSocketOption(oslSocket pSocket, void* pBuffer, sal_uInt32 BufferLen) { - socklen_t nOptLen = (socklen_t) BufferLen; + socklen_t nOptLen = static_cast(BufferLen); SAL_WARN_IF( !pSocket, "sal.osl", "undefined socket" ); if ( pSocket == nullptr ) diff --git a/sal/osl/unx/tempfile.cxx b/sal/osl/unx/tempfile.cxx index 5ba94ded4daa..2f9fb7182db6 100644 --- a/sal/osl/unx/tempfile.cxx +++ b/sal/osl/unx/tempfile.cxx @@ -83,7 +83,7 @@ static void osl_gen_random_name_impl_(rtl_uString** rand_name) gettimeofday(&tv, nullptr); - value += ((uint64_t)tv.tv_usec << 16) ^ tv.tv_sec ^ getpid(); + value += (static_cast(tv.tv_usec) << 16) ^ tv.tv_sec ^ getpid(); v = value; diff --git a/sal/osl/unx/time.cxx b/sal/osl/unx/time.cxx index 61d452434d64..4e42e2dcac9a 100644 --- a/sal/osl/unx/time.cxx +++ b/sal/osl/unx/time.cxx @@ -94,7 +94,7 @@ sal_Bool SAL_CALL osl_getDateTimeFromTimeValue( const TimeValue* pTimeVal, oslDa struct tm tmBuf; time_t atime; - atime = (time_t)pTimeVal->Seconds; + atime = static_cast(pTimeVal->Seconds); /* Convert time from type time_t to struct tm */ pSystemTime = gmtime_r( &atime, &tmBuf ); @@ -152,7 +152,7 @@ sal_Bool SAL_CALL osl_getTimeValueFromDateTime( const oslDateTime* pDateTime, Ti * the returned value to be timezone neutral. */ - if ( nSeconds != (time_t) -1 ) + if ( nSeconds != time_t(-1) ) { time_t bias; @@ -190,7 +190,7 @@ sal_Bool SAL_CALL osl_getLocalTimeFromSystemTime( const TimeValue* pSystemTimeVa time_t bias; time_t atime; - atime = (time_t) pSystemTimeVal->Seconds; + atime = static_cast(pSystemTimeVal->Seconds); pLocalTime = localtime_r( &atime, &tmBuf ); #if defined(STRUCT_TM_HAS_GMTOFF) @@ -205,7 +205,7 @@ sal_Bool SAL_CALL osl_getLocalTimeFromSystemTime( const TimeValue* pSystemTimeVa bias = pLocalTime->tm_isdst > 0 ? timezone - 3600 : timezone; #endif - if ( (sal_Int64) pSystemTimeVal->Seconds > bias ) + if ( static_cast(pSystemTimeVal->Seconds) > bias ) { pLocalTimeVal->Seconds = pSystemTimeVal->Seconds - bias; pLocalTimeVal->Nanosec = pSystemTimeVal->Nanosec; @@ -223,7 +223,7 @@ sal_Bool SAL_CALL osl_getSystemTimeFromLocalTime( const TimeValue* pLocalTimeVal time_t bias; time_t atime; - atime = (time_t) pLocalTimeVal->Seconds; + atime = static_cast(pLocalTimeVal->Seconds); /* Convert atime, which is a local time, to its GMT equivalent. Then, get * the timezone offset for the local time for the GMT equivalent time. Note @@ -247,7 +247,7 @@ sal_Bool SAL_CALL osl_getSystemTimeFromLocalTime( const TimeValue* pLocalTimeVal bias = pLocalTime->tm_isdst > 0 ? timezone - 3600 : timezone; #endif - if ( (sal_Int64) pLocalTimeVal->Seconds + bias > 0 ) + if ( static_cast(pLocalTimeVal->Seconds) + bias > 0 ) { pSystemTimeVal->Seconds = pLocalTimeVal->Seconds + bias; pSystemTimeVal->Nanosec = pLocalTimeVal->Nanosec; @@ -298,9 +298,9 @@ sal_uInt32 SAL_CALL osl_getGlobalTimer() gettimeofday( ¤tTime, NULL ); #endif - nSeconds = (sal_uInt32)( currentTime.tv_sec - startTime.tv_sec ); + nSeconds = static_cast( currentTime.tv_sec - startTime.tv_sec ); #if defined(USE_CLOCK_GETTIME) - nSeconds = ( nSeconds * 1000 ) + (long) (( currentTime.tv_nsec - startTime.tv_nsec) / 1000000 ); + nSeconds = ( nSeconds * 1000 ) + static_cast(( currentTime.tv_nsec - startTime.tv_nsec) / 1000000 ); #else nSeconds = ( nSeconds * 1000 ) + (long) (( currentTime.tv_usec - startTime.tv_usec) / 1000 ); #endif diff --git a/sal/qa/OStringBuffer/rtl_OStringBuffer.cxx b/sal/qa/OStringBuffer/rtl_OStringBuffer.cxx index b4aa4e3c053a..3afd07f8dcab 100644 --- a/sal/qa/OStringBuffer/rtl_OStringBuffer.cxx +++ b/sal/qa/OStringBuffer/rtl_OStringBuffer.cxx @@ -14755,7 +14755,7 @@ namespace rtl_OStringBuffer void append_001() { ::rtl::OStringBuffer aStrBuf( *arrOUS[0] ); - float input = (float)atof("3.0"); + float input = static_cast(atof("3.0")); // LLA: // the complex problem is here, that a float value is not really what we write. @@ -14775,7 +14775,7 @@ namespace rtl_OStringBuffer void append_002() { ::rtl::OStringBuffer aStrBuf( *arrOUS[0] ); - float input = (float)atof("3.5"); + float input = static_cast(atof("3.5")); sal_Int32 nLen = aStrBuf.getLength(); aStrBuf.append( input ); @@ -14791,7 +14791,7 @@ namespace rtl_OStringBuffer void append_003() { ::rtl::OStringBuffer aStrBuf( *arrOUS[0] ); - float input = (float)atof("3.0625"); + float input = static_cast(atof("3.0625")); sal_Int32 nLen = aStrBuf.getLength(); aStrBuf.append( input ); @@ -14807,7 +14807,7 @@ namespace rtl_OStringBuffer void append_004() { ::rtl::OStringBuffer aStrBuf( *arrOUS[0] ); - float input = (float)atof("3.502525"); + float input = static_cast(atof("3.502525")); sal_Int32 nLen = aStrBuf.getLength(); aStrBuf.append( input ); @@ -14823,7 +14823,7 @@ namespace rtl_OStringBuffer void append_005() { ::rtl::OStringBuffer aStrBuf( *arrOUS[0] ); - float input = (float)atof("3.141592"); + float input = static_cast(atof("3.141592")); sal_Int32 nLen = aStrBuf.getLength(); aStrBuf.append( input ); @@ -14839,7 +14839,7 @@ namespace rtl_OStringBuffer void append_006() { ::rtl::OStringBuffer aStrBuf( *arrOUS[0] ); - float input = (float)atof("3.5025255"); + float input = static_cast(atof("3.5025255")); sal_Int32 nLen = aStrBuf.getLength(); aStrBuf.append( input ); @@ -14855,7 +14855,7 @@ namespace rtl_OStringBuffer void append_007() { ::rtl::OStringBuffer aStrBuf( *arrOUS[0] ); - float input = (float)atof("3.00390625"); + float input = static_cast(atof("3.00390625")); sal_Int32 nLen = aStrBuf.getLength(); aStrBuf.append( input ); @@ -14871,7 +14871,7 @@ namespace rtl_OStringBuffer void append_008() { ::rtl::OStringBuffer aStrBuf( *arrOUS[1] ); - float input = (float)atof("3.0"); + float input = static_cast(atof("3.0")); sal_Int32 nLen = aStrBuf.getLength(); aStrBuf.append( input ); @@ -14887,7 +14887,7 @@ namespace rtl_OStringBuffer void append_009() { ::rtl::OStringBuffer aStrBuf( *arrOUS[1] ); - float input = (float)atof("3.5"); + float input = static_cast(atof("3.5")); sal_Int32 nLen = aStrBuf.getLength(); aStrBuf.append( input ); @@ -14903,7 +14903,7 @@ namespace rtl_OStringBuffer void append_010() { ::rtl::OStringBuffer aStrBuf( *arrOUS[1] ); - float input = (float)atof("3.0625"); + float input = static_cast(atof("3.0625")); sal_Int32 nLen = aStrBuf.getLength(); aStrBuf.append( input ); @@ -14919,7 +14919,7 @@ namespace rtl_OStringBuffer void append_011() { ::rtl::OStringBuffer aStrBuf( *arrOUS[1] ); - float input = (float)atof("3.502525"); + float input = static_cast(atof("3.502525")); sal_Int32 nLen = aStrBuf.getLength(); aStrBuf.append( input ); @@ -14935,7 +14935,7 @@ namespace rtl_OStringBuffer void append_012() { ::rtl::OStringBuffer aStrBuf( *arrOUS[1] ); - float input = (float)atof("3.141592"); + float input = static_cast(atof("3.141592")); sal_Int32 nLen = aStrBuf.getLength(); aStrBuf.append( input ); @@ -14951,7 +14951,7 @@ namespace rtl_OStringBuffer void append_013() { ::rtl::OStringBuffer aStrBuf( *arrOUS[1] ); - float input = (float)atof("3.5025255"); + float input = static_cast(atof("3.5025255")); sal_Int32 nLen = aStrBuf.getLength(); aStrBuf.append( input ); @@ -14967,7 +14967,7 @@ namespace rtl_OStringBuffer void append_014() { ::rtl::OStringBuffer aStrBuf( *arrOUS[1] ); - float input = (float)atof("3.00390625"); + float input = static_cast(atof("3.00390625")); sal_Int32 nLen = aStrBuf.getLength(); aStrBuf.append( input ); @@ -14983,7 +14983,7 @@ namespace rtl_OStringBuffer void append_015() { ::rtl::OStringBuffer aStrBuf( *arrOUS[2] ); - float input = (float)atof("3.0"); + float input = static_cast(atof("3.0")); sal_Int32 nLen = aStrBuf.getLength(); aStrBuf.append( input ); @@ -14999,7 +14999,7 @@ namespace rtl_OStringBuffer void append_016() { ::rtl::OStringBuffer aStrBuf( *arrOUS[2] ); - float input = (float)atof("3.5"); + float input = static_cast(atof("3.5")); sal_Int32 nLen = aStrBuf.getLength(); aStrBuf.append( input ); @@ -15015,7 +15015,7 @@ namespace rtl_OStringBuffer void append_017() { ::rtl::OStringBuffer aStrBuf( *arrOUS[2] ); - float input = (float)atof("3.0625"); + float input = static_cast(atof("3.0625")); sal_Int32 nLen = aStrBuf.getLength(); aStrBuf.append( input ); @@ -15031,7 +15031,7 @@ namespace rtl_OStringBuffer void append_018() { ::rtl::OStringBuffer aStrBuf( *arrOUS[2] ); - float input = (float)atof("3.502525"); + float input = static_cast(atof("3.502525")); sal_Int32 nLen = aStrBuf.getLength(); aStrBuf.append( input ); @@ -15047,7 +15047,7 @@ namespace rtl_OStringBuffer void append_019() { ::rtl::OStringBuffer aStrBuf( *arrOUS[2] ); - float input = (float)atof("3.141592"); + float input = static_cast(atof("3.141592")); sal_Int32 nLen = aStrBuf.getLength(); aStrBuf.append( input ); @@ -15063,7 +15063,7 @@ namespace rtl_OStringBuffer void append_020() { ::rtl::OStringBuffer aStrBuf( *arrOUS[2] ); - float input = (float)atof("3.5025255"); + float input = static_cast(atof("3.5025255")); sal_Int32 nLen = aStrBuf.getLength(); aStrBuf.append( input ); @@ -15079,7 +15079,7 @@ namespace rtl_OStringBuffer void append_021() { ::rtl::OStringBuffer aStrBuf( *arrOUS[2] ); - float input = (float)atof("3.00390625"); + float input = static_cast(atof("3.00390625")); sal_Int32 nLen = aStrBuf.getLength(); aStrBuf.append( input ); @@ -15095,7 +15095,7 @@ namespace rtl_OStringBuffer void append_022() { ::rtl::OStringBuffer aStrBuf( *arrOUS[3] ); - float input = (float)atof("3.0"); + float input = static_cast(atof("3.0")); sal_Int32 nLen = aStrBuf.getLength(); aStrBuf.append( input ); @@ -15111,7 +15111,7 @@ namespace rtl_OStringBuffer void append_023() { ::rtl::OStringBuffer aStrBuf( *arrOUS[3] ); - float input = (float)atof("3.5"); + float input = static_cast(atof("3.5")); sal_Int32 nLen = aStrBuf.getLength(); aStrBuf.append( input ); @@ -15127,7 +15127,7 @@ namespace rtl_OStringBuffer void append_024() { ::rtl::OStringBuffer aStrBuf( *arrOUS[3] ); - float input = (float)atof("3.0625"); + float input = static_cast(atof("3.0625")); sal_Int32 nLen = aStrBuf.getLength(); aStrBuf.append( input ); @@ -15143,7 +15143,7 @@ namespace rtl_OStringBuffer void append_025() { ::rtl::OStringBuffer aStrBuf( *arrOUS[3] ); - float input = (float)atof("3.502525"); + float input = static_cast(atof("3.502525")); sal_Int32 nLen = aStrBuf.getLength(); aStrBuf.append( input ); @@ -15332,7 +15332,7 @@ namespace rtl_OStringBuffer void append_001() { ::rtl::OStringBuffer aStrBuf( *arrOUS[0] ); - float input = (float)atof("-3.0"); + float input = static_cast(atof("-3.0")); sal_Int32 nLen = aStrBuf.getLength(); aStrBuf.append( input ); @@ -15348,7 +15348,7 @@ namespace rtl_OStringBuffer void append_002() { ::rtl::OStringBuffer aStrBuf( *arrOUS[0] ); - float input = (float)atof("-3.5"); + float input = static_cast(atof("-3.5")); sal_Int32 nLen = aStrBuf.getLength(); aStrBuf.append( input ); @@ -15364,7 +15364,7 @@ namespace rtl_OStringBuffer void append_003() { ::rtl::OStringBuffer aStrBuf( *arrOUS[0] ); - float input = (float)atof("-3.0625"); + float input = static_cast(atof("-3.0625")); sal_Int32 nLen = aStrBuf.getLength(); aStrBuf.append( input ); @@ -15380,7 +15380,7 @@ namespace rtl_OStringBuffer void append_004() { ::rtl::OStringBuffer aStrBuf( *arrOUS[0] ); - float input = (float)atof("-3.502525"); + float input = static_cast(atof("-3.502525")); sal_Int32 nLen = aStrBuf.getLength(); aStrBuf.append( input ); @@ -15396,7 +15396,7 @@ namespace rtl_OStringBuffer void append_005() { ::rtl::OStringBuffer aStrBuf( *arrOUS[0] ); - float input = (float)atof("-3.141592"); + float input = static_cast(atof("-3.141592")); sal_Int32 nLen = aStrBuf.getLength(); aStrBuf.append( input ); @@ -15412,7 +15412,7 @@ namespace rtl_OStringBuffer void append_006() { ::rtl::OStringBuffer aStrBuf( *arrOUS[0] ); - float input = (float)atof("-3.5025255"); + float input = static_cast(atof("-3.5025255")); sal_Int32 nLen = aStrBuf.getLength(); aStrBuf.append( input ); @@ -15428,7 +15428,7 @@ namespace rtl_OStringBuffer void append_007() { ::rtl::OStringBuffer aStrBuf( *arrOUS[0] ); - float input = (float)atof("-3.00390625"); + float input = static_cast(atof("-3.00390625")); sal_Int32 nLen = aStrBuf.getLength(); aStrBuf.append( input ); @@ -15444,7 +15444,7 @@ namespace rtl_OStringBuffer void append_008() { ::rtl::OStringBuffer aStrBuf( *arrOUS[1] ); - float input = (float)atof("-3.0"); + float input = static_cast(atof("-3.0")); sal_Int32 nLen = aStrBuf.getLength(); aStrBuf.append( input ); @@ -15460,7 +15460,7 @@ namespace rtl_OStringBuffer void append_009() { ::rtl::OStringBuffer aStrBuf( *arrOUS[1] ); - float input = (float)atof("-3.5"); + float input = static_cast(atof("-3.5")); sal_Int32 nLen = aStrBuf.getLength(); aStrBuf.append( input ); @@ -15476,7 +15476,7 @@ namespace rtl_OStringBuffer void append_010() { ::rtl::OStringBuffer aStrBuf( *arrOUS[1] ); - float input = (float)atof("-3.0625"); + float input = static_cast(atof("-3.0625")); sal_Int32 nLen = aStrBuf.getLength(); aStrBuf.append( input ); @@ -15492,7 +15492,7 @@ namespace rtl_OStringBuffer void append_011() { ::rtl::OStringBuffer aStrBuf( *arrOUS[1] ); - float input = (float)atof("-3.502525"); + float input = static_cast(atof("-3.502525")); sal_Int32 nLen = aStrBuf.getLength(); aStrBuf.append( input ); @@ -15508,7 +15508,7 @@ namespace rtl_OStringBuffer void append_012() { ::rtl::OStringBuffer aStrBuf( *arrOUS[1] ); - float input = (float)atof("-3.141592"); + float input = static_cast(atof("-3.141592")); sal_Int32 nLen = aStrBuf.getLength(); aStrBuf.append( input ); @@ -15524,7 +15524,7 @@ namespace rtl_OStringBuffer void append_013() { ::rtl::OStringBuffer aStrBuf( *arrOUS[1] ); - float input = (float)atof("-3.5025255"); + float input = static_cast(atof("-3.5025255")); sal_Int32 nLen = aStrBuf.getLength(); aStrBuf.append( input ); @@ -15540,7 +15540,7 @@ namespace rtl_OStringBuffer void append_014() { ::rtl::OStringBuffer aStrBuf( *arrOUS[1] ); - float input = (float)atof("-3.00390625"); + float input = static_cast(atof("-3.00390625")); sal_Int32 nLen = aStrBuf.getLength(); aStrBuf.append( input ); @@ -15556,7 +15556,7 @@ namespace rtl_OStringBuffer void append_015() { ::rtl::OStringBuffer aStrBuf( *arrOUS[2] ); - float input = (float)atof("-3.0"); + float input = static_cast(atof("-3.0")); sal_Int32 nLen = aStrBuf.getLength(); aStrBuf.append( input ); @@ -15572,7 +15572,7 @@ namespace rtl_OStringBuffer void append_016() { ::rtl::OStringBuffer aStrBuf( *arrOUS[2] ); - float input = (float)atof("-3.5"); + float input = static_cast(atof("-3.5")); sal_Int32 nLen = aStrBuf.getLength(); aStrBuf.append( input ); @@ -15588,7 +15588,7 @@ namespace rtl_OStringBuffer void append_017() { ::rtl::OStringBuffer aStrBuf( *arrOUS[2] ); - float input = (float)atof("-3.0625"); + float input = static_cast(atof("-3.0625")); sal_Int32 nLen = aStrBuf.getLength(); aStrBuf.append( input ); @@ -15604,7 +15604,7 @@ namespace rtl_OStringBuffer void append_018() { ::rtl::OStringBuffer aStrBuf( *arrOUS[2] ); - float input = (float)atof("-3.502525"); + float input = static_cast(atof("-3.502525")); sal_Int32 nLen = aStrBuf.getLength(); aStrBuf.append( input ); @@ -15620,7 +15620,7 @@ namespace rtl_OStringBuffer void append_019() { ::rtl::OStringBuffer aStrBuf( *arrOUS[2] ); - float input = (float)atof("-3.141592"); + float input = static_cast(atof("-3.141592")); sal_Int32 nLen = aStrBuf.getLength(); aStrBuf.append( input ); @@ -15636,7 +15636,7 @@ namespace rtl_OStringBuffer void append_020() { ::rtl::OStringBuffer aStrBuf( *arrOUS[2] ); - float input = (float)atof("-3.5025255"); + float input = static_cast(atof("-3.5025255")); sal_Int32 nLen = aStrBuf.getLength(); aStrBuf.append( input ); @@ -15652,7 +15652,7 @@ namespace rtl_OStringBuffer void append_021() { ::rtl::OStringBuffer aStrBuf( *arrOUS[2] ); - float input = (float)atof("-3.00390625"); + float input = static_cast(atof("-3.00390625")); sal_Int32 nLen = aStrBuf.getLength(); aStrBuf.append( input ); @@ -15668,7 +15668,7 @@ namespace rtl_OStringBuffer void append_022() { ::rtl::OStringBuffer aStrBuf( *arrOUS[3] ); - float input = (float)atof("-3.0"); + float input = static_cast(atof("-3.0")); sal_Int32 nLen = aStrBuf.getLength(); aStrBuf.append( input ); @@ -15684,7 +15684,7 @@ namespace rtl_OStringBuffer void append_023() { ::rtl::OStringBuffer aStrBuf( *arrOUS[3] ); - float input = (float)atof("-3.5"); + float input = static_cast(atof("-3.5")); sal_Int32 nLen = aStrBuf.getLength(); aStrBuf.append( input ); @@ -15700,7 +15700,7 @@ namespace rtl_OStringBuffer void append_024() { ::rtl::OStringBuffer aStrBuf( *arrOUS[3] ); - float input = (float)atof("-3.0625"); + float input = static_cast(atof("-3.0625")); sal_Int32 nLen = aStrBuf.getLength(); aStrBuf.append( input ); @@ -15716,7 +15716,7 @@ namespace rtl_OStringBuffer void append_025() { ::rtl::OStringBuffer aStrBuf( *arrOUS[3] ); - float input = (float)atof("-3.502525"); + float input = static_cast(atof("-3.502525")); sal_Int32 nLen = aStrBuf.getLength(); aStrBuf.append( input ); diff --git a/sal/qa/osl/process/osl_Thread.cxx b/sal/qa/osl/process/osl_Thread.cxx index ae23a9ef41a0..396aa86efdb4 100644 --- a/sal/qa/osl/process/osl_Thread.cxx +++ b/sal/qa/osl/process/osl_Thread.cxx @@ -96,7 +96,7 @@ void StopWatch::start() m_bIsValid = false; m_bIsRunning = true; osl_getSystemTime( &t1 ); - t_print("# %u %u nsecs\n", (unsigned)t1.Seconds, (unsigned)t1.Nanosec); + t_print("# %u %u nsecs\n", static_cast(t1.Seconds), static_cast(t1.Nanosec)); // gettimeofday(&t1, 0); } @@ -107,7 +107,7 @@ void StopWatch::stop() // gettimeofday(&t2, 0); // Ask timer osl_getSystemTime( &t2 ); - t_print("# %u %u nsecs\n", (unsigned) t2.Seconds, (unsigned) t2.Nanosec); + t_print("# %u %u nsecs\n", static_cast(t2.Seconds), static_cast(t2.Nanosec)); if (m_bIsRunning) { // check if started. @@ -119,7 +119,7 @@ void StopWatch::stop() m_nNanoSec = 1000000000 + static_cast(t2.Nanosec) - static_cast(t1.Nanosec); m_nSeconds -= 1; } - t_print("# %u %u nsecs\n", (unsigned) m_nSeconds, (unsigned) m_nNanoSec ); + t_print("# %u %u nsecs\n", static_cast(m_nSeconds), static_cast(m_nNanoSec) ); //if (m_nNanoSec < 0) //{ //m_nNanoSec += 1000000000; @@ -271,7 +271,7 @@ public: OCountThread() { m_nWaitSec = 0; - t_print("new OCountThread thread %u!\n", (unsigned) getIdentifier()); + t_print("new OCountThread thread %u!\n", static_cast(getIdentifier())); } sal_Int32 getValue() { return m_aFlag.getValue(); } @@ -312,7 +312,7 @@ protected: } void SAL_CALL onTerminated() override { - t_print("normally terminate this thread %u!\n", (unsigned) getIdentifier()); + t_print("normally terminate this thread %u!\n", static_cast(getIdentifier())); } public: @@ -351,12 +351,12 @@ protected: } void SAL_CALL onTerminated() override { - t_print("normally terminate this thread %u!\n", (unsigned) getIdentifier()); + t_print("normally terminate this thread %u!\n", static_cast(getIdentifier())); } public: ONoScheduleThread() { - t_print("new thread id %u!\n", (unsigned) getIdentifier()); + t_print("new thread id %u!\n", static_cast(getIdentifier())); } virtual ~ONoScheduleThread() override { @@ -467,7 +467,7 @@ namespace osl_Thread termAndJoinThread(newthread); delete newthread; - t_print(" nValue = %d\n", (int) nValue); + t_print(" nValue = %d\n", static_cast(nValue)); t_print("isRunning = %s\n", isRunning ? "true" : "false"); CPPUNIT_ASSERT_MESSAGE( @@ -671,9 +671,9 @@ namespace osl_Thread termAndJoinThread(pCountThread); delete pCountThread; - t_print("SuspendValue: %d\n", (int) nSuspendValue); - t_print("ResumeValue: %d\n", (int) nResumeValue); - t_print("LaterValue: %d\n", (int) nLaterValue); + t_print("SuspendValue: %d\n", static_cast(nSuspendValue)); + t_print("ResumeValue: %d\n", static_cast(nResumeValue)); + t_print("LaterValue: %d\n", static_cast(nLaterValue)); /* LLA: this assumption is no longer relevant: nResumeValue == nSuspendValue && */ CPPUNIT_ASSERT_MESSAGE( @@ -706,7 +706,7 @@ namespace osl_Thread termAndJoinThread(newthread); delete newthread; - t_print(" nValue = %d\n", (int) nValue); + t_print(" nValue = %d\n", static_cast(nValue)); CPPUNIT_ASSERT_MESSAGE( "Creates a suspended thread, then resume", @@ -747,8 +747,8 @@ namespace osl_Thread aCountThread->join(); delete aCountThread; - t_print(" nValue = %d\n", (int) nValue); - t_print("nLaterValue = %d\n", (int) nLaterValue); + t_print(" nValue = %d\n", static_cast(nValue)); + t_print("nLaterValue = %d\n", static_cast(nLaterValue)); CPPUNIT_ASSERT_MESSAGE( "Terminate the thread", @@ -780,8 +780,8 @@ namespace osl_Thread sal_Int32 nLaterValue = aCountThread->getValue(); delete aCountThread; - t_print(" nValue = %d\n", (int) nValue); - t_print("nLaterValue = %d\n", (int) nLaterValue); + t_print(" nValue = %d\n", static_cast(nValue)); + t_print("nLaterValue = %d\n", static_cast(nLaterValue)); CPPUNIT_ASSERT_MESSAGE( "Suspend then resume the thread", @@ -1013,8 +1013,8 @@ namespace osl_Thread rtl::OString sPrio = getPrioName(_aPriority); t_print("After 10 tenth seconds\n"); - t_print("nValue in %s Prio Thread is %d\n",sPrio.getStr(), (int) nValueNormal); - t_print("nValue in %s Prio Thread is %d\n", sPrio.getStr(), (int) nValueNormal2); + t_print("nValue in %s Prio Thread is %d\n",sPrio.getStr(), static_cast(nValueNormal)); + t_print("nValue in %s Prio Thread is %d\n", sPrio.getStr(), static_cast(nValueNormal2)); // ThreadHelper::thread_sleep_tenth_sec(1); pThread->join(); @@ -1031,7 +1031,7 @@ namespace osl_Thread ); double nDeltaPercent = nDelta / nQuotient * 100; - t_print("Delta value %d, percent %f\n", (int) nDelta, nDeltaPercent); + t_print("Delta value %d, percent %f\n", static_cast(nDelta), nDeltaPercent); // LLA: it's not a bug if the current OS is not able to handle thread scheduling right and good. // like Windows XP @@ -1113,9 +1113,9 @@ namespace osl_Thread nValueNormal = aNormalThread.getValue(); t_print("After 10 tenth seconds\n"); - t_print("nValue in Highest Prio Thread is %d\n", (int) nValueHighest); - t_print("nValue in AboveNormal Prio Thread is %d\n", (int) nValueAboveNormal); - t_print("nValue in Normal Prio Thread is %d\n", (int) nValueNormal); + t_print("nValue in Highest Prio Thread is %d\n", static_cast(nValueHighest)); + t_print("nValue in AboveNormal Prio Thread is %d\n", static_cast(nValueAboveNormal)); + t_print("nValue in Normal Prio Thread is %d\n", static_cast(nValueNormal)); #ifndef _WIN32 CPPUNIT_ASSERT_MESSAGE( @@ -1194,11 +1194,11 @@ namespace osl_Thread nValueLowest = pLowestThread.getValue(); t_print("After 10 tenth seconds\n"); - t_print("nValue in Highest Prio Thread is %d\n", (int) nValueHighest); - t_print("nValue in AboveNormal Prio Thread is %d\n", (int) nValueAboveNormal); - t_print("nValue in Normal Prio Thread is %d\n", (int) nValueNormal); - t_print("nValue in BelowNormal Prio Thread is %d\n", (int) nValueBelowNormal); - t_print("nValue in Lowest Prio Thread is %d\n", (int) nValueLowest); + t_print("nValue in Highest Prio Thread is %d\n", static_cast(nValueHighest)); + t_print("nValue in AboveNormal Prio Thread is %d\n", static_cast(nValueAboveNormal)); + t_print("nValue in Normal Prio Thread is %d\n", static_cast(nValueNormal)); + t_print("nValue in BelowNormal Prio Thread is %d\n", static_cast(nValueBelowNormal)); + t_print("nValue in Lowest Prio Thread is %d\n", static_cast(nValueLowest)); #ifndef _WIN32 CPPUNIT_ASSERT_MESSAGE( @@ -1279,10 +1279,10 @@ namespace osl_Thread nValueLowest = pLowestThread.getValue(); t_print("After 5 tenth seconds\n"); - t_print("nValue in AboveNormal Prio Thread is %d\n", (int) nValueAboveNormal); - t_print("nValue in Normal Prio Thread is %d\n", (int) nValueNormal); - t_print("nValue in BelowNormal Prio Thread is %d\n", (int) nValueBelowNormal); - t_print("nValue in Lowest Prio Thread is %d\n", (int) nValueLowest); + t_print("nValue in AboveNormal Prio Thread is %d\n", static_cast(nValueAboveNormal)); + t_print("nValue in Normal Prio Thread is %d\n", static_cast(nValueNormal)); + t_print("nValue in BelowNormal Prio Thread is %d\n", static_cast(nValueBelowNormal)); + t_print("nValue in Lowest Prio Thread is %d\n", static_cast(nValueLowest)); // delete pHighestThread; @@ -1364,9 +1364,9 @@ namespace osl_Thread nValueLowest = pLowestThread.getValue(); t_print("After 5 tenth seconds\n"); - t_print("nValue in Normal Prio Thread is %d\n", (int) nValueNormal); - t_print("nValue in BelowNormal Prio Thread is %d\n", (int) nValueBelowNormal); - t_print("nValue in Lowest Prio Thread is %d\n", (int) nValueLowest); + t_print("nValue in Normal Prio Thread is %d\n", static_cast(nValueNormal)); + t_print("nValue in BelowNormal Prio Thread is %d\n", static_cast(nValueBelowNormal)); + t_print("nValue in Lowest Prio Thread is %d\n", static_cast(nValueLowest)); #ifndef _WIN32 CPPUNIT_ASSERT_MESSAGE( @@ -1526,7 +1526,7 @@ namespace osl_Thread delete aCountThread; t_print("nTenthSec = %f \n", nTenthSec); t_print("nSec = %f \n", nSec); - t_print("nValue = %d \n", (int) nValue); + t_print("nValue = %d \n", static_cast(nValue)); CPPUNIT_ASSERT_MESSAGE( "Wait: Blocks the calling thread for the given number of time.", @@ -1586,8 +1586,8 @@ namespace osl_Thread ThreadHelper::thread_sleep_tenth_sec(3); sal_Int32 nLaterValue = aThread->getValue(); // resumeAndWaitThread(aThread); - t_print(" value = %d\n", (int) nValue); - t_print("later value = %d\n", (int) nLaterValue); + t_print(" value = %d\n", static_cast(nValue)); + t_print("later value = %d\n", static_cast(nLaterValue)); // if value and latervalue not equal, than the thread would not suspended CPPUNIT_ASSERT_EQUAL_MESSAGE( @@ -1604,8 +1604,8 @@ namespace osl_Thread aThread->join(); sal_Int32 nValue_join = aThread->getValue(); - t_print("value after term = %d\n", (int) nValue_term); - t_print("value after join = %d\n", (int) nValue_join); + t_print("value after term = %d\n", static_cast(nValue_term)); + t_print("value after join = %d\n", static_cast(nValue_join)); // nValue_term and nValue_join should be the same // but should be differ from nValue @@ -1641,8 +1641,8 @@ namespace osl_Thread resumeAndWaitThread(&aThread); - t_print(" value = %d\n", (int) nValue); - t_print("later value = %d\n", (int) nLaterValue); + t_print(" value = %d\n", static_cast(nValue)); + t_print("later value = %d\n", static_cast(nLaterValue)); //On windows, suspend works, so the values are same #ifdef _WIN32 @@ -1665,7 +1665,7 @@ namespace osl_Thread termAndJoinThread(&aThread); sal_Int32 nValue_term = aThread.getValue(); - t_print(" value term = %d\n", (int) nValue_term); + t_print(" value term = %d\n", static_cast(nValue_term)); CPPUNIT_ASSERT_EQUAL_MESSAGE( "Schedule: don't schedule in thread run method, terminate failed.", diff --git a/sal/qa/rtl/digest/rtl_digest.cxx b/sal/qa/rtl/digest/rtl_digest.cxx index 6b693067785f..e022cd500d65 100644 --- a/sal/qa/rtl/digest/rtl_digest.cxx +++ b/sal/qa/rtl/digest/rtl_digest.cxx @@ -76,7 +76,7 @@ OString createHex(const sal_uInt8* pKeyBuffer, sal_uInt32 nKeyLen) OStringBuffer aBuffer(nKeyLen * 2 + 1); for (sal_uInt32 i = 0; i < nKeyLen; ++i) { - sal_Int32 nValue = (sal_Int32) pKeyBuffer[i]; + sal_Int32 nValue = static_cast(pKeyBuffer[i]); if (nValue < 16) aBuffer.append('0'); aBuffer.append(nValue, 16); diff --git a/sal/qa/rtl/textenc/rtl_textcvt.cxx b/sal/qa/rtl/textenc/rtl_textcvt.cxx index 77d7c6a82ac3..4bfdc41742e8 100644 --- a/sal/qa/rtl/textenc/rtl_textcvt.cxx +++ b/sal/qa/rtl/textenc/rtl_textcvt.cxx @@ -71,7 +71,7 @@ void testSingleByteCharSet(SingleByteCharSet const & rSet) { | RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR), &nInfo, &nConverted); CPPUNIT_ASSERT_EQUAL(nNumber, nSize); - CPPUNIT_ASSERT_EQUAL((sal_uInt32)0, nInfo); + CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), nInfo); CPPUNIT_ASSERT_EQUAL(nNumber, nConverted); rtl_destroyTextToUnicodeContext(aConverter, aContext); rtl_destroyTextToUnicodeConverter(aConverter); @@ -116,7 +116,7 @@ void testSingleByteCharSet(SingleByteCharSet const & rSet) { | RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR), &nInfo, &nConverted); CPPUNIT_ASSERT_EQUAL(nNumber, nSize); - CPPUNIT_ASSERT_EQUAL((sal_uInt32)0, nInfo); + CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), nInfo); CPPUNIT_ASSERT_EQUAL(nNumber, nConverted); rtl_destroyUnicodeToTextContext(aConverter, aContext); rtl_destroyUnicodeToTextConverter(aConverter); @@ -163,9 +163,9 @@ void testSingleByteCharSet(SingleByteCharSet const & rSet) { sal_uInt32 nExpectedInfo = (RTL_TEXTTOUNICODE_INFO_ERROR | RTL_TEXTTOUNICODE_INFO_UNDEFINED); - CPPUNIT_ASSERT_EQUAL((sal_Size) 0, nSize); + CPPUNIT_ASSERT_EQUAL(sal_Size(0), nSize); CPPUNIT_ASSERT_EQUAL(nExpectedInfo, nInfo); - CPPUNIT_ASSERT_EQUAL((sal_Size) 0, nConverted); + CPPUNIT_ASSERT_EQUAL(sal_Size(0), nConverted); rtl_destroyTextToUnicodeContext(aConverter, aContext); rtl_destroyTextToUnicodeConverter(aConverter); @@ -214,7 +214,7 @@ void doComplexCharSetTest(ComplexCharSetTest const & rTest) { RTL_TEXTTOUNICODE_FLAGS_GLOBAL_SIGNATURE : 0)), &nInfo, &nConverted); CPPUNIT_ASSERT_EQUAL(rTest.m_nUnicodeSize, nSize); - CPPUNIT_ASSERT_EQUAL((sal_uInt32) 0, nInfo); + CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), nInfo); CPPUNIT_ASSERT_EQUAL(rTest.m_nTextSize, nConverted); rtl_destroyTextToUnicodeContext(aConverter, aContext); @@ -264,7 +264,7 @@ void doComplexCharSetTest(ComplexCharSetTest const & rTest) { nFlags, &nInfo, &nConverted); nOutput += nSize; nInput += nConverted; - CPPUNIT_ASSERT_EQUAL((sal_uInt32) 0, + CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), (nInfo & ~RTL_TEXTTOUNICODE_INFO_SRCBUFFERTOOSMALL)); } CPPUNIT_ASSERT_EQUAL(rTest.m_nUnicodeSize, nOutput); diff --git a/sal/rtl/alloc_arena.cxx b/sal/rtl/alloc_arena.cxx index b8df460b4e88..ef8738fc170f 100644 --- a/sal/rtl/alloc_arena.cxx +++ b/sal/rtl/alloc_arena.cxx @@ -337,7 +337,7 @@ rtl_arena_segment_type * rtl_arena_hash_remove( if (lookups > 1) { - sal_Size nseg = (sal_Size)(arena->m_stats.m_alloc - arena->m_stats.m_free); + sal_Size nseg = static_cast(arena->m_stats.m_alloc - arena->m_stats.m_free); if (nseg > 4 * arena->m_hash_size) { if (!(arena->m_flags & RTL_ARENA_FLAG_RESCALE)) @@ -396,7 +396,7 @@ bool rtl_arena_segment_alloc( } /* roundup to next power of 2 */ - size = (((sal_Size)1) << msb); + size = ((sal_Size(1)) << msb); } index = lowbit(RTL_MEMORY_P2ALIGN(arena->m_freelist_bitmap, size)); @@ -555,7 +555,7 @@ void rtl_arena_constructor(void * obj) head = &(arena->m_freelist_head[i]); rtl_arena_segment_constructor (head); - head->m_size = (((sal_Size)1) << i); + head->m_size = ((sal_Size(1)) << i); head->m_type = RTL_ARENA_SEGMENT_TYPE_HEAD; } @@ -590,7 +590,7 @@ void rtl_arena_destructor(void * obj) { head = &(arena->m_freelist_head[i]); - assert(head->m_size == (((sal_Size)1) << i)); + assert(head->m_size == ((sal_Size(1)) << i)); assert(head->m_type == RTL_ARENA_SEGMENT_TYPE_HEAD); rtl_arena_segment_destructor (head); @@ -623,7 +623,7 @@ rtl_arena_type * rtl_arena_activate( if (!RTL_MEMORY_ISP2(quantum)) { /* roundup to next power of 2 */ - quantum = (((sal_Size)1) << highbit(quantum)); + quantum = ((sal_Size(1)) << highbit(quantum)); } quantum_cache_max = RTL_MEMORY_P2ROUNDUP(quantum_cache_max, quantum); @@ -1060,7 +1060,7 @@ void * rtl_machdep_alloc( #endif #if defined(SAL_UNX) - addr = mmap (nullptr, (size_t)size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); + addr = mmap (nullptr, static_cast(size), PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); #elif defined(SAL_W32) addr = VirtualAlloc (nullptr, (SIZE_T)size, MEM_COMMIT, PAGE_READWRITE); #endif /* (SAL_UNX || SAL_W32) */ @@ -1102,7 +1102,7 @@ sal_Size rtl_machdep_pagesize() #if defined(FREEBSD) || defined(NETBSD) || defined(DRAGONFLY) return (sal_Size)getpagesize(); #else /* POSIX */ - return (sal_Size)sysconf(_SC_PAGESIZE); + return static_cast(sysconf(_SC_PAGESIZE)); #endif /* xBSD || POSIX */ #elif defined(SAL_W32) SYSTEM_INFO info; diff --git a/sal/rtl/alloc_arena.hxx b/sal/rtl/alloc_arena.hxx index 0ac54d96e575..3c04173b4ab0 100644 --- a/sal/rtl/alloc_arena.hxx +++ b/sal/rtl/alloc_arena.hxx @@ -39,10 +39,10 @@ struct rtl_arena_stat_type /** rtl_arena_segment_type * @internal */ -#define RTL_ARENA_SEGMENT_TYPE_HEAD ((sal_Size)(0x01)) -#define RTL_ARENA_SEGMENT_TYPE_SPAN ((sal_Size)(0x02)) -#define RTL_ARENA_SEGMENT_TYPE_FREE ((sal_Size)(0x04)) -#define RTL_ARENA_SEGMENT_TYPE_USED ((sal_Size)(0x08)) +#define RTL_ARENA_SEGMENT_TYPE_HEAD (sal_Size(0x01)) +#define RTL_ARENA_SEGMENT_TYPE_SPAN (sal_Size(0x02)) +#define RTL_ARENA_SEGMENT_TYPE_FREE (sal_Size(0x04)) +#define RTL_ARENA_SEGMENT_TYPE_USED (sal_Size(0x08)) struct rtl_arena_segment_type { diff --git a/sal/rtl/alloc_cache.cxx b/sal/rtl/alloc_cache.cxx index 1c24faaf9829..6a3eea86d6a0 100644 --- a/sal/rtl/alloc_cache.cxx +++ b/sal/rtl/alloc_cache.cxx @@ -181,7 +181,7 @@ rtl_cache_bufctl_type * rtl_cache_hash_remove( if (lookups > 1) { - sal_Size nbuf = (sal_Size)(cache->m_slab_stats.m_alloc - cache->m_slab_stats.m_free); + sal_Size nbuf = static_cast(cache->m_slab_stats.m_alloc - cache->m_slab_stats.m_free); if (nbuf > 4 * cache->m_hash_size) { if (!(cache->m_features & RTL_CACHE_FEATURE_RESCALE)) @@ -744,9 +744,9 @@ rtl_cache_type * rtl_cache_activate( if (flags & RTL_CACHE_FLAG_QUANTUMCACHE) { /* next power of 2 above 3 * qcache_max */ - if (slabsize < (((sal_Size)1) << highbit(3 * source->m_qcache_max))) + if (slabsize < ((sal_Size(1)) << highbit(3 * source->m_qcache_max))) { - slabsize = (((sal_Size)1) << highbit(3 * source->m_qcache_max)); + slabsize = ((sal_Size(1)) << highbit(3 * source->m_qcache_max)); } } else @@ -760,7 +760,7 @@ rtl_cache_type * rtl_cache_activate( slabsize = RTL_MEMORY_P2ROUNDUP(slabsize, source->m_quantum); if (!RTL_MEMORY_ISP2(slabsize)) - slabsize = (((sal_Size)1) << highbit(slabsize)); + slabsize = ((sal_Size(1)) << highbit(slabsize)); cache->m_slab_size = slabsize; if (cache->m_slab_size > source->m_quantum) diff --git a/sal/rtl/alloc_impl.hxx b/sal/rtl/alloc_impl.hxx index 89b9b7c9fa67..bdf4e7b6eb81 100644 --- a/sal/rtl/alloc_impl.hxx +++ b/sal/rtl/alloc_impl.hxx @@ -44,12 +44,12 @@ #define RTL_MEMORY_ALIGN(value, align) (((value) + ((align) - 1)) & ~((align) - 1)) #define RTL_MEMORY_ISP2(value) (((value) & ((value) - 1)) == 0) -#define RTL_MEMORY_P2ALIGN(value, align) ((value) & -(sal_IntPtr)(align)) +#define RTL_MEMORY_P2ALIGN(value, align) ((value) & -static_cast(align)) #define RTL_MEMORY_P2ROUNDUP(value, align) \ - (-(-(sal_IntPtr)(value) & -(sal_IntPtr)(align))) + (-(-static_cast(value) & -static_cast(align))) #define RTL_MEMORY_P2END(value, align) \ - (-(~(sal_IntPtr)(value) & -(sal_IntPtr)(align))) + (-(~static_cast(value) & -static_cast(align))) /** highbit(): log2() + 1 (complexity O(1)) diff --git a/sal/rtl/cipher.cxx b/sal/rtl/cipher.cxx index 735b2eb0d1c0..9a64ac4364b0 100644 --- a/sal/rtl/cipher.cxx +++ b/sal/rtl/cipher.cxx @@ -24,16 +24,16 @@ #include #define RTL_CIPHER_NTOHL(c, l) \ - ((l) = ((sal_uInt32)(*((c)++))) << 24, \ - (l) |= ((sal_uInt32)(*((c)++))) << 16, \ - (l) |= ((sal_uInt32)(*((c)++))) << 8, \ - (l) |= ((sal_uInt32)(*((c)++)))) + ((l) = (static_cast(*((c)++))) << 24, \ + (l) |= (static_cast(*((c)++))) << 16, \ + (l) |= (static_cast(*((c)++))) << 8, \ + (l) |= (static_cast(*((c)++)))) #define RTL_CIPHER_HTONL(l, c) \ - (*((c)++) = (sal_uInt8)(((l) >> 24) & 0xff), \ - *((c)++) = (sal_uInt8)(((l) >> 16) & 0xff), \ - *((c)++) = (sal_uInt8)(((l) >> 8) & 0xff), \ - *((c)++) = (sal_uInt8)(((l) ) & 0xff)) + (*((c)++) = static_cast(((l) >> 24) & 0xff), \ + *((c)++) = static_cast(((l) >> 16) & 0xff), \ + *((c)++) = static_cast(((l) >> 8) & 0xff), \ + *((c)++) = static_cast(((l) ) & 0xff)) #define RTL_CIPHER_NTOHL64(c, xl, xr, n) \ { \ @@ -41,21 +41,21 @@ (c) += (n); \ switch ((n)) \ { \ - case 8: (xr) = ((sal_uInt32)(*(--(c)))); \ + case 8: (xr) = (static_cast(*(--(c)))); \ SAL_FALLTHROUGH; \ - case 7: (xr) |= ((sal_uInt32)(*(--(c)))) << 8; \ + case 7: (xr) |= (static_cast(*(--(c)))) << 8; \ SAL_FALLTHROUGH; \ - case 6: (xr) |= ((sal_uInt32)(*(--(c)))) << 16; \ + case 6: (xr) |= (static_cast(*(--(c)))) << 16; \ SAL_FALLTHROUGH; \ - case 5: (xr) |= ((sal_uInt32)(*(--(c)))) << 24; \ + case 5: (xr) |= (static_cast(*(--(c)))) << 24; \ SAL_FALLTHROUGH; \ - case 4: (xl) = ((sal_uInt32)(*(--(c)))); \ + case 4: (xl) = (static_cast(*(--(c)))); \ SAL_FALLTHROUGH; \ - case 3: (xl) |= ((sal_uInt32)(*(--(c)))) << 8; \ + case 3: (xl) |= (static_cast(*(--(c)))) << 8; \ SAL_FALLTHROUGH; \ - case 2: (xl) |= ((sal_uInt32)(*(--(c)))) << 16; \ + case 2: (xl) |= (static_cast(*(--(c)))) << 16; \ SAL_FALLTHROUGH; \ - case 1: (xl) |= ((sal_uInt32)(*(--(c)))) << 24; \ + case 1: (xl) |= (static_cast(*(--(c)))) << 24; \ } \ } @@ -64,21 +64,21 @@ (c) += (n); \ switch ((n)) \ { \ - case 8: *(--(c)) = (sal_uInt8)(((xr) ) & 0xff); \ + case 8: *(--(c)) = static_cast(((xr) ) & 0xff); \ SAL_FALLTHROUGH; \ - case 7: *(--(c)) = (sal_uInt8)(((xr) >> 8) & 0xff); \ + case 7: *(--(c)) = static_cast(((xr) >> 8) & 0xff); \ SAL_FALLTHROUGH; \ - case 6: *(--(c)) = (sal_uInt8)(((xr) >> 16) & 0xff); \ + case 6: *(--(c)) = static_cast(((xr) >> 16) & 0xff); \ SAL_FALLTHROUGH; \ - case 5: *(--(c)) = (sal_uInt8)(((xr) >> 24) & 0xff); \ + case 5: *(--(c)) = static_cast(((xr) >> 24) & 0xff); \ SAL_FALLTHROUGH; \ - case 4: *(--(c)) = (sal_uInt8)(((xl) ) & 0xff); \ + case 4: *(--(c)) = static_cast(((xl) ) & 0xff); \ SAL_FALLTHROUGH; \ - case 3: *(--(c)) = (sal_uInt8)(((xl) >> 8) & 0xff); \ + case 3: *(--(c)) = static_cast(((xl) >> 8) & 0xff); \ SAL_FALLTHROUGH; \ - case 2: *(--(c)) = (sal_uInt8)(((xl) >> 16) & 0xff); \ + case 2: *(--(c)) = static_cast(((xl) >> 16) & 0xff); \ SAL_FALLTHROUGH; \ - case 1: *(--(c)) = (sal_uInt8)(((xl) >> 24) & 0xff); \ + case 1: *(--(c)) = static_cast(((xl) >> 24) & 0xff); \ } \ } @@ -916,13 +916,13 @@ static sal_uInt32 BF(CipherKeyBF *key, sal_uInt32 x) sal_uInt16 a, b, c, d; sal_uInt32 y; - d = (sal_uInt16)(x & 0x00ff); + d = static_cast(x & 0x00ff); x >>= 8; - c = (sal_uInt16)(x & 0x00ff); + c = static_cast(x & 0x00ff); x >>= 8; - b = (sal_uInt16)(x & 0x00ff); + b = static_cast(x & 0x00ff); x >>= 8; - a = (sal_uInt16)(x & 0x00ff); + a = static_cast(x & 0x00ff); y = key->m_S[0][a]; y += key->m_S[1][b]; @@ -1145,7 +1145,7 @@ static rtlCipherError rtl_cipherARCFOUR_update_Impl( /* Evaluate next key byte S[t]. */ t = (S[x] + S[y]) % CIPHER_CBLOCK_ARCFOUR; - pBuffer[k] = pData[k] ^ ((sal_uInt8)(S[t] & 0xff)); + pBuffer[k] = pData[k] ^ static_cast(S[t] & 0xff); } return rtl_Cipher_E_None; diff --git a/sal/rtl/digest.cxx b/sal/rtl/digest.cxx index 4d4fb59ce3f4..f296fa5fbef8 100644 --- a/sal/rtl/digest.cxx +++ b/sal/rtl/digest.cxx @@ -29,16 +29,16 @@ #define RTL_DIGEST_ROTL(a,n) (((a) << (n)) | ((a) >> (32 - (n)))) #define RTL_DIGEST_HTONL(l,c) \ - (*((c)++) = (sal_uInt8)(((l) >> 24) & 0xff), \ - *((c)++) = (sal_uInt8)(((l) >> 16) & 0xff), \ - *((c)++) = (sal_uInt8)(((l) >> 8) & 0xff), \ - *((c)++) = (sal_uInt8)(((l) ) & 0xff)) + (*((c)++) = static_cast(((l) >> 24) & 0xff), \ + *((c)++) = static_cast(((l) >> 16) & 0xff), \ + *((c)++) = static_cast(((l) >> 8) & 0xff), \ + *((c)++) = static_cast(((l) ) & 0xff)) #define RTL_DIGEST_LTOC(l,c) \ - (*((c)++) = (sal_uInt8)(((l) ) & 0xff), \ - *((c)++) = (sal_uInt8)(((l) >> 8) & 0xff), \ - *((c)++) = (sal_uInt8)(((l) >> 16) & 0xff), \ - *((c)++) = (sal_uInt8)(((l) >> 24) & 0xff)) + (*((c)++) = static_cast(((l) ) & 0xff), \ + *((c)++) = static_cast(((l) >> 8) & 0xff), \ + *((c)++) = static_cast(((l) >> 16) & 0xff), \ + *((c)++) = static_cast(((l) >> 24) & 0xff)) typedef rtlDigestError (Digest_init_t) ( void *ctx, const sal_uInt8 *Data, sal_uInt32 DatLen); @@ -296,12 +296,12 @@ static void endMD2(DigestContextMD2 *ctx) n = DIGEST_CBLOCK_MD2 - ctx->m_nDatLen; for (i = ctx->m_nDatLen; i < DIGEST_CBLOCK_MD2; i++) - X[i] = (sal_uInt8)(n & 0xff); + X[i] = static_cast(n & 0xff); updateMD2(ctx); for (i = 0; i < DIGEST_CBLOCK_MD2; i++) - X[i] = (sal_uInt8)(C[i] & 0xff); + X[i] = static_cast(C[i] & 0xff); updateMD2(ctx); } @@ -414,7 +414,7 @@ rtlDigestError SAL_CALL rtl_digest_getMD2( endMD2(ctx); for (i = 0; i < DIGEST_CBLOCK_MD2; i++) { - pBuffer[i] = (sal_uInt8)(ctx->m_state[i] & 0xff); + pBuffer[i] = static_cast(ctx->m_state[i] & 0xff); } initMD2(ctx); @@ -494,10 +494,10 @@ static void initMD5(DigestContextMD5 *ctx) { memset(ctx, 0, sizeof(DigestContextMD5)); - ctx->m_nA = (sal_uInt32)0x67452301L; - ctx->m_nB = (sal_uInt32)0xefcdab89L; - ctx->m_nC = (sal_uInt32)0x98badcfeL; - ctx->m_nD = (sal_uInt32)0x10325476L; + ctx->m_nA = sal_uInt32(0x67452301L); + ctx->m_nB = sal_uInt32(0xefcdab89L); + ctx->m_nC = sal_uInt32(0x98badcfeL); + ctx->m_nD = sal_uInt32(0x10325476L); } static void updateMD5(DigestContextMD5 *ctx) @@ -612,13 +612,13 @@ static void endMD5(DigestContextMD5 *ctx) switch (ctx->m_nDatLen & 0x03) { - case 0: X[i] = ((sal_uInt32)(*(p++))) << 0; + case 0: X[i] = static_cast(*(p++)) << 0; SAL_FALLTHROUGH; - case 1: X[i] |= ((sal_uInt32)(*(p++))) << 8; + case 1: X[i] |= static_cast(*(p++)) << 8; SAL_FALLTHROUGH; - case 2: X[i] |= ((sal_uInt32)(*(p++))) << 16; + case 2: X[i] |= static_cast(*(p++)) << 16; SAL_FALLTHROUGH; - case 3: X[i] |= ((sal_uInt32)(*p)) << 24; + case 3: X[i] |= static_cast(*p) << 24; } i += 1; @@ -846,10 +846,10 @@ static void initSHA( static void updateSHA(DigestContextSHA *ctx); static void endSHA(DigestContextSHA *ctx); -#define K_00_19 (sal_uInt32)0x5a827999L -#define K_20_39 (sal_uInt32)0x6ed9eba1L -#define K_40_59 (sal_uInt32)0x8f1bbcdcL -#define K_60_79 (sal_uInt32)0xca62c1d6L +#define K_00_19 sal_uInt32(0x5a827999L) +#define K_20_39 sal_uInt32(0x6ed9eba1L) +#define K_40_59 sal_uInt32(0x8f1bbcdcL) +#define K_60_79 sal_uInt32(0xca62c1d6L) #define F_00_19(b,c,d) ((((c) ^ (d)) & (b)) ^ (d)) #define F_20_39(b,c,d) ((b) ^ (c) ^ (d)) @@ -894,11 +894,11 @@ static void initSHA( memset(ctx, 0, sizeof(DigestContextSHA)); ctx->m_update = fct; - ctx->m_nA = (sal_uInt32)0x67452301L; - ctx->m_nB = (sal_uInt32)0xefcdab89L; - ctx->m_nC = (sal_uInt32)0x98badcfeL; - ctx->m_nD = (sal_uInt32)0x10325476L; - ctx->m_nE = (sal_uInt32)0xc3d2e1f0L; + ctx->m_nA = sal_uInt32(0x67452301L); + ctx->m_nB = sal_uInt32(0xefcdab89L); + ctx->m_nC = sal_uInt32(0x98badcfeL); + ctx->m_nD = sal_uInt32(0x10325476L); + ctx->m_nE = sal_uInt32(0xc3d2e1f0L); } static void updateSHA(DigestContextSHA *ctx) @@ -1034,13 +1034,13 @@ static void endSHA(DigestContextSHA *ctx) switch (ctx->m_nDatLen & 0x03) { - case 0: X[i] = ((sal_uInt32)(*(p++))) << 0; + case 0: X[i] = static_cast(*(p++)) << 0; SAL_FALLTHROUGH; - case 1: X[i] |= ((sal_uInt32)(*(p++))) << 8; + case 1: X[i] |= static_cast(*(p++)) << 8; SAL_FALLTHROUGH; - case 2: X[i] |= ((sal_uInt32)(*(p++))) << 16; + case 2: X[i] |= static_cast(*(p++)) << 16; SAL_FALLTHROUGH; - case 3: X[i] |= ((sal_uInt32)(*(p++))) << 24; + case 3: X[i] |= static_cast(*(p++)) << 24; } swapLong(X, i + 1); diff --git a/sal/rtl/hash.cxx b/sal/rtl/hash.cxx index dd5db5c34739..0dc36a4cffff 100644 --- a/sal/rtl/hash.cxx +++ b/sal/rtl/hash.cxx @@ -67,8 +67,8 @@ static sal_uInt32 getNextSize(sal_uInt32 nSize) static sal_uInt32 hashString(rtl_uString *pString) { - return (sal_uInt32) rtl_ustr_hashCode_WithLength(pString->buffer, - pString->length); + return static_cast(rtl_ustr_hashCode_WithLength(pString->buffer, + pString->length)); } static StringHashTable * rtl_str_hash_new(sal_uInt32 nSize) diff --git a/sal/rtl/locale.cxx b/sal/rtl/locale.cxx index e7ef4223b0ca..b6b5ee499141 100644 --- a/sal/rtl/locale.cxx +++ b/sal/rtl/locale.cxx @@ -104,7 +104,7 @@ extern "C" void rtl_hashtable_init(RTL_HASHTABLE** table, sal_Int8 sizeIndex) extern "C" sal_Int32 rtl_hashfunc(RTL_HASHTABLE* table, sal_Int32 key) { - return ((sal_uInt32) key % table->Size); + return (static_cast(key) % table->Size); } extern "C" sal_Bool rtl_hashtable_grow(RTL_HASHTABLE** table); @@ -143,7 +143,7 @@ sal_Bool rtl_hashtable_grow(RTL_HASHTABLE** table) RTL_HASHTABLE* pNewTable = nullptr; sal_Int32 i = 0; - rtl_hashtable_init(&pNewTable, (sal_Int8)((*table)->iSize + 1)); + rtl_hashtable_init(&pNewTable, static_cast((*table)->iSize + 1)); while (i < (*table)->Size) { diff --git a/sal/rtl/random.cxx b/sal/rtl/random.cxx index 1c28c47db43b..1046b7000069 100644 --- a/sal/rtl/random.cxx +++ b/sal/rtl/random.cxx @@ -77,11 +77,11 @@ static double data(RandomData_Impl *pImpl) double random; RTL_RANDOM_RNG (pImpl->m_nX, pImpl->m_nY, pImpl->m_nZ); - random = (((double)(pImpl->m_nX) / 30328.0) + - ((double)(pImpl->m_nY) / 30269.0) + - ((double)(pImpl->m_nZ) / 30307.0) ); + random = ((static_cast(pImpl->m_nX) / 30328.0) + + (static_cast(pImpl->m_nY) / 30269.0) + + (static_cast(pImpl->m_nZ) / 30307.0) ); - random -= ((double)((sal_uInt32)random)); + random -= static_cast(static_cast(random)); return random; } @@ -115,9 +115,9 @@ static bool initPool(RandomPool_Impl *pImpl) tv.Nanosec = RTL_RANDOM_RNG_2(tv.Nanosec); 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); + rd.m_nX = static_cast(((tid >> 1) << 1) + 1); + rd.m_nY = static_cast(((tv.Seconds >> 1) << 1) + 1); + rd.m_nZ = static_cast(((tv.Nanosec >> 1) << 1) + 1); seedPool (pImpl, reinterpret_cast< sal_uInt8* >(&rd), sizeof(rd)); while (pImpl->m_nData < RTL_RANDOM_SIZE_POOL) diff --git a/sal/rtl/string.cxx b/sal/rtl/string.cxx index 20a2cda499c4..b9047b987fde 100644 --- a/sal/rtl/string.cxx +++ b/sal/rtl/string.cxx @@ -59,7 +59,7 @@ static rtl_String const aImplEmpty_rtl_String = #define IMPL_RTL_IS_USTRING 0 #define IMPL_RTL_STRCODE sal_Char -#define IMPL_RTL_USTRCODE( c ) ((unsigned char)c) +#define IMPL_RTL_USTRCODE( c ) (static_cast(c)) #define IMPL_RTL_STRNAME( n ) rtl_str_ ## n #define IMPL_RTL_STRINGNAME( n ) rtl_string_ ## n @@ -122,8 +122,8 @@ sal_Int32 SAL_CALL rtl_str_valueOfDouble(sal_Char * pStr, double d) float SAL_CALL rtl_str_toFloat(sal_Char const * pStr) SAL_THROW_EXTERN_C() { assert(pStr); - return (float) rtl_math_stringToDouble(pStr, pStr + rtl_str_getLength(pStr), - '.', 0, nullptr, nullptr); + return static_cast(rtl_math_stringToDouble(pStr, pStr + rtl_str_getLength(pStr), + '.', 0, nullptr, nullptr)); } double SAL_CALL rtl_str_toDouble(sal_Char const * pStr) SAL_THROW_EXTERN_C() @@ -221,7 +221,7 @@ bool rtl_impl_convertUStringToString(rtl_String ** pTarget, nNewLen = rtl_ImplGetFastUTF8ByteLen( pSource, nLength ); /* Includes the string only ASCII, then we could copy the buffer faster */ - if ( nNewLen == (sal_Size)nLength ) + if ( nNewLen == static_cast(nLength) ) { sal_Char* pBuffer; if ( *pTarget ) @@ -235,7 +235,7 @@ bool rtl_impl_convertUStringToString(rtl_String ** pTarget, OSL_ENSURE( *pSource <= 127, "rtl_uString2String() - UTF8 test is encoding is wrong" ); - *pBuffer = (sal_Char)(unsigned char)*pSource; + *pBuffer = static_cast(static_cast(*pSource)); pBuffer++; pSource++; nLength--; diff --git a/sal/rtl/strtmpl.cxx b/sal/rtl/strtmpl.cxx index 5fdab82f8b43..929e5ce5c60e 100644 --- a/sal/rtl/strtmpl.cxx +++ b/sal/rtl/strtmpl.cxx @@ -101,8 +101,8 @@ sal_Int32 SAL_CALL IMPL_RTL_STRNAME( compare )( const IMPL_RTL_STRCODE* pStr1, else { sal_Int32 nRet; - while ( ((nRet = ((sal_Int32)IMPL_RTL_USTRCODE(*pStr1))- - ((sal_Int32)IMPL_RTL_USTRCODE(*pStr2))) == 0) && + while ( ((nRet = static_cast(IMPL_RTL_USTRCODE(*pStr1))- + static_cast(IMPL_RTL_USTRCODE(*pStr2))) == 0) && *pStr2 ) { pStr1++; @@ -148,8 +148,8 @@ sal_Int32 SAL_CALL IMPL_RTL_STRNAME( compare_WithLength )( const IMPL_RTL_STRCOD while( (--nCount >= 0) && (*++pStr1 == *++pStr2) ) ; if( nCount >= 0 ) - nRet = ((sal_Int32)IMPL_RTL_USTRCODE( *pStr1 )) - - ((sal_Int32)IMPL_RTL_USTRCODE( *pStr2 )); + nRet = static_cast(IMPL_RTL_USTRCODE( *pStr1 )) + - static_cast(IMPL_RTL_USTRCODE( *pStr2 )); return nRet; } @@ -193,8 +193,8 @@ sal_Int32 SAL_CALL IMPL_RTL_STRNAME( shortenedCompare_WithLength )( const IMPL_R while ( (nShortenedLength > 0) && (pStr1 < pStr1End) && (pStr2 < pStr2End) ) { - nRet = ((sal_Int32)IMPL_RTL_USTRCODE( *pStr1 ))- - ((sal_Int32)IMPL_RTL_USTRCODE( *pStr2 )); + nRet = static_cast(IMPL_RTL_USTRCODE( *pStr1 ))- + static_cast(IMPL_RTL_USTRCODE( *pStr2 )); if ( nRet ) return nRet; @@ -227,8 +227,8 @@ sal_Int32 SAL_CALL IMPL_RTL_STRNAME( reverseCompare_WithLength )( const IMPL_RTL { pStr1Run--; pStr2Run--; - nRet = ((sal_Int32)IMPL_RTL_USTRCODE( *pStr1Run ))- - ((sal_Int32)IMPL_RTL_USTRCODE( *pStr2Run )); + nRet = static_cast(IMPL_RTL_USTRCODE( *pStr1Run ))- + static_cast(IMPL_RTL_USTRCODE( *pStr2Run )); if ( nRet ) return nRet; } @@ -359,7 +359,7 @@ 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 const * p = wcschr(reinterpret_cast(pStr), (wchar_t)c); + wchar_t const * p = wcschr(reinterpret_cast(pStr), static_cast(c)); return p ? p - reinterpret_cast(pStr) : -1; } else @@ -420,7 +420,7 @@ 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 const * p = wcsrchr(reinterpret_cast(pStr), (wchar_t)c); + wchar_t const * p = wcsrchr(reinterpret_cast(pStr), static_cast(c)); return p ? p - reinterpret_cast(pStr) : -1; } else @@ -841,7 +841,7 @@ sal_Int32 SAL_CALL IMPL_RTL_STRNAME( valueOfInt32 )( IMPL_RTL_STRCODE* pStr, /* create a recursive buffer with all values, except the last one */ do { - sal_Char nDigit = (sal_Char)(nValue % nRadix); + sal_Char nDigit = static_cast(nValue % nRadix); nValue /= nRadix; if ( nDigit > 9 ) *pBuf = (nDigit-10) + 'a'; @@ -896,7 +896,7 @@ sal_Int32 SAL_CALL IMPL_RTL_STRNAME( valueOfInt64 )( IMPL_RTL_STRCODE* pStr, /* create a recursive buffer with all values, except the last one */ do { - sal_Char nDigit = (sal_Char)(nValue % nRadix); + sal_Char nDigit = static_cast(nValue % nRadix); nValue /= nRadix; if ( nDigit > 9 ) *pBuf = (nDigit-10) + 'a'; @@ -942,7 +942,7 @@ sal_Int32 SAL_CALL IMPL_RTL_STRNAME( valueOfUInt64 )( IMPL_RTL_STRCODE* pStr, /* create a recursive buffer with all values, except the last one */ do { - sal_Char nDigit = (sal_Char)(nValue % nRadix); + sal_Char nDigit = static_cast(nValue % nRadix); nValue /= nRadix; if ( nDigit > 9 ) *pBuf = (nDigit-10) + 'a'; @@ -1437,7 +1437,7 @@ void SAL_CALL IMPL_RTL_STRINGNAME( newFromLiteral )( IMPL_RTL_STRINGDATA** ppThi #if IMPL_RTL_IS_USTRING assert(static_cast(*pCharStr) < 0x80); // ASCII range #endif - SAL_WARN_IF( ((unsigned char)*pCharStr) == '\0', "rtl.string", + SAL_WARN_IF( (static_cast(*pCharStr)) == '\0', "rtl.string", "rtl_uString_newFromLiteral - Found embedded \\0 character" ); *pBuffer = *pCharStr; diff --git a/sal/rtl/ustrbuf.cxx b/sal/rtl/ustrbuf.cxx index dfb2c1a06a30..4ebfbbbc994c 100644 --- a/sal/rtl/ustrbuf.cxx +++ b/sal/rtl/ustrbuf.cxx @@ -170,12 +170,12 @@ void rtl_uStringbuffer_insertUtf32( sal_Int32 len; OSL_ASSERT(rtl::isUnicodeScalarValue(c)); if (c <= 0xFFFF) { - buf[0] = (sal_Unicode) c; + buf[0] = static_cast(c); len = 1; } else { c -= 0x10000; - buf[0] = (sal_Unicode) ((c >> 10) | 0xD800); - buf[1] = (sal_Unicode) ((c & 0x3FF) | 0xDC00); + buf[0] = static_cast((c >> 10) | 0xD800); + buf[1] = static_cast((c & 0x3FF) | 0xDC00); len = 2; } rtl_uStringbuffer_insert(pThis, capacity, offset, buf, len); @@ -217,7 +217,7 @@ void SAL_CALL rtl_uStringbuffer_insert_ascii( /*inout*/rtl_uString ** This, /* Check ASCII range */ OSL_ENSURE( (*str & 0x80) == 0, "Found ASCII char > 127"); - pBuf[offset + n] = (sal_Unicode)*(str++); + pBuf[offset + n] = static_cast(*(str++)); } (*This)->length = nOldLen + len; diff --git a/sal/rtl/ustring.cxx b/sal/rtl/ustring.cxx index 31e0cf10d363..d562c7c736a1 100644 --- a/sal/rtl/ustring.cxx +++ b/sal/rtl/ustring.cxx @@ -53,7 +53,7 @@ */ static rtl_uString const aImplEmpty_rtl_uString = { - (sal_Int32) (SAL_STRING_INTERN_FLAG|SAL_STRING_STATIC_FLAG|1), /*sal_Int32 refCount; */ + sal_Int32(SAL_STRING_INTERN_FLAG|SAL_STRING_STATIC_FLAG|1), /*sal_Int32 refCount; */ 0, /*sal_Int32 length; */ { 0 } /*sal_Unicode buffer[1];*/ }; @@ -217,12 +217,12 @@ sal_Int32 SAL_CALL rtl_ustr_ascii_compare( const sal_Unicode* pStr1, assert(pStr1); assert(pStr2); sal_Int32 nRet; - while ( ((nRet = ((sal_Int32)(*pStr1))- - ((sal_Int32)((unsigned char)(*pStr2)))) == 0) && + while ( ((nRet = static_cast(*pStr1)- + static_cast(static_cast(*pStr2))) == 0) && *pStr2 ) { /* Check ASCII range */ - SAL_WARN_IF( ((unsigned char)*pStr2) > 127, "rtl.string", + SAL_WARN_IF( (static_cast(*pStr2)) > 127, "rtl.string", "rtl_ustr_ascii_compare - Found char > 127" ); pStr1++; pStr2++; @@ -242,12 +242,12 @@ sal_Int32 SAL_CALL rtl_ustr_ascii_compare_WithLength( const sal_Unicode* pStr1, assert(nStr1Len >= 0); assert(pStr2); sal_Int32 nRet = 0; - while( ((nRet = (nStr1Len ? (sal_Int32)(*pStr1) : 0)- - ((sal_Int32)((unsigned char)(*pStr2)))) == 0) && + while( ((nRet = (nStr1Len ? static_cast(*pStr1) : 0)- + static_cast(static_cast(*pStr2))) == 0) && nStr1Len && *pStr2 ) { /* Check ASCII range */ - SAL_WARN_IF( ((unsigned char)*pStr2) > 127, "rtl.string", + SAL_WARN_IF( (static_cast(*pStr2)) > 127, "rtl.string", "rtl_ustr_ascii_compare_WithLength - Found char > 127" ); pStr1++; pStr2++; @@ -273,11 +273,11 @@ sal_Int32 SAL_CALL rtl_ustr_ascii_shortenedCompare_WithLength( const sal_Unicode (pStr1 < pStr1End) && *pStr2 ) { /* Check ASCII range */ - SAL_WARN_IF( ((unsigned char)*pStr2) > 127, "rtl.string", + SAL_WARN_IF( (static_cast(*pStr2)) > 127, "rtl.string", "rtl_ustr_ascii_shortenedCompare_WithLength - Found char > 127" ); - nRet = ((sal_Int32)*pStr1)- - ((sal_Int32)(unsigned char)*pStr2); + nRet = static_cast(*pStr1)- + static_cast(static_cast(*pStr2)); if ( nRet != 0 ) return nRet; @@ -319,11 +319,11 @@ sal_Int32 SAL_CALL rtl_ustr_asciil_reverseCompare_WithLength( const sal_Unicode* while ( (pStr1 < pStr1Run) && (pStr2 < pStr2Run) ) { /* Check ASCII range */ - SAL_WARN_IF( ((unsigned char)*pStr2) > 127, "rtl.string", + SAL_WARN_IF( (static_cast(*pStr2)) > 127, "rtl.string", "rtl_ustr_asciil_reverseCompare_WithLength - Found char > 127" ); pStr1Run--; pStr2Run--; - nRet = ((sal_Int32)*pStr1Run)-((sal_Int32)*pStr2Run); + nRet = static_cast(*pStr1Run)- static_cast(*pStr2Run); if ( nRet ) return nRet; } @@ -344,11 +344,11 @@ sal_Bool SAL_CALL rtl_ustr_asciil_reverseEquals_WithLength( const sal_Unicode* p while ( pStr1 < pStr1Run ) { /* Check ASCII range */ - SAL_WARN_IF( ((unsigned char)*pStr2) > 127, "rtl.string", + SAL_WARN_IF( (static_cast(*pStr2)) > 127, "rtl.string", "rtl_ustr_asciil_reverseEquals_WithLength - Found char > 127" ); pStr1Run--; pStr2Run--; - if( *pStr1Run != (sal_Unicode)*pStr2Run ) + if( *pStr1Run != static_cast(*pStr2Run) ) return false; } @@ -369,11 +369,11 @@ sal_Int32 SAL_CALL rtl_ustr_ascii_compareIgnoreAsciiCase( const sal_Unicode* pSt do { /* Check ASCII range */ - SAL_WARN_IF( ((unsigned char)*pStr2) > 127, "rtl.string", + SAL_WARN_IF( (static_cast(*pStr2)) > 127, "rtl.string", "rtl_ustr_ascii_compareIgnoreAsciiCase - Found char > 127" ); /* If character between 'A' and 'Z', than convert it to lowercase */ - c1 = (sal_Int32)*pStr1; - c2 = (sal_Int32)((unsigned char)*pStr2); + c1 = static_cast(*pStr1); + c2 = static_cast(static_cast(*pStr2)); if ( (c1 >= 65) && (c1 <= 90) ) c1 += 32; if ( (c2 >= 65) && (c2 <= 90) ) @@ -405,14 +405,14 @@ sal_Int32 SAL_CALL rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( const sal_U do { /* Check ASCII range */ - SAL_WARN_IF( ((unsigned char)*pStr2) > 127, "rtl.string", + SAL_WARN_IF( (static_cast(*pStr2)) > 127, "rtl.string", "rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength - Found char > 127" ); if ( !nStr1Len ) return *pStr2 == '\0' ? 0 : -1; /* If character between 'A' and 'Z', than convert it to lowercase */ - c1 = (sal_Int32)*pStr1; - c2 = (sal_Int32)((unsigned char)*pStr2); + c1 = static_cast(*pStr1); + c2 = static_cast(static_cast(*pStr2)); if ( (c1 >= 65) && (c1 <= 90) ) c1 += 32; if ( (c2 >= 65) && (c2 <= 90) ) @@ -439,10 +439,10 @@ sal_Int32 rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths( sal_Int32 len = firstLen < secondLen ? firstLen : secondLen; for (i = 0; i < len; ++i) { /* Check ASCII range */ - SAL_WARN_IF( ((unsigned char)*second) > 127, "rtl.string", + SAL_WARN_IF( (static_cast(*second)) > 127, "rtl.string", "rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths - Found char > 127" ); sal_Int32 c1 = *first++; - sal_Int32 c2 = (unsigned char) *second++; + sal_Int32 c2 = static_cast(*second++); sal_Int32 d; if (c1 >= 65 && c1 <= 90) { c1 += 32; @@ -476,12 +476,12 @@ sal_Int32 SAL_CALL rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( co (pStr1 < pStr1End) && *pStr2 ) { /* Check ASCII range */ - SAL_WARN_IF( ((unsigned char)*pStr2) > 127, "rtl.string", + SAL_WARN_IF( (static_cast(*pStr2)) > 127, "rtl.string", "rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength - Found char > 127" ); /* If character between 'A' and 'Z', than convert it to lowercase */ - c1 = (sal_Int32)*pStr1; - c2 = (sal_Int32)((unsigned char)*pStr2); + c1 = static_cast(*pStr1); + c2 = static_cast(static_cast(*pStr2)); if ( (c1 >= 65) && (c1 <= 90) ) c1 += 32; if ( (c2 >= 65) && (c2 <= 90) ) @@ -669,7 +669,7 @@ static int rtl_ImplGetFastUTF8UnicodeLen( const sal_Char* pStr, sal_Int32 nLen, pEndStr = pStr+nLen; while ( pStr < pEndStr ) { - unsigned char c = (unsigned char)*pStr; + unsigned char c = static_cast(*pStr); if ( !(c & 0x80) ) pStr++; @@ -790,7 +790,7 @@ retry: pBuffer = (*ppThis)->buffer; do { - assert(((unsigned char)*pStr) <= 127); + assert((static_cast(*pStr)) <= 127); *pBuffer = *pStr; pBuffer++; pStr++; @@ -1003,7 +1003,7 @@ void SAL_CALL rtl_uString_internConvert( rtl_uString ** newStr, for (i = 0; i < len; i++) { /* Check ASCII range */ - SAL_WARN_IF( ((unsigned char)str[i]) > 127, "rtl.string", + SAL_WARN_IF( (static_cast(str[i])) > 127, "rtl.string", "rtl_ustring_internConvert() - Found char > 127 and RTL_TEXTENCODING_ASCII_US is specified" ); pScratch->buffer[i] = str[i]; } diff --git a/sal/rtl/uuid.cxx b/sal/rtl/uuid.cxx index 9ffbff7ff2cc..632b842f6391 100644 --- a/sal/rtl/uuid.cxx +++ b/sal/rtl/uuid.cxx @@ -28,31 +28,31 @@ #define SWAP_INT32_TO_NETWORK(x)\ { sal_uInt32 y = x;\ sal_uInt8 *p = reinterpret_cast(&(x)); \ - p[0] = (sal_uInt8) ( ( y >> 24 ) & 0xff );\ - p[1] = (sal_uInt8) ( ( y >> 16 ) & 0xff );\ - p[2] = (sal_uInt8) ( ( y >> 8 ) & 0xff );\ - p[3] = (sal_uInt8) ( ( y ) & 0xff);\ + p[0] = static_cast( ( y >> 24 ) & 0xff );\ + p[1] = static_cast( ( y >> 16 ) & 0xff );\ + p[2] = static_cast( ( y >> 8 ) & 0xff );\ + p[3] = static_cast( ( y ) & 0xff);\ } #define SWAP_INT16_TO_NETWORK(x)\ { sal_uInt16 y = x;\ sal_uInt8 *p = reinterpret_cast(&(x)); \ - p[0] = (sal_uInt8) ( ( y >> 8 ) & 0xff );\ - p[1] = (sal_uInt8) ( ( y ) & 0xff);\ + p[0] = static_cast( ( y >> 8 ) & 0xff );\ + p[1] = static_cast( ( y ) & 0xff);\ } #define SWAP_NETWORK_TO_INT16(x)\ { sal_uInt16 y = x;\ sal_uInt8 *p = reinterpret_cast(&(y));\ - x = ( ( ((sal_uInt16)p[0]) & 0xff) << 8 ) |\ - ( ( (sal_uInt16)p[1]) & 0xff);\ + x = ( ( (static_cast(p[0])) & 0xff) << 8 ) |\ + ( ( static_cast(p[1])) & 0xff);\ } #define SWAP_NETWORK_TO_INT32(x)\ { sal_uInt32 y = x;\ sal_uInt8 *p = reinterpret_cast(&(y)); \ - x = ( ( ((sal_uInt32)p[0]) & 0xff) << 24 ) |\ - ( ( ((sal_uInt32)p[1]) & 0xff) << 16 ) |\ - ( ( ((sal_uInt32)p[2]) & 0xff) << 8 ) |\ - ( ( (sal_uInt32)p[3]) & 0xff);\ + x = ( ( (static_cast(p[0])) & 0xff) << 24 ) |\ + ( ( (static_cast(p[1])) & 0xff) << 16 ) |\ + ( ( (static_cast(p[2])) & 0xff) << 8 ) |\ + ( ( static_cast(p[3])) & 0xff);\ } struct UUID diff --git a/sal/textenc/convertbig5hkscs.cxx b/sal/textenc/convertbig5hkscs.cxx index eec82b2c495c..3d66bdfcc432 100644 --- a/sal/textenc/convertbig5hkscs.cxx +++ b/sal/textenc/convertbig5hkscs.cxx @@ -93,7 +93,7 @@ sal_Size ImplConvertBig5HkscsToUnicode(void const * pData, if (nRow == 0) if (nChar < 0x80) if (pDestBufPtr != pDestBufEnd) - *pDestBufPtr++ = (sal_Unicode) nChar; + *pDestBufPtr++ = static_cast(nChar); else goto no_output; else if (nChar >= 0x81 && nChar <= 0xFE) @@ -198,16 +198,16 @@ sal_Size ImplConvertBig5HkscsToUnicode(void const * pData, { nOffset += nLast - nFirst + 1; nFirst = pBig5Hkscs2001Data[nOffset++]; - *pDestBufPtr++ = (sal_Unicode) nUnicode; + *pDestBufPtr++ = static_cast(nUnicode); *pDestBufPtr++ - = (sal_Unicode) pBig5Hkscs2001Data[ - nOffset + (nChar - nFirst)]; + = static_cast(pBig5Hkscs2001Data[ + nOffset + (nChar - nFirst)]); } else goto no_output; else if (pDestBufPtr != pDestBufEnd) - *pDestBufPtr++ = (sal_Unicode) nUnicode; + *pDestBufPtr++ = static_cast(nUnicode); else goto no_output; nRow = 0; @@ -316,7 +316,7 @@ sal_Size ImplConvertUnicodeToBig5Hkscs(void const * pData, { if (ImplIsHighSurrogate(nChar)) { - nHighSurrogate = (sal_Unicode) nChar; + nHighSurrogate = static_cast(nChar); continue; } } diff --git a/sal/textenc/converter.cxx b/sal/textenc/converter.cxx index 8d23f3081522..92eca3fc190a 100644 --- a/sal/textenc/converter.cxx +++ b/sal/textenc/converter.cxx @@ -58,7 +58,7 @@ sal::detail::textenc::handleBadInputTextToUnicodeConversion( if (*pDestBufPtr != pDestBufEnd) { *(*pDestBufPtr)++ = RTL_TEXTCVT_BYTE_PRIVATE_START - | ((unsigned char) cByte); + | static_cast(cByte); return BAD_INPUT_CONTINUE; } else @@ -141,7 +141,7 @@ sal::detail::textenc::handleBadInputUnicodeToTextConversion( cReplace = '_'; break; } - if ((sal_Size) (pDestBufEnd - *pDestBufPtr) > nPrefixLen) + if (static_cast(pDestBufEnd - *pDestBufPtr) > nPrefixLen) { while (nPrefixLen-- > 0) *(*pDestBufPtr)++ = *pPrefix++; diff --git a/sal/textenc/converteuctw.cxx b/sal/textenc/converteuctw.cxx index 14be7000cc88..87becd9b11ec 100644 --- a/sal/textenc/converteuctw.cxx +++ b/sal/textenc/converteuctw.cxx @@ -110,7 +110,7 @@ sal_Size ImplConvertEucTwToUnicode(void const * pData, case IMPL_EUC_TW_TO_UNICODE_STATE_0: if (nChar < 0x80) if (pDestBufPtr != pDestBufEnd) - *pDestBufPtr++ = (sal_Unicode) nChar; + *pDestBufPtr++ = static_cast(nChar); else goto no_output; else if (nChar >= 0xA1 && nChar <= 0xFE) @@ -206,17 +206,16 @@ sal_Size ImplConvertEucTwToUnicode(void const * pData, { nOffset += nLast - nFirst + 1; nFirst = pCns116431992Data[nOffset++]; - *pDestBufPtr++ = (sal_Unicode) nUnicode; + *pDestBufPtr++ = static_cast(nUnicode); *pDestBufPtr++ - = (sal_Unicode) - pCns116431992Data[ - nOffset + (nChar - nFirst)]; + = static_cast(pCns116431992Data[ + nOffset + (nChar - nFirst)]); } else goto no_output; else if (pDestBufPtr != pDestBufEnd) - *pDestBufPtr++ = (sal_Unicode) nUnicode; + *pDestBufPtr++ = static_cast(nUnicode); else goto no_output; } @@ -326,7 +325,7 @@ sal_Size ImplConvertUnicodeToEucTw(void const * pData, { if (ImplIsHighSurrogate(nChar)) { - nHighSurrogate = (sal_Unicode) nChar; + nHighSurrogate = static_cast(nChar); continue; } } diff --git a/sal/textenc/convertgb18030.cxx b/sal/textenc/convertgb18030.cxx index 28ddd9335bb8..87e814674bb7 100644 --- a/sal/textenc/convertgb18030.cxx +++ b/sal/textenc/convertgb18030.cxx @@ -102,7 +102,7 @@ sal_Size ImplConvertGb18030ToUnicode(void const * pData, case IMPL_GB_18030_TO_UNICODE_STATE_0: if (nChar < 0x80) if (pDestBufPtr != pDestBufEnd) - *pDestBufPtr++ = (sal_Unicode) nChar; + *pDestBufPtr++ = static_cast(nChar); else goto no_output; else if (nChar == 0x80) @@ -167,9 +167,9 @@ sal_Size ImplConvertGb18030ToUnicode(void const * pData, { nCode -= 189000 - 0x10000; *pDestBufPtr++ - = (sal_Unicode) ImplGetHighSurrogate(nCode); + = static_cast(ImplGetHighSurrogate(nCode)); *pDestBufPtr++ - = (sal_Unicode) ImplGetLowSurrogate(nCode); + = static_cast(ImplGetLowSurrogate(nCode)); } else goto no_output; @@ -197,8 +197,7 @@ sal_Size ImplConvertGb18030ToUnicode(void const * pData, { if (pDestBufPtr != pDestBufEnd) *pDestBufPtr++ - = (sal_Unicode) - (pRange->m_nFirstUnicode + = static_cast(pRange->m_nFirstUnicode + (nCode - pRange-> m_nFirstLinear)); @@ -314,7 +313,7 @@ sal_Size ImplConvertUnicodeToGb18030(void const * pData, { if (ImplIsHighSurrogate(nChar)) { - nHighSurrogate = (sal_Unicode) nChar; + nHighSurrogate = static_cast(nChar); continue; } } @@ -381,7 +380,7 @@ sal_Size ImplConvertUnicodeToGb18030(void const * pData, break; } nFirstNonRange - = (sal_Unicode) ((pRange++)->m_nLastUnicode + 1); + = static_cast((pRange++)->m_nLastUnicode + 1); } } else diff --git a/sal/textenc/convertiso2022cn.cxx b/sal/textenc/convertiso2022cn.cxx index 5d534fc2fa84..e931d68f1f35 100644 --- a/sal/textenc/convertiso2022cn.cxx +++ b/sal/textenc/convertiso2022cn.cxx @@ -150,7 +150,7 @@ sal_Size ImplConvertIso2022CnToUnicode(void const * pData, eState = IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC; else if (nChar < 0x80) if (pDestBufPtr != pDestBufEnd) - *pDestBufPtr++ = (sal_Unicode) nChar; + *pDestBufPtr++ = static_cast(nChar); else goto no_output; else @@ -201,7 +201,7 @@ sal_Size ImplConvertIso2022CnToUnicode(void const * pData, if (nUnicode != 0) if (pDestBufPtr != pDestBufEnd) { - *pDestBufPtr++ = (sal_Unicode) nUnicode; + *pDestBufPtr++ = static_cast(nUnicode); eState = IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO; } else @@ -328,17 +328,16 @@ sal_Size ImplConvertIso2022CnToUnicode(void const * pData, { nOffset += nLast - nFirst + 1; nFirst = pCns116431992Data[nOffset++]; - *pDestBufPtr++ = (sal_Unicode) nUnicode; + *pDestBufPtr++ = static_cast(nUnicode); *pDestBufPtr++ - = (sal_Unicode) - pCns116431992Data[ - nOffset + (nChar - nFirst)]; + = static_cast(pCns116431992Data[ + nOffset + (nChar - nFirst)]); } else goto no_output; else if (pDestBufPtr != pDestBufEnd) - *pDestBufPtr++ = (sal_Unicode) nUnicode; + *pDestBufPtr++ = static_cast(nUnicode); else goto no_output; } @@ -541,7 +540,7 @@ sal_Size ImplConvertUnicodeToIso2022Cn(void const * pData, { if (ImplIsHighSurrogate(nChar)) { - nHighSurrogate = (sal_Unicode) nChar; + nHighSurrogate = static_cast(nChar); continue; } } diff --git a/sal/textenc/convertiso2022jp.cxx b/sal/textenc/convertiso2022jp.cxx index d455f7cfb896..f0eb5eb9a936 100644 --- a/sal/textenc/convertiso2022jp.cxx +++ b/sal/textenc/convertiso2022jp.cxx @@ -112,7 +112,7 @@ sal_Size ImplConvertIso2022JpToUnicode(void const * pData, eState = IMPL_ISO_2022_JP_TO_UNICODE_STATE_ESC; else if (nChar < 0x80) if (pDestBufPtr != pDestBufEnd) - *pDestBufPtr++ = (sal_Unicode) nChar; + *pDestBufPtr++ = static_cast(nChar); else goto no_output; else @@ -138,7 +138,7 @@ sal_Size ImplConvertIso2022JpToUnicode(void const * pData, nChar = 0xAF; // MACRON break; } - *pDestBufPtr++ = (sal_Unicode) nChar; + *pDestBufPtr++ = static_cast(nChar); } else goto no_output; @@ -176,7 +176,7 @@ sal_Size ImplConvertIso2022JpToUnicode(void const * pData, if (nUnicode != 0) if (pDestBufPtr != pDestBufEnd) { - *pDestBufPtr++ = (sal_Unicode) nUnicode; + *pDestBufPtr++ = static_cast(nUnicode); eState = IMPL_ISO_2022_JP_TO_UNICODE_STATE_0208; } else @@ -360,7 +360,7 @@ sal_Size ImplConvertUnicodeToIso2022Jp(void const * pData, { if (ImplIsHighSurrogate(nChar)) { - nHighSurrogate = (sal_Unicode) nChar; + nHighSurrogate = static_cast(nChar); continue; } } diff --git a/sal/textenc/convertiso2022kr.cxx b/sal/textenc/convertiso2022kr.cxx index 4daef323b40e..c65bc8597414 100644 --- a/sal/textenc/convertiso2022kr.cxx +++ b/sal/textenc/convertiso2022kr.cxx @@ -120,7 +120,7 @@ sal_Size ImplConvertIso2022KrToUnicode(void const * pData, eState = IMPL_ISO_2022_KR_TO_UNICODE_STATE_ESC; else if (nChar < 0x80) if (pDestBufPtr != pDestBufEnd) - *pDestBufPtr++ = (sal_Unicode) nChar; + *pDestBufPtr++ = static_cast(nChar); else goto no_output; else @@ -157,7 +157,7 @@ sal_Size ImplConvertIso2022KrToUnicode(void const * pData, if (nUnicode != 0) if (pDestBufPtr != pDestBufEnd) { - *pDestBufPtr++ = (sal_Unicode) nUnicode; + *pDestBufPtr++ = static_cast(nUnicode); eState = IMPL_ISO_2022_KR_TO_UNICODE_STATE_1001; } else @@ -339,7 +339,7 @@ sal_Size ImplConvertUnicodeToIso2022Kr(void const * pData, { if (ImplIsHighSurrogate(nChar)) { - nHighSurrogate = (sal_Unicode) nChar; + nHighSurrogate = static_cast(nChar); continue; } } diff --git a/sal/textenc/convertsimple.cxx b/sal/textenc/convertsimple.cxx index d4d23c82e6af..e621cdda504a 100644 --- a/sal/textenc/convertsimple.cxx +++ b/sal/textenc/convertsimple.cxx @@ -524,7 +524,7 @@ sal_Size sal::detail::textenc::convertCharToUnicode( pEndSrcBuf = pSrcBuf+nSrcBytes; while ( pSrcBuf < pEndSrcBuf ) { - unsigned char c = (unsigned char)*pSrcBuf; + unsigned char c = static_cast(*pSrcBuf); if ( c < 0x80 ) cConv = c; else diff --git a/sal/textenc/handleundefinedunicodetotextchar.cxx b/sal/textenc/handleundefinedunicodetotextchar.cxx index 007e342b485e..320562495e97 100644 --- a/sal/textenc/handleundefinedunicodetotextchar.cxx +++ b/sal/textenc/handleundefinedunicodetotextchar.cxx @@ -90,7 +90,7 @@ bool sal::detail::textenc::handleUndefinedUnicodeToTextChar( { if ( nFlags & RTL_UNICODETOTEXT_FLAGS_PRIVATE_MAPTO0 ) { - **ppDestBuf = (char)(unsigned char)(c-RTL_TEXTCVT_BYTE_PRIVATE_START); + **ppDestBuf = static_cast(static_cast(c-RTL_TEXTCVT_BYTE_PRIVATE_START)); (*ppDestBuf)++; (*ppSrcBuf)++; return true; diff --git a/sal/textenc/tcvtbyte.cxx b/sal/textenc/tcvtbyte.cxx index aa6664a40494..ee727d9f910f 100644 --- a/sal/textenc/tcvtbyte.cxx +++ b/sal/textenc/tcvtbyte.cxx @@ -47,11 +47,11 @@ sal_Size ImplSymbolToUnicode( SAL_UNUSED_PARAMETER const void*, } /* 0-31 (all Control-Character get the same Unicode value) */ - unsigned char c = (unsigned char)*pSrcBuf; + unsigned char c = static_cast(*pSrcBuf); if ( c <= 0x1F ) - *pDestBuf = (sal_Unicode)c; + *pDestBuf = static_cast(c); else - *pDestBuf = ((sal_Unicode)c)+0xF000; + *pDestBuf = static_cast(c)+0xF000; pDestBuf++; pSrcBuf++; } @@ -142,7 +142,7 @@ sal_Size ImplUpperCharToUnicode( const void* pData, } while ( pSrcBuf < pEndSrcBuf ) { - unsigned char c = (unsigned char)*pSrcBuf; + unsigned char c = static_cast(*pSrcBuf); if (c < 0x80) cConv = c; else diff --git a/sal/textenc/tcvtmb.cxx b/sal/textenc/tcvtmb.cxx index efdf01ea4e90..b5b6903a1d40 100644 --- a/sal/textenc/tcvtmb.cxx +++ b/sal/textenc/tcvtmb.cxx @@ -49,7 +49,7 @@ sal_Size ImplDBCSToUnicode( const void* pData, SAL_UNUSED_PARAMETER void*, pEndSrcBuf = pSrcBuf+nSrcBytes; while ( pSrcBuf < pEndSrcBuf ) { - unsigned char cLead = (unsigned char)*pSrcBuf; + unsigned char cLead = static_cast(*pSrcBuf); /* get entry for the lead byte */ pLeadEntry = pLeadTab+cLead; @@ -91,7 +91,7 @@ sal_Size ImplDBCSToUnicode( const void* pData, SAL_UNUSED_PARAMETER void*, else { pSrcBuf++; - cTrail = (unsigned char)*pSrcBuf; + cTrail = static_cast(*pSrcBuf); if ( (cTrail >= pLeadEntry->mnTrailStart) && (cTrail <= pLeadEntry->mnTrailEnd) ) cConv = pLeadEntry->mpToUniTrailTab[cTrail-pLeadEntry->mnTrailStart]; else @@ -229,8 +229,8 @@ sal_Size ImplUnicodeToDBCS( const void* pData, SAL_UNUSED_PARAMETER void*, while ( pSrcBuf < pEndSrcBuf ) { c = *pSrcBuf; - unsigned char nHighChar = (unsigned char)((c >> 8) & 0xFF); - unsigned char nLowChar = (unsigned char)(c & 0xFF); + unsigned char nHighChar = static_cast((c >> 8) & 0xFF); + unsigned char nLowChar = static_cast(c & 0xFF); /* get entry for the high byte */ pHighEntry = pHighTab+nHighChar; @@ -264,8 +264,7 @@ sal_Size ImplUnicodeToDBCS( const void* pData, SAL_UNUSED_PARAMETER void*, sal_uInt32 nTrailOff = nIndex % pEUDCTab->mnTrailRangeCount; sal_uInt32 nSize; - cConv = (sal_uInt16) - ((pEUDCTab->mnLeadStart + nLeadOff) << 8); + cConv = static_cast((pEUDCTab->mnLeadStart + nLeadOff) << 8); nSize = pEUDCTab->mnTrail1End - pEUDCTab->mnTrail1Start + 1; if (nTrailOff < nSize) @@ -379,7 +378,7 @@ sal_Size ImplEUCJPToUnicode( const void* pData, pEndSrcBuf = pSrcBuf+nSrcBytes; while ( pSrcBuf < pEndSrcBuf ) { - unsigned char c = (unsigned char)*pSrcBuf; + unsigned char c = static_cast(*pSrcBuf); /* ASCII */ if ( c <= 0x7F ) @@ -398,7 +397,7 @@ sal_Size ImplEUCJPToUnicode( const void* pData, } pSrcBuf++; - c = (unsigned char)*pSrcBuf; + c = static_cast(*pSrcBuf); if ( (c >= 0xA1) && (c <= 0xDF) ) cConv = 0xFF61+(c-0xA1); else @@ -422,9 +421,9 @@ sal_Size ImplEUCJPToUnicode( const void* pData, } pSrcBuf++; - cLead = (unsigned char)*pSrcBuf; + cLead = static_cast(*pSrcBuf); pSrcBuf++; - cTrail = (unsigned char)*pSrcBuf; + cTrail = static_cast(*pSrcBuf); pLeadTab = pConvertData->mpJIS0212ToUniLeadTab; } /* CodeSet 2 JIS 0208-1997 */ @@ -440,7 +439,7 @@ sal_Size ImplEUCJPToUnicode( const void* pData, cLead = c; pSrcBuf++; - cTrail = (unsigned char)*pSrcBuf; + cTrail = static_cast(*pSrcBuf); pLeadTab = pConvertData->mpJIS0208ToUniLeadTab; } @@ -547,8 +546,8 @@ sal_Size ImplUnicodeToEUCJP( const void* pData, cConv = 0x8E00+0xA1+(c-0xFF61); else { - nHighChar = (unsigned char)((c >> 8) & 0xFF); - nLowChar = (unsigned char)(c & 0xFF); + nHighChar = static_cast((c >> 8) & 0xFF); + nLowChar = static_cast(c & 0xFF); /* JIS 0208 */ pHighTab = pConvertData->mpUniToJIS0208HighTab; diff --git a/sal/textenc/tcvtutf7.cxx b/sal/textenc/tcvtutf7.cxx index 2b18d4370b3a..6c0625d0016e 100644 --- a/sal/textenc/tcvtutf7.cxx +++ b/sal/textenc/tcvtutf7.cxx @@ -180,7 +180,7 @@ sal_Size ImplUTF7ToUnicode( SAL_UNUSED_PARAMETER const void*, void* pContext, { if ( pSrcBuf < pEndSrcBuf ) { - c = (unsigned char)*pSrcBuf; + c = static_cast(*pSrcBuf); /* End, when not a base64 character */ bBase64End = false; @@ -235,7 +235,7 @@ sal_Size ImplUTF7ToUnicode( SAL_UNUSED_PARAMETER const void*, void* pContext, /* Skip character */ pSrcBuf++; if ( pSrcBuf < pEndSrcBuf ) - c = (unsigned char)*pSrcBuf; + c = static_cast(*pSrcBuf); else bEnd = true; } @@ -266,7 +266,7 @@ sal_Size ImplUTF7ToUnicode( SAL_UNUSED_PARAMETER const void*, void* pContext, { /* Add 6 Bits from character to the bit buffer */ nBufferBits += 6; - nBitBuffer |= ((sal_uInt32)(nBase64Value & 0x3F)) << (32-nBufferBits); + nBitBuffer |= static_cast(nBase64Value & 0x3F) << (32-nBufferBits); bFirst = false; } @@ -275,7 +275,7 @@ sal_Size ImplUTF7ToUnicode( SAL_UNUSED_PARAMETER const void*, void* pContext, while ( (pDestBuf < pEndDestBuf) && (nBufferBits >= 16) ) { nBitBufferTemp = nBitBuffer >> (32-16); - *pDestBuf = (sal_Unicode)(nBitBufferTemp & 0xFFFF); + *pDestBuf = static_cast(nBitBufferTemp & 0xFFFF); pDestBuf++; nBitBuffer <<= 16; nBufferBits -= 16; @@ -506,7 +506,7 @@ sal_Size ImplUnicodeToUTF7( SAL_UNUSED_PARAMETER const void*, void* pContext, if ( bNeedShift ) { nBufferBits += 16; - nBitBuffer |= ((sal_uInt32)c) << (32-nBufferBits); + nBitBuffer |= static_cast(c) << (32-nBufferBits); } else nBufferBits += (6-(nBufferBits%6))%6; diff --git a/sal/textenc/tcvtutf8.cxx b/sal/textenc/tcvtutf8.cxx index 0f0ac6fbbdf1..72b336b9ded4 100644 --- a/sal/textenc/tcvtutf8.cxx +++ b/sal/textenc/tcvtutf8.cxx @@ -187,13 +187,13 @@ sal_Size ImplConvertUtf8ToUnicode( } if (nUtf32 <= 0xFFFF) if (pDestBufPtr != pDestBufEnd) - *pDestBufPtr++ = (sal_Unicode) nUtf32; + *pDestBufPtr++ = static_cast(nUtf32); else goto no_output; else if (pDestBufEnd - pDestBufPtr >= 2) { - *pDestBufPtr++ = (sal_Unicode) ImplGetHighSurrogate(nUtf32); - *pDestBufPtr++ = (sal_Unicode) ImplGetLowSurrogate(nUtf32); + *pDestBufPtr++ = static_cast(ImplGetHighSurrogate(nUtf32)); + *pDestBufPtr++ = static_cast(ImplGetLowSurrogate(nUtf32)); } else goto no_output; @@ -333,7 +333,7 @@ sal_Size ImplConvertUnicodeToUtf8( { if (ImplIsHighSurrogate(nChar) && !bJavaUtf8) { - nHighSurrogate = (sal_Unicode) nChar; + nHighSurrogate = static_cast(nChar); continue; } } diff --git a/sal/textenc/textcvt.cxx b/sal/textenc/textcvt.cxx index 76f0f826f89b..2d5add0a89e4 100644 --- a/sal/textenc/textcvt.cxx +++ b/sal/textenc/textcvt.cxx @@ -57,7 +57,7 @@ static sal_Size ImplDummyToUnicode( const char* pSrcBuf, sal_Size nSrcBytes, break; } - *pDestBuf = (sal_Unicode)(unsigned char)*pSrcBuf; + *pDestBuf = static_cast(static_cast(*pSrcBuf)); pDestBuf++; pSrcBuf++; } @@ -94,7 +94,7 @@ static sal_Size ImplUnicodeToDummy( const sal_Unicode* pSrcBuf, sal_Size nSrcCha break; } - *pDestBuf = (char)(unsigned char)(*pSrcBuf & 0x00FF); + *pDestBuf = static_cast(static_cast(*pSrcBuf & 0x00FF)); pDestBuf++; pSrcBuf++; } -- cgit