From d847a21238239b95a55c15c912696dd7ccdc5f09 Mon Sep 17 00:00:00 2001 From: William Zhao <39807811+mingyzha@users.noreply.github.com> Date: Sat, 22 Jul 2017 01:11:59 +0000 Subject: [PATCH] ICU-13275 Merge warning cleanup fixes into trunk X-SVN-Rev: 40283 --- icu4c/source/common/caniter.cpp | 2 +- icu4c/source/common/locmap.cpp | 4 ++-- icu4c/source/common/putil.cpp | 7 ++++--- icu4c/source/common/uchar.cpp | 5 +---- icu4c/source/common/uchar_props_data.h | 2 +- icu4c/source/common/ucnv_ct.cpp | 2 +- icu4c/source/common/ucnv_lmb.cpp | 8 ++++---- icu4c/source/common/ucnvmbcs.cpp | 4 ++-- icu4c/source/common/udata.cpp | 8 ++++++-- icu4c/source/common/uhash.cpp | 2 +- icu4c/source/common/uinvchar.cpp | 4 ++-- icu4c/source/common/ulist.cpp | 2 +- icu4c/source/common/uloc.cpp | 6 +++--- icu4c/source/common/uloc_tag.cpp | 6 +++--- icu4c/source/common/umapfile.cpp | 10 +++++---- icu4c/source/common/umutex.cpp | 2 +- icu4c/source/common/unifiedcache.h | 2 +- icu4c/source/common/ustrtrns.cpp | 2 +- icu4c/source/common/uts46.cpp | 8 ++++---- icu4c/source/i18n/plurrule.cpp | 2 +- icu4c/source/i18n/tzfmt.cpp | 10 +++++---- icu4c/source/i18n/tzgnames.cpp | 6 +++--- icu4c/source/i18n/tznames_impl.cpp | 4 ++-- icu4c/source/i18n/ucol_res.cpp | 4 ++-- icu4c/source/i18n/unum.cpp | 2 +- icu4c/source/i18n/uspoof.cpp | 8 ++++---- icu4c/source/i18n/windtfmt.cpp | 6 +++--- icu4c/source/i18n/winnmfmt.cpp | 8 ++++---- icu4c/source/i18n/wintzimpl.cpp | 28 +++++++++++++------------- icu4c/source/i18n/zonemeta.cpp | 2 +- 30 files changed, 86 insertions(+), 80 deletions(-) diff --git a/icu4c/source/common/caniter.cpp b/icu4c/source/common/caniter.cpp index aee9f4ee31a..b28acfc84ee 100644 --- a/icu4c/source/common/caniter.cpp +++ b/icu4c/source/common/caniter.cpp @@ -405,7 +405,7 @@ UnicodeString* CanonicalIterator::getEquivalents(const UnicodeString &segment, i //String[] finalResult = new String[result.size()]; UnicodeString *finalResult = NULL; int32_t resultCount; - if((resultCount = result.count())) { + if((resultCount = result.count()) != 0) { finalResult = new UnicodeString[resultCount]; if (finalResult == 0) { status = U_MEMORY_ALLOCATION_ERROR; diff --git a/icu4c/source/common/locmap.cpp b/icu4c/source/common/locmap.cpp index ea4d61efe4b..cbb2b810a58 100644 --- a/icu4c/source/common/locmap.cpp +++ b/icu4c/source/common/locmap.cpp @@ -1132,7 +1132,7 @@ uprv_convertToPosix(uint32_t hostid, char *posixID, int32_t posixIDCapacity, UEr } if (pPosixID) { - int32_t resLen = uprv_strlen(pPosixID); + int32_t resLen = static_cast(uprv_strlen(pPosixID)); int32_t copyLen = resLen <= posixIDCapacity ? resLen : posixIDCapacity; uprv_memcpy(posixID, pPosixID, copyLen); if (resLen < posixIDCapacity) { @@ -1206,7 +1206,7 @@ uprv_convertToLCIDPlatform(const char* localeID) char asciiBCP47Tag[LOCALE_NAME_MAX_LENGTH] = {}; // this will change it from de_DE@collation=phonebook to de-DE-u-co-phonebk form - int32_t bcp47Len = uloc_toLanguageTag(mylocaleID, asciiBCP47Tag, UPRV_LENGTHOF(asciiBCP47Tag), FALSE, &myStatus); + (void)uloc_toLanguageTag(mylocaleID, asciiBCP47Tag, UPRV_LENGTHOF(asciiBCP47Tag), FALSE, &myStatus); if (U_SUCCESS(myStatus)) { diff --git a/icu4c/source/common/putil.cpp b/icu4c/source/common/putil.cpp index 96f343635a7..1bfd2475228 100644 --- a/icu4c/source/common/putil.cpp +++ b/icu4c/source/common/putil.cpp @@ -1050,7 +1050,7 @@ uprv_getWindowsTimeZone() hr = timezone->GetTimeZone(timezoneString.GetAddressOf()); if (SUCCEEDED(hr)) { - int32_t length = wcslen(timezoneString.GetRawBuffer(NULL)); + int32_t length = static_cast(wcslen(timezoneString.GetRawBuffer(NULL))); char* asciiId = (char*)uprv_calloc(length + 1, sizeof(char)); if (asciiId != nullptr) { @@ -1069,6 +1069,7 @@ uprv_getWindowsTimeZone() U_CAPI const char* U_EXPORT2 uprv_tzname(int n) { + n; // Avoid unreferenced parameter warning. const char *tzid = NULL; #if U_PLATFORM_USES_ONLY_WIN32_API #if U_PLATFORM_HAS_WINUWP_API > 0 @@ -1292,7 +1293,7 @@ u_setDataDirectory(const char *directory) { #if (U_FILE_SEP_CHAR != U_FILE_ALT_SEP_CHAR) { char *p; - while(p = uprv_strchr(newDataDir, U_FILE_ALT_SEP_CHAR)) { + while((p = uprv_strchr(newDataDir, U_FILE_ALT_SEP_CHAR)) != NULL) { *p = U_FILE_SEP_CHAR; } } @@ -1450,7 +1451,7 @@ static void setTimeZoneFilesDir(const char *path, UErrorCode &status) { gTimeZoneFilesDirectory->append(path, status); #if (U_FILE_SEP_CHAR != U_FILE_ALT_SEP_CHAR) char *p = gTimeZoneFilesDirectory->data(); - while (p = uprv_strchr(p, U_FILE_ALT_SEP_CHAR)) { + while ((p = uprv_strchr(p, U_FILE_ALT_SEP_CHAR)) != NULL) { *p = U_FILE_SEP_CHAR; } #endif diff --git a/icu4c/source/common/uchar.cpp b/icu4c/source/common/uchar.cpp index 6d96f342fc7..a7374b7e9ad 100644 --- a/icu4c/source/common/uchar.cpp +++ b/icu4c/source/common/uchar.cpp @@ -729,8 +729,5 @@ upropsvec_addPropertyStarts(const USetAdder *sa, UErrorCode *pErrorCode) { } /* add the start code point of each same-value range of the properties vectors trie */ - if(propsVectorsColumns>0) { - /* if propsVectorsColumns==0 then the properties vectors trie may not be there at all */ - utrie2_enum(&propsVectorsTrie, NULL, _enumPropertyStartsRange, sa); - } + utrie2_enum(&propsVectorsTrie, NULL, _enumPropertyStartsRange, sa); } diff --git a/icu4c/source/common/uchar_props_data.h b/icu4c/source/common/uchar_props_data.h index 5b5c4ddca1e..94de36673d7 100644 --- a/icu4c/source/common/uchar_props_data.h +++ b/icu4c/source/common/uchar_props_data.h @@ -3601,7 +3601,7 @@ static const uint32_t propsVectors[6375]={ 0xe30000,0xa00b1596,0x7c00300,0xe30000,0xa040af86,0x6800400,0x962540}; static const int32_t countPropsVectors=6375; -static const int32_t propsVectorsColumns=3; +static const int32_t propsVectorsColumns=3; /* The code assumes that this value is > 0*/ static const uint16_t scriptExtensions[198]={ 0x800e,0x8019,8,0x8059,8,2,8,0x8038,8,6,8,0x8019,3,0x800c,2,0x22, 0x8025,2,0xe,2,0x22,0x54,0x79,0x7b,0x80a7,2,0x8022,2,0x8025,2,0x1b,4, diff --git a/icu4c/source/common/ucnv_ct.cpp b/icu4c/source/common/ucnv_ct.cpp index c9a0ce36930..e363193860a 100644 --- a/icu4c/source/common/ucnv_ct.cpp +++ b/icu4c/source/common/ucnv_ct.cpp @@ -519,7 +519,7 @@ UConverter_toUnicode_CompoundText_OFFSETS(UConverterToUnicodeArgs *args, currentState = tmpState; } - sourceOffset = uprv_strlen((char*)escSeqCompoundText[currentState]) - args->converter->toULength; + sourceOffset = static_cast(uprv_strlen((char*)escSeqCompoundText[currentState]) - args->converter->toULength); mySource += sourceOffset; diff --git a/icu4c/source/common/ucnv_lmb.cpp b/icu4c/source/common/ucnv_lmb.cpp index ec6dc66bda9..1ec56f7a45f 100644 --- a/icu4c/source/common/ucnv_lmb.cpp +++ b/icu4c/source/common/ucnv_lmb.cpp @@ -966,26 +966,26 @@ _LMBCSFromUnicode(UConverterFromUnicodeArgs* args, if(extraInfo->localeConverterIndex < ULMBCS_DOUBLEOPTGROUP_START) { - bytes_written = LMBCSConversionWorker (extraInfo, + bytes_written = (int32_t)LMBCSConversionWorker (extraInfo, ULMBCS_GRP_L1, pLMBCS, &uniChar, &lastConverterIndex, groups_tried); if(!bytes_written) { - bytes_written = LMBCSConversionWorker (extraInfo, + bytes_written = (int32_t)LMBCSConversionWorker (extraInfo, ULMBCS_GRP_EXCEPT, pLMBCS, &uniChar, &lastConverterIndex, groups_tried); } if(!bytes_written) { - bytes_written = LMBCSConversionWorker (extraInfo, + bytes_written = (int32_t)LMBCSConversionWorker (extraInfo, extraInfo->localeConverterIndex, pLMBCS, &uniChar, &lastConverterIndex, groups_tried); } } else { - bytes_written = LMBCSConversionWorker (extraInfo, + bytes_written = (int32_t)LMBCSConversionWorker (extraInfo, extraInfo->localeConverterIndex, pLMBCS, &uniChar, &lastConverterIndex, groups_tried); } diff --git a/icu4c/source/common/ucnvmbcs.cpp b/icu4c/source/common/ucnvmbcs.cpp index 7f37eeeeaaf..21a651f8968 100644 --- a/icu4c/source/common/ucnvmbcs.cpp +++ b/icu4c/source/common/ucnvmbcs.cpp @@ -5037,7 +5037,7 @@ ucnv_SBCSFromUTF8(UConverterFromUnicodeArgs *pFromUArgs, uint8_t b, t1, t2; uint32_t asciiRoundtrips; - uint16_t value, minValue; + uint16_t value, minValue = 0; UBool hasSupplementary; /* set up the local pointers */ @@ -5344,7 +5344,7 @@ ucnv_DBCSFromUTF8(UConverterFromUnicodeArgs *pFromUArgs, uint32_t stage2Entry; uint32_t asciiRoundtrips; - uint16_t value; + uint16_t value = 0; UBool hasSupplementary; /* set up the local pointers */ diff --git a/icu4c/source/common/udata.cpp b/icu4c/source/common/udata.cpp index 29074a64c45..3cb8863f6c3 100644 --- a/icu4c/source/common/udata.cpp +++ b/icu4c/source/common/udata.cpp @@ -206,6 +206,8 @@ setCommonICUData(UDataMemory *pData, /* The new common data. Belongs to ca return didUpdate; } +#if U_PLATFORM_HAS_WINUWP_API == 0 + static UBool setCommonICUDataPointer(const void *pData, UBool /*warn*/, UErrorCode *pErrorCode) { UDataMemory tData; @@ -215,6 +217,8 @@ setCommonICUDataPointer(const void *pData, UBool /*warn*/, UErrorCode *pErrorCod return setCommonICUData(&tData, FALSE, pErrorCode); } +#endif + static const char * findBasename(const char *path) { const char *basename=uprv_strrchr(path, U_FILE_SEP_CHAR); @@ -982,7 +986,7 @@ static UDataMemory *doLoadFromIndividualFiles(const char *pkgName, /* init path iterator for individual files */ UDataPathIterator iter(dataPath, pkgName, path, tocEntryPathSuffix, FALSE, pErrorCode); - while((pathBuffer = iter.next(pErrorCode))) + while((pathBuffer = iter.next(pErrorCode)) != NULL) { #ifdef UDATA_DEBUG fprintf(stderr, "UDATA: trying individual file %s\n", pathBuffer); @@ -1165,7 +1169,7 @@ doOpenChoice(const char *path, const char *type, const char *name, if(uprv_strchr(path,U_FILE_ALT_SEP_CHAR) != NULL) { altSepPath.append(path, *pErrorCode); char *p; - while((p=uprv_strchr(altSepPath.data(), U_FILE_ALT_SEP_CHAR))) { + while ((p = uprv_strchr(altSepPath.data(), U_FILE_ALT_SEP_CHAR)) != NULL) { *p = U_FILE_SEP_CHAR; } #if defined (UDATA_DEBUG) diff --git a/icu4c/source/common/uhash.cpp b/icu4c/source/common/uhash.cpp index 6bde9e59f01..b7326f238cc 100644 --- a/icu4c/source/common/uhash.cpp +++ b/icu4c/source/common/uhash.cpp @@ -844,7 +844,7 @@ uhash_hashUChars(const UHashTok key) { U_CAPI int32_t U_EXPORT2 uhash_hashChars(const UHashTok key) { const char *s = (const char *)key.pointer; - return s == NULL ? 0 : ustr_hashCharsN(s, uprv_strlen(s)); + return s == NULL ? 0 : static_cast(ustr_hashCharsN(s, uprv_strlen(s))); } U_CAPI int32_t U_EXPORT2 diff --git a/icu4c/source/common/uinvchar.cpp b/icu4c/source/common/uinvchar.cpp index c478e363658..a0fd9dfbb1c 100644 --- a/icu4c/source/common/uinvchar.cpp +++ b/icu4c/source/common/uinvchar.cpp @@ -573,7 +573,7 @@ uprv_aestrncpy(uint8_t *dst, const uint8_t *src, int32_t n) uint8_t *orig_dst = dst; if(n==-1) { - n = uprv_strlen((const char*)src)+1; /* copy NUL */ + n = static_cast(uprv_strlen((const char*)src)+1); /* copy NUL */ } /* copy non-null */ while(*src && n>0) { @@ -594,7 +594,7 @@ uprv_eastrncpy(uint8_t *dst, const uint8_t *src, int32_t n) uint8_t *orig_dst = dst; if(n==-1) { - n = uprv_strlen((const char*)src)+1; /* copy NUL */ + n = static_cast(uprv_strlen((const char*)src)+1); /* copy NUL */ } /* copy non-null */ while(*src && n>0) { diff --git a/icu4c/source/common/ulist.cpp b/icu4c/source/common/ulist.cpp index b3f3fd8b7e8..c5180431c31 100644 --- a/icu4c/source/common/ulist.cpp +++ b/icu4c/source/common/ulist.cpp @@ -252,7 +252,7 @@ U_CAPI const char * U_EXPORT2 ulist_next_keyword_value(UEnumeration *en, int32_t s = (const char *)ulist_getNext((UList *)(en->context)); if (s != NULL && resultLength != NULL) { - *resultLength = uprv_strlen(s); + *resultLength = static_cast(uprv_strlen(s)); } return s; } diff --git a/icu4c/source/common/uloc.cpp b/icu4c/source/common/uloc.cpp index 9ca90160724..4a6cdbcc197 100644 --- a/icu4c/source/common/uloc.cpp +++ b/icu4c/source/common/uloc.cpp @@ -538,7 +538,7 @@ static const VariantMap VARIANT_MAP[] = { } /* Gets the size of the shortest subtag in the given localeID. */ static int32_t getShortestSubtagLength(const char *localeID) { - int32_t localeIDLength = uprv_strlen(localeID); + int32_t localeIDLength = static_cast(uprv_strlen(localeID)); int32_t length = localeIDLength; int32_t tmpLength = 0; int32_t i; @@ -2488,7 +2488,7 @@ uloc_acceptLanguage(char *result, int32_t resultAvailable, #if defined(ULOC_DEBUG) fprintf(stderr,"%02d: %s\n", i, acceptList[i]); #endif - while((l=uenum_next(availableLocales, NULL, status))) { + while((l=uenum_next(availableLocales, NULL, status)) != NULL) { #if defined(ULOC_DEBUG) fprintf(stderr," %s\n", l); #endif @@ -2528,7 +2528,7 @@ uloc_acceptLanguage(char *result, int32_t resultAvailable, #if defined(ULOC_DEBUG) fprintf(stderr,"Try: [%s]", fallbackList[i]); #endif - while((l=uenum_next(availableLocales, NULL, status))) { + while((l=uenum_next(availableLocales, NULL, status)) != NULL) { #if defined(ULOC_DEBUG) fprintf(stderr," %s\n", l); #endif diff --git a/icu4c/source/common/uloc_tag.cpp b/icu4c/source/common/uloc_tag.cpp index dcd72716539..87b9f63f279 100644 --- a/icu4c/source/common/uloc_tag.cpp +++ b/icu4c/source/common/uloc_tag.cpp @@ -1022,7 +1022,7 @@ _appendKeywordsToLanguageTag(const char* localeID, char* appendAt, int32_t capac no known mapping. This implementation normalizes the the value to lower case */ - int32_t bcpValueLen = uprv_strlen(bcpValue); + int32_t bcpValueLen = static_cast(uprv_strlen(bcpValue)); if (bcpValueLen < extBufCapacity) { uprv_strcpy(pExtBuf, bcpValue); T_CString_toLowerCase(pExtBuf); @@ -1288,7 +1288,7 @@ _appendLDMLExtensionAsKeywords(const char* ldmlext, ExtensionListEntry** appendT bufIdx++; } - len = uprv_strlen(attr->attribute); + len = static_cast(uprv_strlen(attr->attribute)); uprv_memcpy(buf + bufIdx, attr->attribute, len); bufIdx += len; @@ -1841,7 +1841,7 @@ ultag_parse(const char* tag, int32_t tagLen, int32_t* parsedLen, UErrorCode* sta int32_t newTagLength; grandfatheredLen = tagLen; /* back up for output parsedLen */ - newTagLength = uprv_strlen(GRANDFATHERED[i+1]); + newTagLength = static_cast(uprv_strlen(GRANDFATHERED[i+1])); if (tagLen < newTagLength) { uprv_free(tagBuf); tagBuf = (char*)uprv_malloc(newTagLength + 1); diff --git a/icu4c/source/common/umapfile.cpp b/icu4c/source/common/umapfile.cpp index df588a4f950..53699e762b2 100644 --- a/icu4c/source/common/umapfile.cpp +++ b/icu4c/source/common/umapfile.cpp @@ -102,10 +102,7 @@ { HANDLE map; HANDLE file; - SECURITY_ATTRIBUTES mappingAttributes; - SECURITY_ATTRIBUTES *mappingAttributesPtr = NULL; - SECURITY_DESCRIPTOR securityDesc; - + UDataMemory_init(pData); /* Clear the output struct. */ /* open the input file */ @@ -143,6 +140,11 @@ This is required for multiuser systems on Windows 2000 SP4 and beyond */ // TODO: UWP does not have this function and I do not think it is required? #if U_PLATFORM_HAS_WINUWP_API == 0 + + SECURITY_ATTRIBUTES mappingAttributes; + SECURITY_ATTRIBUTES *mappingAttributesPtr = NULL; + SECURITY_DESCRIPTOR securityDesc; + if (InitializeSecurityDescriptor(&securityDesc, SECURITY_DESCRIPTOR_REVISION)) { /* give the security descriptor a Null Dacl done using the "TRUE, (PACL)NULL" here */ if (SetSecurityDescriptorDacl(&securityDesc, TRUE, (PACL)NULL, FALSE)) { diff --git a/icu4c/source/common/umutex.cpp b/icu4c/source/common/umutex.cpp index 77c17782677..29dbc90ec98 100644 --- a/icu4c/source/common/umutex.cpp +++ b/icu4c/source/common/umutex.cpp @@ -132,7 +132,7 @@ umtx_condBroadcast(UConditionVar *condition) { } U_CAPI void U_EXPORT2 -umtx_condSignal(UConditionVar *condition) { +umtx_condSignal(UConditionVar * /* condition */) { // Function not implemented. There is no immediate requirement from ICU to have it. // Once ICU drops support for Windows XP and Server 2003, ICU Condition Variables will be // changed to be thin wrappers on native Windows CONDITION_VARIABLEs, and this function diff --git a/icu4c/source/common/unifiedcache.h b/icu4c/source/common/unifiedcache.h index 97da7ff5f77..957c0dbd73b 100644 --- a/icu4c/source/common/unifiedcache.h +++ b/icu4c/source/common/unifiedcache.h @@ -107,7 +107,7 @@ class CacheKey : public CacheKeyBase { */ virtual int32_t hashCode() const { const char *s = typeid(T).name(); - return ustr_hashCharsN(s, uprv_strlen(s)); + return ustr_hashCharsN(s, static_cast(uprv_strlen(s))); } /** diff --git a/icu4c/source/common/ustrtrns.cpp b/icu4c/source/common/ustrtrns.cpp index a4682870442..09eca22fda3 100644 --- a/icu4c/source/common/ustrtrns.cpp +++ b/icu4c/source/common/ustrtrns.cpp @@ -1312,7 +1312,7 @@ u_strFromJavaModifiedUTF8WithSub( u_terminateUChars(dest, destCapacity, reqLength, pErrorCode); return dest; } - srcLength = uprv_strlen((const char *)pSrc); + srcLength = static_cast(uprv_strlen((const char *)pSrc)); } /* Faster loop without ongoing checking for pSrcLimit and pDestLimit. */ diff --git a/icu4c/source/common/uts46.cpp b/icu4c/source/common/uts46.cpp index 98a9cf627e0..9b8d3ded2fd 100644 --- a/icu4c/source/common/uts46.cpp +++ b/icu4c/source/common/uts46.cpp @@ -1415,7 +1415,7 @@ uidna_labelToASCII_UTF8(const UIDNA *idna, if(!checkArgs(label, length, dest, capacity, pInfo, pErrorCode)) { return 0; } - StringPiece src(label, length<0 ? uprv_strlen(label) : length); + StringPiece src(label, length<0 ? static_cast(uprv_strlen(label)) : length); CheckedArrayByteSink sink(dest, capacity); IDNAInfo info; reinterpret_cast(idna)->labelToASCII_UTF8(src, sink, info, *pErrorCode); @@ -1431,7 +1431,7 @@ uidna_labelToUnicodeUTF8(const UIDNA *idna, if(!checkArgs(label, length, dest, capacity, pInfo, pErrorCode)) { return 0; } - StringPiece src(label, length<0 ? uprv_strlen(label) : length); + StringPiece src(label, length<0 ? static_cast(uprv_strlen(label)) : length); CheckedArrayByteSink sink(dest, capacity); IDNAInfo info; reinterpret_cast(idna)->labelToUnicodeUTF8(src, sink, info, *pErrorCode); @@ -1447,7 +1447,7 @@ uidna_nameToASCII_UTF8(const UIDNA *idna, if(!checkArgs(name, length, dest, capacity, pInfo, pErrorCode)) { return 0; } - StringPiece src(name, length<0 ? uprv_strlen(name) : length); + StringPiece src(name, length<0 ? static_cast(uprv_strlen(name)) : length); CheckedArrayByteSink sink(dest, capacity); IDNAInfo info; reinterpret_cast(idna)->nameToASCII_UTF8(src, sink, info, *pErrorCode); @@ -1463,7 +1463,7 @@ uidna_nameToUnicodeUTF8(const UIDNA *idna, if(!checkArgs(name, length, dest, capacity, pInfo, pErrorCode)) { return 0; } - StringPiece src(name, length<0 ? uprv_strlen(name) : length); + StringPiece src(name, length<0 ? static_cast(uprv_strlen(name)) : length); CheckedArrayByteSink sink(dest, capacity); IDNAInfo info; reinterpret_cast(idna)->nameToUnicodeUTF8(src, sink, info, *pErrorCode); diff --git a/icu4c/source/i18n/plurrule.cpp b/icu4c/source/i18n/plurrule.cpp index c4155cb4732..013d3fcac35 100644 --- a/icu4c/source/i18n/plurrule.cpp +++ b/icu4c/source/i18n/plurrule.cpp @@ -1665,7 +1665,7 @@ const char *PluralAvailableLocalesEnumeration::next(int32_t *resultLength, UErro } const char *result = ures_getKey(fRes); if (resultLength != NULL) { - *resultLength = uprv_strlen(result); + *resultLength = static_cast(uprv_strlen(result)); } return result; } diff --git a/icu4c/source/i18n/tzfmt.cpp b/icu4c/source/i18n/tzfmt.cpp index 7f26d196b7e..383fb514835 100644 --- a/icu4c/source/i18n/tzfmt.cpp +++ b/icu4c/source/i18n/tzfmt.cpp @@ -320,7 +320,7 @@ TimeZoneFormat::TimeZoneFormat(const Locale& locale, UErrorCode& status) } const char* region = fLocale.getCountry(); - int32_t regionLen = uprv_strlen(region); + int32_t regionLen = static_cast(uprv_strlen(region)); if (regionLen == 0) { char loc[ULOC_FULLNAME_CAPACITY]; uloc_addLikelySubtags(fLocale.getName(), loc, sizeof(loc), &status); @@ -1812,7 +1812,9 @@ TimeZoneFormat::parseOffsetFields(const UnicodeString& text, int32_t start, UBoo // but it should be parsed as 00:10:20. int32_t tmpLen = 0; int32_t tmpSign = 1; - int32_t tmpH, tmpM, tmpS; + int32_t tmpH = 0; + int32_t tmpM = 0; + int32_t tmpS = 0; for (int32_t patidx = 0; PARSE_GMT_OFFSET_TYPES[patidx] >= 0; patidx++) { int32_t gmtPatType = PARSE_GMT_OFFSET_TYPES[patidx]; @@ -2752,7 +2754,7 @@ static void U_CALLCONV initZoneIdTrie(UErrorCode &status) { } StringEnumeration *tzenum = TimeZone::createEnumeration(); const UnicodeString *id; - while ((id = tzenum->snext(status))) { + while ((id = tzenum->snext(status)) != NULL) { const UChar* uid = ZoneMeta::findTimeZoneID(*id); if (uid) { gZoneIdTrie->put(uid, const_cast(uid), status); @@ -2799,7 +2801,7 @@ static void U_CALLCONV initShortZoneIdTrie(UErrorCode &status) { status = U_MEMORY_ALLOCATION_ERROR; } else { const UnicodeString *id; - while ((id = tzenum->snext(status))) { + while ((id = tzenum->snext(status)) != NULL) { const UChar* uID = ZoneMeta::findTimeZoneID(*id); const UChar* shortID = ZoneMeta::getShortID(*id); if (shortID && uID) { diff --git a/icu4c/source/i18n/tzgnames.cpp b/icu4c/source/i18n/tzgnames.cpp index b14e9835d9a..236ec760ed6 100644 --- a/icu4c/source/i18n/tzgnames.cpp +++ b/icu4c/source/i18n/tzgnames.cpp @@ -856,7 +856,7 @@ TZGNCore::loadStrings(const UnicodeString& tzCanonicalID) { }; StringEnumeration *mzIDs = fTimeZoneNames->getAvailableMetaZoneIDs(tzCanonicalID, status); - while ((mzID = mzIDs->snext(status))) { + while ((mzID = mzIDs->snext(status)) != NULL) { if (U_FAILURE(status)) { break; } @@ -1044,7 +1044,7 @@ TZGNCore::findLocal(const UnicodeString& text, int32_t start, uint32_t types, UE StringEnumeration *tzIDs = TimeZone::createTimeZoneIDEnumeration(UCAL_ZONE_TYPE_CANONICAL, NULL, NULL, status); if (U_SUCCESS(status)) { const UnicodeString *tzID; - while ((tzID = tzIDs->snext(status))) { + while ((tzID = tzIDs->snext(status)) != NULL) { if (U_FAILURE(status)) { break; } @@ -1164,7 +1164,7 @@ static void sweepCache() { const UHashElement* elem; double now = (double)uprv_getUTCtime(); - while ((elem = uhash_nextElement(gTZGNCoreCache, &pos))) { + while ((elem = uhash_nextElement(gTZGNCoreCache, &pos)) != NULL) { TZGNCoreRef *entry = (TZGNCoreRef *)elem->value.pointer; if (entry->refCount <= 0 && (now - entry->lastAccess) > CACHE_EXPIRATION) { // delete this entry diff --git a/icu4c/source/i18n/tznames_impl.cpp b/icu4c/source/i18n/tznames_impl.cpp index 6817a88af8f..8accb84d2d5 100644 --- a/icu4c/source/i18n/tznames_impl.cpp +++ b/icu4c/source/i18n/tznames_impl.cpp @@ -1070,7 +1070,7 @@ TimeZoneNamesImpl::loadStrings(const UnicodeString& tzCanonicalID, UErrorCode& s U_ASSERT(!mzIDs.isNull()); const UnicodeString *mzID; - while ((mzID = mzIDs->snext(status)) && U_SUCCESS(status)) { + while (((mzID = mzIDs->snext(status)) != NULL) && U_SUCCESS(status)) { loadMetaZoneNames(*mzID, status); } } @@ -1651,7 +1651,7 @@ void TimeZoneNamesImpl::internalLoadAllDisplayNames(UErrorCode& status) { StringEnumeration *tzIDs = TimeZone::createTimeZoneIDEnumeration( UCAL_ZONE_TYPE_CANONICAL, NULL, NULL, status); if (U_SUCCESS(status)) { - while ((id = tzIDs->snext(status))) { + while ((id = tzIDs->snext(status)) != NULL) { if (U_FAILURE(status)) { break; } diff --git a/icu4c/source/i18n/ucol_res.cpp b/icu4c/source/i18n/ucol_res.cpp index d1597021c3e..1c70bbfd5ab 100644 --- a/icu4c/source/i18n/ucol_res.cpp +++ b/icu4c/source/i18n/ucol_res.cpp @@ -110,7 +110,7 @@ CollationLoader::loadRules(const char *localeID, const char *collationType, U_ASSERT(collationType != NULL && *collationType != 0); // Copy the type for lowercasing. char type[16]; - int32_t typeLength = uprv_strlen(collationType); + int32_t typeLength = static_cast(uprv_strlen(collationType)); if(typeLength >= UPRV_LENGTHOF(type)) { errorCode = U_ILLEGAL_ARGUMENT_ERROR; return; @@ -318,7 +318,7 @@ CollationLoader::loadFromCollations(UErrorCode &errorCode) { // Load the collations/type tailoring, with type fallback. LocalUResourceBundlePointer localData( ures_getByKeyWithFallback(collations, type, NULL, &errorCode)); - int32_t typeLength = uprv_strlen(type); + int32_t typeLength = static_cast(uprv_strlen(type)); if(errorCode == U_MISSING_RESOURCE_ERROR) { errorCode = U_USING_DEFAULT_WARNING; typeFallback = TRUE; diff --git a/icu4c/source/i18n/unum.cpp b/icu4c/source/i18n/unum.cpp index b8d26612ff2..11c2f8c8337 100644 --- a/icu4c/source/i18n/unum.cpp +++ b/icu4c/source/i18n/unum.cpp @@ -298,7 +298,7 @@ unum_formatDecimal(const UNumberFormat* fmt, } if (length < 0) { - length = uprv_strlen(number); + length = static_cast(uprv_strlen(number)); } StringPiece numSP(number, length); Formattable numFmtbl(numSP, *status); diff --git a/icu4c/source/i18n/uspoof.cpp b/icu4c/source/i18n/uspoof.cpp index 92b3b0c13ca..515bdce2a05 100644 --- a/icu4c/source/i18n/uspoof.cpp +++ b/icu4c/source/i18n/uspoof.cpp @@ -374,7 +374,7 @@ uspoof_check2UTF8(const USpoofChecker *sc, if (U_FAILURE(*status)) { return 0; } - UnicodeString idStr = UnicodeString::fromUTF8(StringPiece(id, length>=0 ? length : uprv_strlen(id))); + UnicodeString idStr = UnicodeString::fromUTF8(StringPiece(id, length>=0 ? length : static_cast(uprv_strlen(id)))); int32_t result = uspoof_check2UnicodeString(sc, idStr, checkResult, status); return result; } @@ -413,8 +413,8 @@ uspoof_areConfusableUTF8(const USpoofChecker *sc, *status = U_ILLEGAL_ARGUMENT_ERROR; return 0; } - UnicodeString id1Str = UnicodeString::fromUTF8(StringPiece(id1, length1>=0? length1 : uprv_strlen(id1))); - UnicodeString id2Str = UnicodeString::fromUTF8(StringPiece(id2, length2>=0? length2 : uprv_strlen(id2))); + UnicodeString id1Str = UnicodeString::fromUTF8(StringPiece(id1, length1>=0? length1 : static_cast(uprv_strlen(id1)))); + UnicodeString id2Str = UnicodeString::fromUTF8(StringPiece(id2, length2>=0? length2 : static_cast(uprv_strlen(id2)))); int32_t results = uspoof_areConfusableUnicodeString(sc, id1Str, id2Str, status); return results; } @@ -680,7 +680,7 @@ uspoof_getSkeletonUTF8(const USpoofChecker *sc, return 0; } - UnicodeString srcStr = UnicodeString::fromUTF8(StringPiece(id, length>=0 ? length : uprv_strlen(id))); + UnicodeString srcStr = UnicodeString::fromUTF8(StringPiece(id, length>=0 ? length : static_cast(uprv_strlen(id)))); UnicodeString destStr; uspoof_getSkeletonUnicodeString(sc, type, srcStr, destStr, status); if (U_FAILURE(*status)) { diff --git a/icu4c/source/i18n/windtfmt.cpp b/icu4c/source/i18n/windtfmt.cpp index be5f384c2c6..253e919def9 100644 --- a/icu4c/source/i18n/windtfmt.cpp +++ b/icu4c/source/i18n/windtfmt.cpp @@ -102,7 +102,7 @@ static UErrorCode GetEquivalentWindowsLocaleName(const Locale& locale, UnicodeSt char asciiBCP47Tag[LOCALE_NAME_MAX_LENGTH] = {}; // Convert from names like "en_CA" and "de_DE@collation=phonebook" to "en-CA" and "de-DE-u-co-phonebk". - int32_t length = uloc_toLanguageTag(locale.getName(), asciiBCP47Tag, UPRV_LENGTHOF(asciiBCP47Tag), FALSE, &status); + (void)uloc_toLanguageTag(locale.getName(), asciiBCP47Tag, UPRV_LENGTHOF(asciiBCP47Tag), FALSE, &status); if (U_SUCCESS(status)) { @@ -219,7 +219,7 @@ Format *Win32DateFormat::clone(void) const } // TODO: Is just ignoring pos the right thing? -UnicodeString &Win32DateFormat::format(Calendar &cal, UnicodeString &appendTo, FieldPosition &pos) const +UnicodeString &Win32DateFormat::format(Calendar &cal, UnicodeString &appendTo, FieldPosition & /* pos */) const { FILETIME ft; SYSTEMTIME st_gmt; @@ -263,7 +263,7 @@ UnicodeString &Win32DateFormat::format(Calendar &cal, UnicodeString &appendTo, F return appendTo; } -void Win32DateFormat::parse(const UnicodeString& text, Calendar& cal, ParsePosition& pos) const +void Win32DateFormat::parse(const UnicodeString& /* text */, Calendar& /* cal */, ParsePosition& pos) const { pos.setErrorIndex(pos.getIndex()); } diff --git a/icu4c/source/i18n/winnmfmt.cpp b/icu4c/source/i18n/winnmfmt.cpp index 3e03cb1feef..5637a0f4a13 100644 --- a/icu4c/source/i18n/winnmfmt.cpp +++ b/icu4c/source/i18n/winnmfmt.cpp @@ -147,7 +147,7 @@ static UErrorCode GetEquivalentWindowsLocaleName(const Locale& locale, UnicodeSt char asciiBCP47Tag[LOCALE_NAME_MAX_LENGTH] = {}; // Convert from names like "en_CA" and "de_DE@collation=phonebook" to "en-CA" and "de-DE-u-co-phonebk". - int32_t length = uloc_toLanguageTag(locale.getName(), asciiBCP47Tag, UPRV_LENGTHOF(asciiBCP47Tag), FALSE, &status); + (void) uloc_toLanguageTag(locale.getName(), asciiBCP47Tag, UPRV_LENGTHOF(asciiBCP47Tag), FALSE, &status); if (U_SUCCESS(status)) { @@ -299,17 +299,17 @@ Format *Win32NumberFormat::clone(void) const return new Win32NumberFormat(*this); } -UnicodeString& Win32NumberFormat::format(double number, UnicodeString& appendTo, FieldPosition& pos) const +UnicodeString& Win32NumberFormat::format(double number, UnicodeString& appendTo, FieldPosition& /* pos */) const { return format(getMaximumFractionDigits(), appendTo, L"%.16f", number); } -UnicodeString& Win32NumberFormat::format(int32_t number, UnicodeString& appendTo, FieldPosition& pos) const +UnicodeString& Win32NumberFormat::format(int32_t number, UnicodeString& appendTo, FieldPosition& /* pos */) const { return format(getMinimumFractionDigits(), appendTo, L"%I32d", number); } -UnicodeString& Win32NumberFormat::format(int64_t number, UnicodeString& appendTo, FieldPosition& pos) const +UnicodeString& Win32NumberFormat::format(int64_t number, UnicodeString& appendTo, FieldPosition& /* pos */) const { return format(getMinimumFractionDigits(), appendTo, L"%I64d", number); } diff --git a/icu4c/source/i18n/wintzimpl.cpp b/icu4c/source/i18n/wintzimpl.cpp index 7a87d1c4f59..433ed4c2939 100644 --- a/icu4c/source/i18n/wintzimpl.cpp +++ b/icu4c/source/i18n/wintzimpl.cpp @@ -65,12 +65,12 @@ static UBool getSystemTimeInformation(TimeZone *tz, SYSTEMTIME &daylightDate, SY // Always use DOW type rule int32_t hour, min, sec, mil; standardDate.wYear = 0; - standardDate.wMonth = std->getRule()->getRuleMonth() + 1; - standardDate.wDay = std->getRule()->getRuleWeekInMonth(); + standardDate.wMonth = static_cast(std->getRule()->getRuleMonth()) + 1; + standardDate.wDay = static_cast(std->getRule()->getRuleWeekInMonth()); if (standardDate.wDay < 0) { standardDate.wDay = 5; } - standardDate.wDayOfWeek = std->getRule()->getRuleDayOfWeek() - 1; + standardDate.wDayOfWeek = static_cast(std->getRule()->getRuleDayOfWeek()) - 1; mil = std->getRule()->getRuleMillisInDay(); hour = mil/3600000; @@ -80,18 +80,18 @@ static UBool getSystemTimeInformation(TimeZone *tz, SYSTEMTIME &daylightDate, SY sec = mil/1000; mil %= 1000; - standardDate.wHour = hour; - standardDate.wMinute = min; - standardDate.wSecond = sec; - standardDate.wMilliseconds = mil; + standardDate.wHour = static_cast(hour); + standardDate.wMinute = static_cast(min); + standardDate.wSecond = static_cast(sec); + standardDate.wMilliseconds = static_cast(mil); daylightDate.wYear = 0; - daylightDate.wMonth = dst->getRule()->getRuleMonth() + 1; - daylightDate.wDay = dst->getRule()->getRuleWeekInMonth(); + daylightDate.wMonth = static_cast(dst->getRule()->getRuleMonth()) + 1; + daylightDate.wDay = static_cast(dst->getRule()->getRuleWeekInMonth()); if (daylightDate.wDay < 0) { daylightDate.wDay = 5; } - daylightDate.wDayOfWeek = dst->getRule()->getRuleDayOfWeek() - 1; + daylightDate.wDayOfWeek = static_cast(dst->getRule()->getRuleDayOfWeek()) - 1; mil = dst->getRule()->getRuleMillisInDay(); hour = mil/3600000; @@ -101,10 +101,10 @@ static UBool getSystemTimeInformation(TimeZone *tz, SYSTEMTIME &daylightDate, SY sec = mil/1000; mil %= 1000; - daylightDate.wHour = hour; - daylightDate.wMinute = min; - daylightDate.wSecond = sec; - daylightDate.wMilliseconds = mil; + daylightDate.wHour = static_cast(hour); + daylightDate.wMinute = static_cast(min); + daylightDate.wSecond = static_cast(sec); + daylightDate.wMilliseconds = static_cast(mil); } } else { result = FALSE; diff --git a/icu4c/source/i18n/zonemeta.cpp b/icu4c/source/i18n/zonemeta.cpp index 84a96578029..b26798f990a 100644 --- a/icu4c/source/i18n/zonemeta.cpp +++ b/icu4c/source/i18n/zonemeta.cpp @@ -792,7 +792,7 @@ static void U_CALLCONV initAvailableMetaZoneIDs () { break; } const char *mzID = ures_getKey(&res); - int32_t len = uprv_strlen(mzID); + int32_t len = static_cast(uprv_strlen(mzID)); UChar *uMzID = (UChar*)uprv_malloc(sizeof(UChar) * (len + 1)); if (uMzID == NULL) { status = U_MEMORY_ALLOCATION_ERROR; -- 2.40.0