From 0bf8a95309992b7cb940fdf0629d3d58e3104861 Mon Sep 17 00:00:00 2001 From: Fredrik Roubert Date: Wed, 18 Sep 2024 20:42:13 +0200 Subject: [PATCH] ICU-22793 Remove superfluous return value typecasts to UBool. --- icu4c/source/common/bmpset.cpp | 4 +- icu4c/source/common/bmpset.h | 2 +- icu4c/source/common/normalizer2impl.h | 2 +- icu4c/source/common/patternprops.cpp | 10 +-- icu4c/source/common/putil.cpp | 12 ++-- icu4c/source/common/ubidi_props.cpp | 6 +- icu4c/source/common/ucase.cpp | 10 +-- icu4c/source/common/uchar.cpp | 63 +++++++++---------- icu4c/source/common/uchriter.cpp | 4 +- icu4c/source/common/ucnv.cpp | 2 +- icu4c/source/common/ucnv_bld.cpp | 4 +- icu4c/source/common/ucnv_io.cpp | 6 +- icu4c/source/common/ucnv_u8.cpp | 2 +- icu4c/source/common/ucnvisci.cpp | 4 +- icu4c/source/common/ucnvmbcs.cpp | 2 +- icu4c/source/common/ucnvscsu.cpp | 4 +- icu4c/source/common/uhash.cpp | 8 +-- icu4c/source/common/unames.cpp | 6 +- icu4c/source/common/unicode/uniset.h | 4 +- icu4c/source/common/unicode/unistr.h | 8 +-- icu4c/source/common/unicode/utypes.h | 4 +- icu4c/source/common/uniset.cpp | 6 +- icu4c/source/common/unisetspan.cpp | 2 +- icu4c/source/common/unisetspan.h | 4 +- icu4c/source/common/uprops.cpp | 8 +-- icu4c/source/common/uresbund.cpp | 5 +- icu4c/source/common/uresdata.cpp | 4 +- icu4c/source/common/uset.cpp | 4 +- icu4c/source/common/usprep.cpp | 3 +- icu4c/source/common/ustr_wcs.cpp | 2 +- icu4c/source/common/utrie.cpp | 2 +- icu4c/source/common/utrie2.cpp | 2 +- icu4c/source/common/utrie2_builder.cpp | 8 +-- icu4c/source/i18n/calendar.cpp | 2 +- icu4c/source/i18n/datefmt.cpp | 2 +- icu4c/source/i18n/dtptngen.cpp | 4 +- icu4c/source/i18n/tznames_impl.h | 2 +- icu4c/source/i18n/unicode/tblcoll.h | 2 +- icu4c/source/io/ufmt_cmn.cpp | 2 +- icu4c/source/test/cintltst/chashtst.c | 6 +- icu4c/source/test/cintltst/cintltst.c | 2 +- icu4c/source/test/cintltst/crestst.c | 2 +- icu4c/source/test/cintltst/creststn.c | 2 +- icu4c/source/test/intltest/nptrans.cpp | 2 +- icu4c/source/test/intltest/restest.cpp | 4 +- icu4c/source/test/intltest/restsnew.cpp | 2 +- icu4c/source/test/intltest/usettest.cpp | 2 +- .../test/perf/unisetperf/draft/bitset.cpp | 4 +- .../test/perf/unisetperf/draft/trieset.cpp | 4 +- icu4c/source/tools/genrb/parse.cpp | 2 +- icu4c/source/tools/gensprep/store.c | 2 +- icu4c/source/tools/icupkg/icupkg.cpp | 2 +- icu4c/source/tools/makeconv/genmbcs.cpp | 2 +- icu4c/source/tools/toolutil/package.cpp | 2 +- 54 files changed, 133 insertions(+), 138 deletions(-) diff --git a/icu4c/source/common/bmpset.cpp b/icu4c/source/common/bmpset.cpp index bab4cff41728..9b2a2967f0dd 100644 --- a/icu4c/source/common/bmpset.cpp +++ b/icu4c/source/common/bmpset.cpp @@ -293,14 +293,14 @@ BMPSet::contains(UChar32 c) const { if (static_cast(c) <= 0xff) { return latin1Contains[c]; } else if (static_cast(c) <= 0x7ff) { - return static_cast((table7FF[c & 0x3f] & (static_cast(1) << (c >> 6))) != 0); + return (table7FF[c & 0x3f] & (static_cast(1) << (c >> 6))) != 0; } else if (static_cast(c) < 0xd800 || (c >= 0xe000 && c <= 0xffff)) { int lead=c>>12; uint32_t twoBits=(bmpBlockBits[(c>>6)&0x3f]>>lead)&0x10001; if(twoBits<=1) { // All 64 code points with the same bits 15..6 // are either in the set or not. - return static_cast(twoBits); + return twoBits; } else { // Look up the code point in its 4k block of code points. return containsSlow(c, list4kStarts[lead], list4kStarts[lead+1]); diff --git a/icu4c/source/common/bmpset.h b/icu4c/source/common/bmpset.h index 440a7a81b087..00253f97c126 100644 --- a/icu4c/source/common/bmpset.h +++ b/icu4c/source/common/bmpset.h @@ -156,7 +156,7 @@ class BMPSet : public UMemory { }; inline UBool BMPSet::containsSlow(UChar32 c, int32_t lo, int32_t hi) const { - return static_cast(findCodePoint(c, lo, hi) & 1); + return findCodePoint(c, lo, hi) & 1; } U_NAMESPACE_END diff --git a/icu4c/source/common/normalizer2impl.h b/icu4c/source/common/normalizer2impl.h index 7bd733dee92e..5999190bae9b 100644 --- a/icu4c/source/common/normalizer2impl.h +++ b/icu4c/source/common/normalizer2impl.h @@ -364,7 +364,7 @@ class U_COMMON_API Normalizer2Impl : public UObject { // 0<=lead<=0xffff uint8_t bits=smallFCD[lead>>8]; if(bits==0) { return false; } - return static_cast((bits >> ((lead >> 5) & 7)) & 1); + return (bits >> ((lead >> 5) & 7)) & 1; } /** Returns the FCD value from the regular normalization data. */ uint16_t getFCD16FromNormData(UChar32 c) const; diff --git a/icu4c/source/common/patternprops.cpp b/icu4c/source/common/patternprops.cpp index 19998574cc55..782d3366f93d 100644 --- a/icu4c/source/common/patternprops.cpp +++ b/icu4c/source/common/patternprops.cpp @@ -120,12 +120,12 @@ PatternProps::isSyntax(UChar32 c) { if(c<0) { return false; } else if(c<=0xff) { - return static_cast(latin1[c] >> 1) & 1; + return (latin1[c] >> 1) & 1; } else if(c<0x2010) { return false; } else if(c<=0x3030) { uint32_t bits=syntax2000[index2000[(c-0x2000)>>5]]; - return static_cast((bits >> (c & 0x1f)) & 1); + return (bits >> (c & 0x1f)) & 1; } else if(0xfd3e<=c && c<=0xfe46) { return c<=0xfd3f || 0xfe45<=c; } else { @@ -138,12 +138,12 @@ PatternProps::isSyntaxOrWhiteSpace(UChar32 c) { if(c<0) { return false; } else if(c<=0xff) { - return static_cast(latin1[c] & 1); + return latin1[c] & 1; } else if(c<0x200e) { return false; } else if(c<=0x3030) { uint32_t bits=syntaxOrWhiteSpace2000[index2000[(c-0x2000)>>5]]; - return static_cast((bits >> (c & 0x1f)) & 1); + return (bits >> (c & 0x1f)) & 1; } else if(0xfd3e<=c && c<=0xfe46) { return c<=0xfd3f || 0xfe45<=c; } else { @@ -156,7 +156,7 @@ PatternProps::isWhiteSpace(UChar32 c) { if(c<0) { return false; } else if(c<=0xff) { - return static_cast(latin1[c] >> 2) & 1; + return (latin1[c] >> 2) & 1; } else if(0x200e<=c && c<=0x2029) { return c<=0x200f || 0x2028<=c; } else { diff --git a/icu4c/source/common/putil.cpp b/icu4c/source/common/putil.cpp index 718bbb3d371a..4cf07797ba35 100644 --- a/icu4c/source/common/putil.cpp +++ b/icu4c/source/common/putil.cpp @@ -342,7 +342,7 @@ uprv_isNaN(double number) BitPatternConversion convertedNumber; convertedNumber.d64 = number; /* Infinity is 0x7FF0000000000000U. Anything greater than that is a NaN */ - return (UBool)((convertedNumber.i64 & U_INT64_MAX) > gInf.i64); + return (convertedNumber.i64 & U_INT64_MAX) > gInf.i64; #elif U_PLATFORM == U_PF_OS390 uint32_t highBits = *(uint32_t*)u_topNBytesOfDouble(&number, @@ -368,7 +368,7 @@ uprv_isInfinite(double number) BitPatternConversion convertedNumber; convertedNumber.d64 = number; /* Infinity is exactly 0x7FF0000000000000U. */ - return (UBool)((convertedNumber.i64 & U_INT64_MAX) == gInf.i64); + return (convertedNumber.i64 & U_INT64_MAX) == gInf.i64; #elif U_PLATFORM == U_PF_OS390 uint32_t highBits = *(uint32_t*)u_topNBytesOfDouble(&number, sizeof(uint32_t)); @@ -389,7 +389,7 @@ U_CAPI UBool U_EXPORT2 uprv_isPositiveInfinity(double number) { #if IEEE_754 || U_PLATFORM == U_PF_OS390 - return (UBool)(number > 0 && uprv_isInfinite(number)); + return number > 0 && uprv_isInfinite(number); #else return uprv_isInfinite(number); #endif @@ -399,7 +399,7 @@ U_CAPI UBool U_EXPORT2 uprv_isNegativeInfinity(double number) { #if IEEE_754 || U_PLATFORM == U_PF_OS390 - return (UBool)(number < 0 && uprv_isInfinite(number)); + return number < 0 && uprv_isInfinite(number); #else uint32_t highBits = *(uint32_t*)u_topNBytesOfDouble(&number, @@ -744,11 +744,11 @@ static UBool isValidOlsonID(const char *id) { The timezone is sometimes set to "CST-7CDT", "CST6CDT5,J129,J131/19:30", "GRNLNDST3GRNLNDDT" or similar, so we cannot use it. The rest of the time it could be an Olson ID. George */ - return static_cast(id[idx] == 0 + return id[idx] == 0 || uprv_strcmp(id, "PST8PDT") == 0 || uprv_strcmp(id, "MST7MDT") == 0 || uprv_strcmp(id, "CST6CDT") == 0 - || uprv_strcmp(id, "EST5EDT") == 0); + || uprv_strcmp(id, "EST5EDT") == 0; } /* On some Unix-like OS, 'posix' subdirectory in diff --git a/icu4c/source/common/ubidi_props.cpp b/icu4c/source/common/ubidi_props.cpp index 80044cca5413..1ac4ab12a2c3 100644 --- a/icu4c/source/common/ubidi_props.cpp +++ b/icu4c/source/common/ubidi_props.cpp @@ -139,7 +139,7 @@ ubidi_getClass(UChar32 c) { U_CFUNC UBool ubidi_isMirrored(UChar32 c) { uint16_t props=UTRIE2_GET16(&ubidi_props_singleton.trie, c); - return (UBool)UBIDI_GET_FLAG(props, UBIDI_IS_MIRRORED_SHIFT); + return UBIDI_GET_FLAG(props, UBIDI_IS_MIRRORED_SHIFT); } static UChar32 @@ -183,13 +183,13 @@ ubidi_getMirror(UChar32 c) { U_CFUNC UBool ubidi_isBidiControl(UChar32 c) { uint16_t props=UTRIE2_GET16(&ubidi_props_singleton.trie, c); - return (UBool)UBIDI_GET_FLAG(props, UBIDI_BIDI_CONTROL_SHIFT); + return UBIDI_GET_FLAG(props, UBIDI_BIDI_CONTROL_SHIFT); } U_CFUNC UBool ubidi_isJoinControl(UChar32 c) { uint16_t props=UTRIE2_GET16(&ubidi_props_singleton.trie, c); - return (UBool)UBIDI_GET_FLAG(props, UBIDI_JOIN_CONTROL_SHIFT); + return UBIDI_GET_FLAG(props, UBIDI_JOIN_CONTROL_SHIFT); } U_CFUNC UJoiningType diff --git a/icu4c/source/common/ucase.cpp b/icu4c/source/common/ucase.cpp index 40b43cd89275..5a2feaee840b 100644 --- a/icu4c/source/common/ucase.cpp +++ b/icu4c/source/common/ucase.cpp @@ -696,17 +696,17 @@ getDotType(UChar32 c) { U_CAPI UBool U_EXPORT2 ucase_isSoftDotted(UChar32 c) { - return (UBool)(getDotType(c)==UCASE_SOFT_DOTTED); + return getDotType(c)==UCASE_SOFT_DOTTED; } U_CAPI UBool U_EXPORT2 ucase_isCaseSensitive(UChar32 c) { uint16_t props=UTRIE2_GET16(&ucase_props_singleton.trie, c); if(!UCASE_HAS_EXCEPTION(props)) { - return (UBool)((props&UCASE_SENSITIVE)!=0); + return (props&UCASE_SENSITIVE)!=0; } else { const uint16_t *pe=GET_EXCEPTIONS(&ucase_props_singleton, props); - return (UBool)((*pe&UCASE_EXC_SENSITIVE)!=0); + return (*pe&UCASE_EXC_SENSITIVE)!=0; } } @@ -1623,12 +1623,12 @@ ucase_toFullFolding(UChar32 c, U_CAPI UBool U_EXPORT2 u_isULowercase(UChar32 c) { - return (UBool)(UCASE_LOWER==ucase_getType(c)); + return UCASE_LOWER==ucase_getType(c); } U_CAPI UBool U_EXPORT2 u_isUUppercase(UChar32 c) { - return (UBool)(UCASE_UPPER==ucase_getType(c)); + return UCASE_UPPER==ucase_getType(c); } /* Transforms the Unicode character to its lower case equivalent.*/ diff --git a/icu4c/source/common/uchar.cpp b/icu4c/source/common/uchar.cpp index f22d861c96e9..3b2ae8c8af5d 100644 --- a/icu4c/source/common/uchar.cpp +++ b/icu4c/source/common/uchar.cpp @@ -91,7 +91,7 @@ U_CAPI UBool U_EXPORT2 u_islower(UChar32 c) { uint32_t props; GET_PROPS(c, props); - return (UBool)(GET_CATEGORY(props)==U_LOWERCASE_LETTER); + return GET_CATEGORY(props)==U_LOWERCASE_LETTER; } /* Checks if ch is an upper case letter.*/ @@ -99,7 +99,7 @@ U_CAPI UBool U_EXPORT2 u_isupper(UChar32 c) { uint32_t props; GET_PROPS(c, props); - return (UBool)(GET_CATEGORY(props)==U_UPPERCASE_LETTER); + return GET_CATEGORY(props)==U_UPPERCASE_LETTER; } /* Checks if ch is a title case letter; usually upper case letters.*/ @@ -107,7 +107,7 @@ U_CAPI UBool U_EXPORT2 u_istitle(UChar32 c) { uint32_t props; GET_PROPS(c, props); - return (UBool)(GET_CATEGORY(props)==U_TITLECASE_LETTER); + return GET_CATEGORY(props)==U_TITLECASE_LETTER; } /* Checks if ch is a decimal digit. */ @@ -115,7 +115,7 @@ U_CAPI UBool U_EXPORT2 u_isdigit(UChar32 c) { uint32_t props; GET_PROPS(c, props); - return (UBool)(GET_CATEGORY(props)==U_DECIMAL_DIGIT_NUMBER); + return GET_CATEGORY(props)==U_DECIMAL_DIGIT_NUMBER; } U_CAPI UBool U_EXPORT2 @@ -131,7 +131,7 @@ u_isxdigit(UChar32 c) { } GET_PROPS(c, props); - return (UBool)(GET_CATEGORY(props)==U_DECIMAL_DIGIT_NUMBER); + return GET_CATEGORY(props)==U_DECIMAL_DIGIT_NUMBER; } /* Checks if the Unicode character is a letter.*/ @@ -139,7 +139,7 @@ U_CAPI UBool U_EXPORT2 u_isalpha(UChar32 c) { uint32_t props; GET_PROPS(c, props); - return (UBool)((CAT_MASK(props)&U_GC_L_MASK)!=0); + return (CAT_MASK(props)&U_GC_L_MASK)!=0; } U_CAPI UBool U_EXPORT2 @@ -152,7 +152,7 @@ U_CAPI UBool U_EXPORT2 u_isalnum(UChar32 c) { uint32_t props; GET_PROPS(c, props); - return (UBool)((CAT_MASK(props)&(U_GC_L_MASK|U_GC_ND_MASK))!=0); + return (CAT_MASK(props)&(U_GC_L_MASK|U_GC_ND_MASK))!=0; } /** @@ -161,7 +161,7 @@ u_isalnum(UChar32 c) { */ U_CFUNC UBool u_isalnumPOSIX(UChar32 c) { - return (UBool)(u_isUAlphabetic(c) || u_isdigit(c)); + return u_isUAlphabetic(c) || u_isdigit(c); } /* Checks if ch is a unicode character with assigned character type.*/ @@ -169,7 +169,7 @@ U_CAPI UBool U_EXPORT2 u_isdefined(UChar32 c) { uint32_t props; GET_PROPS(c, props); - return (UBool)(GET_CATEGORY(props)!=0); + return GET_CATEGORY(props)!=0; } /* Checks if the Unicode character is a base form character that can take a diacritic.*/ @@ -177,7 +177,7 @@ U_CAPI UBool U_EXPORT2 u_isbase(UChar32 c) { uint32_t props; GET_PROPS(c, props); - return (UBool)((CAT_MASK(props)&(U_GC_L_MASK|U_GC_N_MASK|U_GC_MC_MASK|U_GC_ME_MASK))!=0); + return (CAT_MASK(props)&(U_GC_L_MASK|U_GC_N_MASK|U_GC_MC_MASK|U_GC_ME_MASK))!=0; } /* Checks if the Unicode character is a control character.*/ @@ -185,7 +185,7 @@ U_CAPI UBool U_EXPORT2 u_iscntrl(UChar32 c) { uint32_t props; GET_PROPS(c, props); - return (UBool)((CAT_MASK(props)&(U_GC_CC_MASK|U_GC_CF_MASK|U_GC_ZL_MASK|U_GC_ZP_MASK))!=0); + return (CAT_MASK(props)&(U_GC_CC_MASK|U_GC_CF_MASK|U_GC_ZL_MASK|U_GC_ZP_MASK))!=0; } U_CAPI UBool U_EXPORT2 @@ -206,14 +206,14 @@ U_CAPI UBool U_EXPORT2 u_isspace(UChar32 c) { uint32_t props; GET_PROPS(c, props); - return (UBool)((CAT_MASK(props)&U_GC_Z_MASK)!=0 || IS_THAT_CONTROL_SPACE(c)); + return (CAT_MASK(props)&U_GC_Z_MASK)!=0 || IS_THAT_CONTROL_SPACE(c); } U_CAPI UBool U_EXPORT2 u_isJavaSpaceChar(UChar32 c) { uint32_t props; GET_PROPS(c, props); - return (UBool)((CAT_MASK(props)&U_GC_Z_MASK)!=0); + return (CAT_MASK(props)&U_GC_Z_MASK)!=0; } /* Checks if the Unicode character is a whitespace character.*/ @@ -221,11 +221,9 @@ U_CAPI UBool U_EXPORT2 u_isWhitespace(UChar32 c) { uint32_t props; GET_PROPS(c, props); - return (UBool)( - ((CAT_MASK(props)&U_GC_Z_MASK)!=0 && - c!=NBSP && c!=FIGURESP && c!=NNBSP) || /* exclude no-break spaces */ - IS_THAT_ASCII_CONTROL_SPACE(c) - ); + return ((CAT_MASK(props)&U_GC_Z_MASK)!=0 && + c!=NBSP && c!=FIGURESP && c!=NNBSP) || /* exclude no-break spaces */ + IS_THAT_ASCII_CONTROL_SPACE(c); } U_CAPI UBool U_EXPORT2 @@ -236,7 +234,7 @@ u_isblank(UChar32 c) { /* Zs */ uint32_t props; GET_PROPS(c, props); - return (UBool)(GET_CATEGORY(props)==U_SPACE_SEPARATOR); + return GET_CATEGORY(props)==U_SPACE_SEPARATOR; } } @@ -251,7 +249,7 @@ u_isprint(UChar32 c) { uint32_t props; GET_PROPS(c, props); /* comparing ==0 returns false for the categories mentioned */ - return (UBool)((CAT_MASK(props)&U_GC_C_MASK)==0); + return (CAT_MASK(props)&U_GC_C_MASK)==0; } /** @@ -267,7 +265,7 @@ u_isprintPOSIX(UChar32 c) { * The only cntrl character in graph+blank is TAB (in blank). * Here we implement (blank-TAB)=Zs instead of calling u_isblank(). */ - return (UBool)((GET_CATEGORY(props)==U_SPACE_SEPARATOR) || u_isgraphPOSIX(c)); + return (GET_CATEGORY(props)==U_SPACE_SEPARATOR) || u_isgraphPOSIX(c); } U_CAPI UBool U_EXPORT2 @@ -275,9 +273,9 @@ u_isgraph(UChar32 c) { uint32_t props; GET_PROPS(c, props); /* comparing ==0 returns false for the categories mentioned */ - return (UBool)((CAT_MASK(props)& - (U_GC_CC_MASK|U_GC_CF_MASK|U_GC_CS_MASK|U_GC_CN_MASK|U_GC_Z_MASK)) - ==0); + return (CAT_MASK(props)& + (U_GC_CC_MASK|U_GC_CF_MASK|U_GC_CS_MASK|U_GC_CN_MASK|U_GC_Z_MASK)) + ==0; } /** @@ -293,16 +291,16 @@ u_isgraphPOSIX(UChar32 c) { GET_PROPS(c, props); /* \p{space}\p{gc=Control} == \p{gc=Z}\p{Control} */ /* comparing ==0 returns false for the categories mentioned */ - return (UBool)((CAT_MASK(props)& - (U_GC_CC_MASK|U_GC_CS_MASK|U_GC_CN_MASK|U_GC_Z_MASK)) - ==0); + return (CAT_MASK(props)& + (U_GC_CC_MASK|U_GC_CS_MASK|U_GC_CN_MASK|U_GC_Z_MASK)) + ==0; } U_CAPI UBool U_EXPORT2 u_ispunct(UChar32 c) { uint32_t props; GET_PROPS(c, props); - return (UBool)((CAT_MASK(props)&U_GC_P_MASK)!=0); + return (CAT_MASK(props)&U_GC_P_MASK)!=0; } /*Checks if the Unicode character can be ignorable in a Java or Unicode identifier.*/ @@ -313,7 +311,7 @@ u_isIDIgnorable(UChar32 c) { } else { uint32_t props; GET_PROPS(c, props); - return (UBool)(GET_CATEGORY(props)==U_FORMAT_CHAR); + return GET_CATEGORY(props)==U_FORMAT_CHAR; } } @@ -322,7 +320,7 @@ U_CAPI UBool U_EXPORT2 u_isJavaIDStart(UChar32 c) { uint32_t props; GET_PROPS(c, props); - return (UBool)((CAT_MASK(props)&(U_GC_L_MASK|U_GC_SC_MASK|U_GC_PC_MASK))!=0); + return (CAT_MASK(props)&(U_GC_L_MASK|U_GC_SC_MASK|U_GC_PC_MASK))!=0; } /*Checks if the Unicode character can be a Java identifier part other than starting the @@ -332,14 +330,13 @@ U_CAPI UBool U_EXPORT2 u_isJavaIDPart(UChar32 c) { uint32_t props; GET_PROPS(c, props); - return (UBool)( - (CAT_MASK(props)& + return (CAT_MASK(props)& (U_GC_ND_MASK|U_GC_NL_MASK| U_GC_L_MASK| U_GC_SC_MASK|U_GC_PC_MASK| U_GC_MC_MASK|U_GC_MN_MASK) )!=0 || - u_isIDIgnorable(c)); + u_isIDIgnorable(c); } U_CAPI int32_t U_EXPORT2 diff --git a/icu4c/source/common/uchriter.cpp b/icu4c/source/common/uchriter.cpp index b3402989011b..903eb46c3b34 100644 --- a/icu4c/source/common/uchriter.cpp +++ b/icu4c/source/common/uchriter.cpp @@ -172,7 +172,7 @@ UCharCharacterIterator::nextPostInc() { UBool UCharCharacterIterator::hasNext() { - return static_cast(pos < end); + return pos < end; } char16_t @@ -186,7 +186,7 @@ UCharCharacterIterator::previous() { UBool UCharCharacterIterator::hasPrevious() { - return static_cast(pos > begin); + return pos > begin; } UChar32 diff --git a/icu4c/source/common/ucnv.cpp b/icu4c/source/common/ucnv.cpp index 2ea88cca691a..c66200b79323 100644 --- a/icu4c/source/common/ucnv.cpp +++ b/icu4c/source/common/ucnv.cpp @@ -2684,7 +2684,7 @@ ucnv_fixFileSeparator(const UConverter *cnv, U_CAPI UBool U_EXPORT2 ucnv_isAmbiguous(const UConverter *cnv) { - return (UBool)(ucnv_getAmbiguous(cnv)!=nullptr); + return ucnv_getAmbiguous(cnv)!=nullptr; } U_CAPI void U_EXPORT2 diff --git a/icu4c/source/common/ucnv_bld.cpp b/icu4c/source/common/ucnv_bld.cpp index eb7ae1eaa9da..8dc166cd5b55 100644 --- a/icu4c/source/common/ucnv_bld.cpp +++ b/icu4c/source/common/ucnv_bld.cpp @@ -270,7 +270,7 @@ static UBool U_CALLCONV isCnvAcceptable(void * /*context*/, const char * /*type*/, const char * /*name*/, const UDataInfo *pInfo) { - return static_cast( + return pInfo->size>=20 && pInfo->isBigEndian==U_IS_BIG_ENDIAN && pInfo->charsetFamily==U_CHARSET_FAMILY && @@ -279,7 +279,7 @@ isCnvAcceptable(void * /*context*/, pInfo->dataFormat[1]==0x6e && pInfo->dataFormat[2]==0x76 && pInfo->dataFormat[3]==0x74 && - pInfo->formatVersion[0]==6); /* Everything will be version 6 */ + pInfo->formatVersion[0]==6; /* Everything will be version 6 */ } /** diff --git a/icu4c/source/common/ucnv_io.cpp b/icu4c/source/common/ucnv_io.cpp index abd19022ebb3..7207de397eb1 100644 --- a/icu4c/source/common/ucnv_io.cpp +++ b/icu4c/source/common/ucnv_io.cpp @@ -205,7 +205,7 @@ static UBool U_CALLCONV isAcceptable(void * /*context*/, const char * /*type*/, const char * /*name*/, const UDataInfo *pInfo) { - return static_cast( + return pInfo->size>=20 && pInfo->isBigEndian==U_IS_BIG_ENDIAN && pInfo->charsetFamily==U_CHARSET_FAMILY && @@ -213,7 +213,7 @@ isAcceptable(void * /*context*/, pInfo->dataFormat[1]==0x76 && pInfo->dataFormat[2]==0x41 && pInfo->dataFormat[3]==0x6c && - pInfo->formatVersion[0]==3); + pInfo->formatVersion[0]==3; } static UBool U_CALLCONV ucnv_io_cleanup() @@ -321,7 +321,7 @@ isAlias(const char *alias, UErrorCode *pErrorCode) { *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR; return false; } - return static_cast(*alias != 0); + return *alias != 0; } static uint32_t getTagNumber(const char *tagname) { diff --git a/icu4c/source/common/ucnv_u8.cpp b/icu4c/source/common/ucnv_u8.cpp index 18c57c61482a..cca6e603ae32 100644 --- a/icu4c/source/common/ucnv_u8.cpp +++ b/icu4c/source/common/ucnv_u8.cpp @@ -58,7 +58,7 @@ static UBool hasCESU8Data(const UConverter *cnv) #if UCONFIG_ONLY_HTML_CONVERSION return false; #else - return static_cast(cnv->sharedData == &_CESU8Data); + return cnv->sharedData == &_CESU8Data; #endif } U_CDECL_BEGIN diff --git a/icu4c/source/common/ucnvisci.cpp b/icu4c/source/common/ucnvisci.cpp index 9f3a8125e28d..c5f5832dcfcc 100644 --- a/icu4c/source/common/ucnvisci.cpp +++ b/icu4c/source/common/ucnvisci.cpp @@ -174,7 +174,7 @@ isPNJConsonant(UChar32 c) { if (c < 0xa00 || 0xa50 <= c) { return false; } else { - return static_cast(pnjMap[c - 0xa00] & 1); + return pnjMap[c - 0xa00] & 1; } } @@ -183,7 +183,7 @@ isPNJBindiTippi(UChar32 c) { if (c < 0xa00 || 0xa50 <= c) { return false; } else { - return static_cast(pnjMap[c - 0xa00] >> 1); + return pnjMap[c - 0xa00] >> 1; } } U_CDECL_BEGIN diff --git a/icu4c/source/common/ucnvmbcs.cpp b/icu4c/source/common/ucnvmbcs.cpp index 6b4d1491a2a6..e20dc984155a 100644 --- a/icu4c/source/common/ucnvmbcs.cpp +++ b/icu4c/source/common/ucnvmbcs.cpp @@ -5644,7 +5644,7 @@ ucnv_MBCSGetStarters(const UConverter* cnv, */ U_CFUNC UBool ucnv_MBCSIsLeadByte(UConverterSharedData *sharedData, char byte) { - return (UBool)MBCS_ENTRY_IS_TRANSITION(sharedData->mbcs.stateTable[0][(uint8_t)byte]); + return MBCS_ENTRY_IS_TRANSITION(sharedData->mbcs.stateTable[0][(uint8_t)byte]); } static void U_CALLCONV diff --git a/icu4c/source/common/ucnvscsu.cpp b/icu4c/source/common/ucnvscsu.cpp index 6dd1654636a1..5412136a346a 100644 --- a/icu4c/source/common/ucnvscsu.cpp +++ b/icu4c/source/common/ucnvscsu.cpp @@ -893,9 +893,9 @@ getWindow(const uint32_t offsets[8], uint32_t c) { /* is the character in the dynamic window starting at the offset, or in the direct-encoded range? */ static UBool isInOffsetWindowOrDirect(uint32_t offset, uint32_t c) { - return static_cast(c<=offset+0x7f && + return c<=offset+0x7f && (c>=offset || (c<=0x7f && - (c>=0x20 || (1UL<=0x20 || (1UL<( + return pInfo->size>=20 && pInfo->isBigEndian==U_IS_BIG_ENDIAN && pInfo->charsetFamily==U_CHARSET_FAMILY && @@ -188,7 +188,7 @@ isAcceptable(void * /*context*/, pInfo->dataFormat[1]==0x6e && pInfo->dataFormat[2]==0x61 && pInfo->dataFormat[3]==0x6d && - pInfo->formatVersion[0]==1); + pInfo->formatVersion[0]==1; } static void U_CALLCONV @@ -415,7 +415,7 @@ compareName(UCharNames *names, } /* complete match? */ - return static_cast(*otherName == 0); + return *otherName == 0; } static uint8_t getCharCat(UChar32 cp) { diff --git a/icu4c/source/common/unicode/uniset.h b/icu4c/source/common/unicode/uniset.h index c45f93d19674..d070fd631a22 100644 --- a/icu4c/source/common/unicode/uniset.h +++ b/icu4c/source/common/unicode/uniset.h @@ -1843,7 +1843,7 @@ inline bool UnicodeSet::operator!=(const UnicodeSet& o) const { } inline UBool UnicodeSet::isFrozen() const { - return static_cast(bmpSet != nullptr || stringSpan != nullptr); + return bmpSet != nullptr || stringSpan != nullptr; } inline UBool UnicodeSet::containsSome(UChar32 start, UChar32 end) const { @@ -1859,7 +1859,7 @@ inline UBool UnicodeSet::containsSome(const UnicodeString& s) const { } inline UBool UnicodeSet::isBogus() const { - return static_cast(fFlags & kIsBogus); + return fFlags & kIsBogus; } inline UnicodeSet *UnicodeSet::fromUSet(USet *uset) { diff --git a/icu4c/source/common/unicode/unistr.h b/icu4c/source/common/unicode/unistr.h index a65d467c07dc..a0a4f0021ff6 100644 --- a/icu4c/source/common/unicode/unistr.h +++ b/icu4c/source/common/unicode/unistr.h @@ -4227,18 +4227,18 @@ UnicodeString::hashCode() const inline UBool UnicodeString::isBogus() const -{ return static_cast(fUnion.fFields.fLengthAndFlags & kIsBogus); } +{ return fUnion.fFields.fLengthAndFlags & kIsBogus; } inline UBool UnicodeString::isWritable() const -{ return static_cast(!(fUnion.fFields.fLengthAndFlags & (kOpenGetBuffer | kIsBogus))); } +{ return !(fUnion.fFields.fLengthAndFlags & (kOpenGetBuffer | kIsBogus)); } inline UBool UnicodeString::isBufferWritable() const { - return static_cast( + return !(fUnion.fFields.fLengthAndFlags&(kOpenGetBuffer|kIsBogus|kBufferIsReadonly)) && - (!(fUnion.fFields.fLengthAndFlags&kRefCounted) || refCount()==1)); + (!(fUnion.fFields.fLengthAndFlags&kRefCounted) || refCount()==1); } inline const char16_t * diff --git a/icu4c/source/common/unicode/utypes.h b/icu4c/source/common/unicode/utypes.h index fcec29546af7..87fa5ddf7e87 100644 --- a/icu4c/source/common/unicode/utypes.h +++ b/icu4c/source/common/unicode/utypes.h @@ -729,13 +729,13 @@ typedef enum UErrorCode { * @stable ICU 2.0 */ static - inline UBool U_SUCCESS(UErrorCode code) { return static_cast(code <= U_ZERO_ERROR); } + inline UBool U_SUCCESS(UErrorCode code) { return code <= U_ZERO_ERROR; } /** * Does the error code indicate a failure? * @stable ICU 2.0 */ static - inline UBool U_FAILURE(UErrorCode code) { return static_cast(code > U_ZERO_ERROR); } + inline UBool U_FAILURE(UErrorCode code) { return code > U_ZERO_ERROR; } #else /** * Does the error code indicate success? diff --git a/icu4c/source/common/uniset.cpp b/icu4c/source/common/uniset.cpp index ef78ce33b195..2d6610cb355d 100644 --- a/icu4c/source/common/uniset.cpp +++ b/icu4c/source/common/uniset.cpp @@ -355,7 +355,7 @@ UBool UnicodeSet::contains(UChar32 c) const { return false; } int32_t i = findCodePoint(c); - return static_cast(i & 1); // return true if odd + return i & 1; // return true if odd } /** @@ -460,7 +460,7 @@ UBool UnicodeSet::containsAll(const UnicodeSet& c) const { * @return true if the test condition is met */ UBool UnicodeSet::containsAll(const UnicodeString& s) const { - return static_cast(span(s.getBuffer(), s.length(), USET_SPAN_CONTAINED) == s.length()); + return span(s.getBuffer(), s.length(), USET_SPAN_CONTAINED) == s.length(); } /** @@ -505,7 +505,7 @@ UBool UnicodeSet::containsNone(const UnicodeSet& c) const { * @return true if the test condition is met */ UBool UnicodeSet::containsNone(const UnicodeString& s) const { - return static_cast(span(s.getBuffer(), s.length(), USET_SPAN_NOT_CONTAINED) == s.length()); + return span(s.getBuffer(), s.length(), USET_SPAN_NOT_CONTAINED) == s.length(); } /** diff --git a/icu4c/source/common/unisetspan.cpp b/icu4c/source/common/unisetspan.cpp index dc4e89e5ca4a..209f0a86b541 100644 --- a/icu4c/source/common/unisetspan.cpp +++ b/icu4c/source/common/unisetspan.cpp @@ -84,7 +84,7 @@ class OffsetList { // Only ever stack-allocated, does not need to inherit UMemo } UBool isEmpty() const { - return static_cast(length == 0); + return length == 0; } // Reduce all stored offsets by delta, used when the current position diff --git a/icu4c/source/common/unisetspan.h b/icu4c/source/common/unisetspan.h index ecf8a9b00ffc..482782ebf75e 100644 --- a/icu4c/source/common/unisetspan.h +++ b/icu4c/source/common/unisetspan.h @@ -141,11 +141,11 @@ class UnicodeSetStringSpan : public UMemory { }; UBool UnicodeSetStringSpan::needsStringSpanUTF16() { - return static_cast(maxLength16 != 0); + return maxLength16 != 0; } UBool UnicodeSetStringSpan::needsStringSpanUTF8() { - return static_cast(maxLength8 != 0); + return maxLength8 != 0; } UBool UnicodeSetStringSpan::contains(UChar32 c) const { diff --git a/icu4c/source/common/uprops.cpp b/icu4c/source/common/uprops.cpp index 36aaba698d05..0f80d742d657 100644 --- a/icu4c/source/common/uprops.cpp +++ b/icu4c/source/common/uprops.cpp @@ -171,7 +171,7 @@ static UBool defaultContains(const BinaryProperty &prop, UChar32 c, UProperty /* } static UBool caseBinaryPropertyContains(const BinaryProperty &/*prop*/, UChar32 c, UProperty which) { - return static_cast(ucase_hasBinaryProperty(c, which)); + return ucase_hasBinaryProperty(c, which); } static UBool isBidiControl(const BinaryProperty &/*prop*/, UChar32 c, UProperty /*which*/) { @@ -242,7 +242,7 @@ static UBool changesWhenCasefolded(const BinaryProperty &/*prop*/, UChar32 c, UP if(c>=0) { /* single code point */ const char16_t *resultString; - return static_cast(ucase_toFullFolding(c, &resultString, U_FOLD_CASE_DEFAULT) >= 0); + return ucase_toFullFolding(c, &resultString, U_FOLD_CASE_DEFAULT) >= 0; } else { /* guess some large but stack-friendly capacity */ char16_t dest[2*UCASE_MAX_STRING_LENGTH]; @@ -250,9 +250,9 @@ static UBool changesWhenCasefolded(const BinaryProperty &/*prop*/, UChar32 c, UP destLength=u_strFoldCase(dest, UPRV_LENGTHOF(dest), nfd.getBuffer(), nfd.length(), U_FOLD_CASE_DEFAULT, &errorCode); - return static_cast(U_SUCCESS(errorCode) && + return U_SUCCESS(errorCode) && 0!=u_strCompare(nfd.getBuffer(), nfd.length(), - dest, destLength, false)); + dest, destLength, false); } } #endif diff --git a/icu4c/source/common/uresbund.cpp b/icu4c/source/common/uresbund.cpp index cfe2f4a4d20f..3a09cbf3bcaa 100644 --- a/icu4c/source/common/uresbund.cpp +++ b/icu4c/source/common/uresbund.cpp @@ -72,8 +72,7 @@ static UBool U_CALLCONV compareEntries(const UHashTok p1, const UHashTok p2) { name2.pointer = b2->fName; path1.pointer = b1->fPath; path2.pointer = b2->fPath; - return static_cast(uhash_compareChars(name1, name2) && - uhash_compareChars(path1, path2)); + return uhash_compareChars(name1, name2) && uhash_compareChars(path1, path2); } @@ -1730,7 +1729,7 @@ U_CAPI UBool U_EXPORT2 ures_hasNext(const UResourceBundle *resB) { if(resB == nullptr) { return false; } - return (UBool)(resB->fIndex < resB->fSize-1); + return resB->fIndex < resB->fSize-1; } U_CAPI const char16_t* U_EXPORT2 ures_getNextString(UResourceBundle *resB, int32_t* len, const char ** key, UErrorCode *status) { diff --git a/icu4c/source/common/uresdata.cpp b/icu4c/source/common/uresdata.cpp index 896e4ed1d6f1..11faddf1ade9 100644 --- a/icu4c/source/common/uresdata.cpp +++ b/icu4c/source/common/uresdata.cpp @@ -140,7 +140,7 @@ isAcceptable(void *context, const char * /*type*/, const char * /*name*/, const UDataInfo *pInfo) { uprv_memcpy(context, pInfo->formatVersion, 4); - return static_cast( + return pInfo->size>=20 && pInfo->isBigEndian==U_IS_BIG_ENDIAN && pInfo->charsetFamily==U_CHARSET_FAMILY && @@ -149,7 +149,7 @@ isAcceptable(void *context, pInfo->dataFormat[1]==0x65 && pInfo->dataFormat[2]==0x73 && pInfo->dataFormat[3]==0x42 && - (1<=pInfo->formatVersion[0] && pInfo->formatVersion[0]<=3)); + (1<=pInfo->formatVersion[0] && pInfo->formatVersion[0]<=3); } /* semi-public functions ---------------------------------------------------- */ diff --git a/icu4c/source/common/uset.cpp b/icu4c/source/common/uset.cpp index 8712da8b07fe..29b8655ac965 100644 --- a/icu4c/source/common/uset.cpp +++ b/icu4c/source/common/uset.cpp @@ -496,7 +496,7 @@ uset_serializedContains(const USerializedSet* set, UChar32 c) { } else { hi += 1; } - return (UBool)(hi&1); + return hi&1; } else { /* find c in the supplementary part */ uint16_t high=(uint16_t)(c>>16), low=(uint16_t)c; @@ -521,7 +521,7 @@ uset_serializedContains(const USerializedSet* set, UChar32 c) { hi += 2; } /* count pairs of 16-bit units even per BMP and check if the number of pairs is odd */ - return (UBool)(((hi+(base<<1))&2)!=0); + return ((hi+(base<<1))&2)!=0; } } diff --git a/icu4c/source/common/usprep.cpp b/icu4c/source/common/usprep.cpp index 82dd7a4ca0fd..477b8f2309db 100644 --- a/icu4c/source/common/usprep.cpp +++ b/icu4c/source/common/usprep.cpp @@ -126,8 +126,7 @@ compareEntries(const UHashTok p1, const UHashTok p2) { name2.pointer = b2->name; path1.pointer = b1->path; path2.pointer = b2->path; - return ((UBool)(uhash_compareChars(name1, name2) & - uhash_compareChars(path1, path2))); + return uhash_compareChars(name1, name2) & uhash_compareChars(path1, path2); } static void diff --git a/icu4c/source/common/ustr_wcs.cpp b/icu4c/source/common/ustr_wcs.cpp index efbbbc2f1878..8ce0855226d6 100644 --- a/icu4c/source/common/ustr_wcs.cpp +++ b/icu4c/source/common/ustr_wcs.cpp @@ -57,7 +57,7 @@ u_growAnyBufferFromStatic(void *context, } *pBuffer=newBuffer; - return (UBool)(newBuffer!=nullptr); + return newBuffer!=nullptr; } /* helper function */ diff --git a/icu4c/source/common/utrie.cpp b/icu4c/source/common/utrie.cpp index 88c01a53d2df..c27f447eddad 100644 --- a/icu4c/source/common/utrie.cpp +++ b/icu4c/source/common/utrie.cpp @@ -40,7 +40,7 @@ equal_uint32(const uint32_t *s, const uint32_t *t, int32_t length) { ++t; --length; } - return static_cast(length == 0); + return length == 0; } /* Building a trie ----------------------------------------------------------*/ diff --git a/icu4c/source/common/utrie2.cpp b/icu4c/source/common/utrie2.cpp index f8ed7cfc70fe..35be698fbb5d 100644 --- a/icu4c/source/common/utrie2.cpp +++ b/icu4c/source/common/utrie2.cpp @@ -389,7 +389,7 @@ utrie2_close(UTrie2 *trie) { U_CAPI UBool U_EXPORT2 utrie2_isFrozen(const UTrie2 *trie) { - return (UBool)(trie->newTrie==nullptr); + return trie->newTrie==nullptr; } U_CAPI int32_t U_EXPORT2 diff --git a/icu4c/source/common/utrie2_builder.cpp b/icu4c/source/common/utrie2_builder.cpp index 92e9fd733c4f..4bd49c7adfa4 100644 --- a/icu4c/source/common/utrie2_builder.cpp +++ b/icu4c/source/common/utrie2_builder.cpp @@ -506,7 +506,7 @@ isInNullBlock(UNewTrie2 *trie, UChar32 c, UBool forLSCP) { ((c>>UTRIE2_SHIFT_2)&UTRIE2_INDEX_2_MASK); } block=trie->index2[i2]; - return static_cast(block == trie->dataNullOffset); + return block == trie->dataNullOffset; } static int32_t @@ -603,7 +603,7 @@ releaseDataBlock(UNewTrie2 *trie, int32_t block) { static inline UBool isWritableBlock(UNewTrie2 *trie, int32_t block) { - return static_cast(block != trie->dataNullOffset && 1 == trie->map[block >> UTRIE2_SHIFT_2]); + return block != trie->dataNullOffset && 1 == trie->map[block >> UTRIE2_SHIFT_2]; } static inline void @@ -891,7 +891,7 @@ equal_int32(const int32_t *s, const int32_t *t, int32_t length) { ++t; --length; } - return static_cast(length == 0); + return length == 0; } static inline UBool @@ -901,7 +901,7 @@ equal_uint32(const uint32_t *s, const uint32_t *t, int32_t length) { ++t; --length; } - return static_cast(length == 0); + return length == 0; } static int32_t diff --git a/icu4c/source/i18n/calendar.cpp b/icu4c/source/i18n/calendar.cpp index f74446b43765..96247174f70d 100644 --- a/icu4c/source/i18n/calendar.cpp +++ b/icu4c/source/i18n/calendar.cpp @@ -2849,7 +2849,7 @@ Calendar::inDaylightTime(UErrorCode& status) const // Force an update of the state of the Calendar. const_cast(this)->complete(status); // cast away const - return static_cast(U_SUCCESS(status) ? internalGet(UCAL_DST_OFFSET) != 0 : false); + return U_SUCCESS(status) ? internalGet(UCAL_DST_OFFSET) != 0 : false; } bool diff --git a/icu4c/source/i18n/datefmt.cpp b/icu4c/source/i18n/datefmt.cpp index 80f74ede65df..655cfbd1239d 100644 --- a/icu4c/source/i18n/datefmt.cpp +++ b/icu4c/source/i18n/datefmt.cpp @@ -763,7 +763,7 @@ DateFormat::setBooleanAttribute(UDateFormatBooleanAttribute attr, UBool DateFormat::getBooleanAttribute(UDateFormatBooleanAttribute attr, UErrorCode &/*status*/) const { - return static_cast(fBoolFlags.get(attr)); + return fBoolFlags.get(attr); } U_NAMESPACE_END diff --git a/icu4c/source/i18n/dtptngen.cpp b/icu4c/source/i18n/dtptngen.cpp index 976e8d28b305..50c0b050b92e 100644 --- a/icu4c/source/i18n/dtptngen.cpp +++ b/icu4c/source/i18n/dtptngen.cpp @@ -1874,7 +1874,7 @@ DateTimePatternGenerator::setAvailableFormat(const UnicodeString &key, UErrorCod UBool DateTimePatternGenerator::isAvailableFormatSet(const UnicodeString &key) const { - return static_cast(fAvailableFormatKeyHash->geti(key) == 1); + return fAvailableFormatKeyHash->geti(key) == 1; } void @@ -2576,7 +2576,7 @@ FormatParser::getCanonicalIndex(const UnicodeString& s, UBool strict) { UBool FormatParser::isQuoteLiteral(const UnicodeString& s) { - return static_cast(s.charAt(0) == SINGLE_QUOTE); + return s.charAt(0) == SINGLE_QUOTE; } // This function assumes the current itemIndex points to the quote literal. diff --git a/icu4c/source/i18n/tznames_impl.h b/icu4c/source/i18n/tznames_impl.h index eb4748799e2e..c628cd72edab 100644 --- a/icu4c/source/i18n/tznames_impl.h +++ b/icu4c/source/i18n/tznames_impl.h @@ -99,7 +99,7 @@ struct CharacterNode { }; inline UBool CharacterNode::hasValues() const { - return static_cast(fValues != nullptr); + return fValues != nullptr; } inline int32_t CharacterNode::countValues() const { diff --git a/icu4c/source/i18n/unicode/tblcoll.h b/icu4c/source/i18n/unicode/tblcoll.h index 3843691ddf5f..0c65e897f501 100644 --- a/icu4c/source/i18n/unicode/tblcoll.h +++ b/icu4c/source/i18n/unicode/tblcoll.h @@ -850,7 +850,7 @@ class U_I18N_API RuleBasedCollator final : public Collator { } UBool attributeHasBeenSetExplicitly(int32_t attribute) const { // assert(0 <= attribute < ATTR_LIMIT); - return static_cast((explicitlySetAttributes & (static_cast(1) << attribute)) != 0); + return (explicitlySetAttributes & (static_cast(1) << attribute)) != 0; } /** diff --git a/icu4c/source/io/ufmt_cmn.cpp b/icu4c/source/io/ufmt_cmn.cpp index 0202783f8b5e..7930fe30beb6 100644 --- a/icu4c/source/io/ufmt_cmn.cpp +++ b/icu4c/source/io/ufmt_cmn.cpp @@ -58,7 +58,7 @@ ufmt_isdigit(char16_t c, { int digitVal = ufmt_digitvalue(c); - return static_cast(digitVal < radix && digitVal >= 0); + return digitVal < radix && digitVal >= 0; } #define TO_UC_DIGIT(a) a <= 9 ? (DIGIT_0 + a) : (0x0037 + a) diff --git a/icu4c/source/test/cintltst/chashtst.c b/icu4c/source/test/cintltst/chashtst.c index a4b774d93a1c..729b9b9c3ae0 100644 --- a/icu4c/source/test/cintltst/chashtst.c +++ b/icu4c/source/test/cintltst/chashtst.c @@ -379,9 +379,9 @@ static int32_t U_EXPORT2 U_CALLCONV hashChars(const UHashTok key) { } static UBool U_EXPORT2 U_CALLCONV isEqualChars(const UHashTok key1, const UHashTok key2) { - return (UBool)((key1.pointer != NULL) && - (key2.pointer != NULL) && - (uprv_strcmp((const char*)key1.pointer, (const char*)key2.pointer) == 0)); + return key1.pointer != NULL && + key2.pointer != NULL && + uprv_strcmp((const char*)key1.pointer, (const char*)key2.pointer) == 0; } /********************************************************************** diff --git a/icu4c/source/test/cintltst/cintltst.c b/icu4c/source/test/cintltst/cintltst.c index 4c6d5fc6dec7..5af75680138a 100644 --- a/icu4c/source/test/cintltst/cintltst.c +++ b/icu4c/source/test/cintltst/cintltst.c @@ -723,7 +723,7 @@ U_CFUNC UBool assertTrue(const char* msg, int /*not UBool*/ condition) { log_verbose("Ok: %s\n", msg); } #endif - return (UBool)condition; + return condition; } U_CFUNC UBool assertEquals(const char* message, const char* expected, diff --git a/icu4c/source/test/cintltst/crestst.c b/icu4c/source/test/cintltst/crestst.c index 7d0476462e66..f32dce366eac 100644 --- a/icu4c/source/test/cintltst/crestst.c +++ b/icu4c/source/test/cintltst/crestst.c @@ -428,7 +428,7 @@ UBool testTag(const char* frag, ures_close(theBundle); } free(base); - return (UBool)(passNum == pass); + return passNum == pass; } void record_pass(void) diff --git a/icu4c/source/test/cintltst/creststn.c b/icu4c/source/test/cintltst/creststn.c index 4877d8b49ccf..d5b0bb4febf8 100644 --- a/icu4c/source/test/cintltst/creststn.c +++ b/icu4c/source/test/cintltst/creststn.c @@ -2055,7 +2055,7 @@ static UBool testTag(const char* frag, ures_close(tags); ures_close(arrayItem1); free(base); - return (UBool)(failNum == fail); + return failNum == fail; } static void record_pass(void) diff --git a/icu4c/source/test/intltest/nptrans.cpp b/icu4c/source/test/intltest/nptrans.cpp index aebf18104924..879fdfa16af3 100644 --- a/icu4c/source/test/intltest/nptrans.cpp +++ b/icu4c/source/test/intltest/nptrans.cpp @@ -122,7 +122,7 @@ NamePrepTransform::NamePrepTransform(UParseError& parseError, UErrorCode& status UBool NamePrepTransform::isProhibited(UChar32 ch){ - return static_cast(ch != ASCII_SPACE); + return ch != ASCII_SPACE; } NamePrepTransform::~NamePrepTransform(){ diff --git a/icu4c/source/test/intltest/restest.cpp b/icu4c/source/test/intltest/restest.cpp index 381dfa25627a..661312ad5316 100644 --- a/icu4c/source/test/intltest/restest.cpp +++ b/icu4c/source/test/intltest/restest.cpp @@ -499,12 +499,12 @@ ResourceBundleTest::testTag(const char* frag, else if (status != expected_resource_status) { record_fail("Error getting " + UnicodeString(tag)); - return static_cast(failOrig != fail); + return failOrig != fail; } } - return static_cast(failOrig != fail); + return failOrig != fail; } void diff --git a/icu4c/source/test/intltest/restsnew.cpp b/icu4c/source/test/intltest/restsnew.cpp index 1bdfa2140781..a7bbf7717d9b 100644 --- a/icu4c/source/test/intltest/restsnew.cpp +++ b/icu4c/source/test/intltest/restsnew.cpp @@ -1051,7 +1051,7 @@ NewResourceBundleTest::testTag(const char* frag, CONFIRM_EQ(count, tag_count); } - return static_cast(failOrig == fail); + return failOrig == fail; } void diff --git a/icu4c/source/test/intltest/usettest.cpp b/icu4c/source/test/intltest/usettest.cpp index 18320f928fd7..b047b01bfa2d 100644 --- a/icu4c/source/test/intltest/usettest.cpp +++ b/icu4c/source/test/intltest/usettest.cpp @@ -2530,7 +2530,7 @@ class UnicodeSetWithStrings { } UBool hasStrings() const { - return static_cast(stringsLength > 0); + return stringsLength > 0; } UBool hasStringsWithSurrogates() const { diff --git a/icu4c/source/test/perf/unisetperf/draft/bitset.cpp b/icu4c/source/test/perf/unisetperf/draft/bitset.cpp index dc72cf4df237..d720b3827e4b 100644 --- a/icu4c/source/test/perf/unisetperf/draft/bitset.cpp +++ b/icu4c/source/test/perf/unisetperf/draft/bitset.cpp @@ -190,9 +190,9 @@ class BitSet : public UObject, public UnicodeContainable { UBool contains(UChar32 c) const override { if (static_cast(c) <= 0xff) { - return static_cast((latin1Set[c >> 5] & (static_cast(1) << (c & 0x1f))) != 0); + return (latin1Set[c >> 5] & (static_cast(1) << (c & 0x1f))) != 0; } else if (static_cast(c) < 0xffff) { - return static_cast((bits[c >> 6] & (INT64_C(1) << (c & 0x3f))) != 0); + return (bits[c >> 6] & (INT64_C(1) << (c & 0x3f))) != 0; } else { return restSet->contains(c); } diff --git a/icu4c/source/test/perf/unisetperf/draft/trieset.cpp b/icu4c/source/test/perf/unisetperf/draft/trieset.cpp index 9c15179216c1..d5406601fcef 100644 --- a/icu4c/source/test/perf/unisetperf/draft/trieset.cpp +++ b/icu4c/source/test/perf/unisetperf/draft/trieset.cpp @@ -108,9 +108,9 @@ class TrieSet : public UObject, public UnicodeContainable { UBool contains(UChar32 c) const override { if (static_cast(c) <= 0xff) { - return static_cast(latin1[c]); + return latin1[c]; } else if (static_cast(c) < 0xffff) { - return static_cast(UTRIE_GET8_FROM_LEAD(&trie, c)); + return UTRIE_GET8_FROM_LEAD(&trie, c); } else { return restSet->contains(c); } diff --git a/icu4c/source/tools/genrb/parse.cpp b/icu4c/source/tools/genrb/parse.cpp index f0bf9e79a0b4..f487241cc189 100644 --- a/icu4c/source/tools/genrb/parse.cpp +++ b/icu4c/source/tools/genrb/parse.cpp @@ -2137,7 +2137,7 @@ void initParser() } static inline UBool isTable(enum EResourceType type) { - return static_cast(type == RESTYPE_TABLE || type == RESTYPE_TABLE_NO_FALLBACK); + return type == RESTYPE_TABLE || type == RESTYPE_TABLE_NO_FALLBACK; } static enum EResourceType diff --git a/icu4c/source/tools/gensprep/store.c b/icu4c/source/tools/gensprep/store.c index f0f4d7844be8..b2cf44d186b3 100644 --- a/icu4c/source/tools/gensprep/store.c +++ b/icu4c/source/tools/gensprep/store.c @@ -233,7 +233,7 @@ static int32_t U_CALLCONV hashEntry(const UHashTok parm) { /* Callback for comparing two entries */ static UBool U_CALLCONV compareEntries(const UHashTok p1, const UHashTok p2) { - return (UBool)(p1.integer != p2.integer); + return p1.integer != p2.integer; } diff --git a/icu4c/source/tools/icupkg/icupkg.cpp b/icu4c/source/tools/icupkg/icupkg.cpp index 45663d413ac4..3da4af745786 100644 --- a/icu4c/source/tools/icupkg/icupkg.cpp +++ b/icu4c/source/tools/icupkg/icupkg.cpp @@ -253,7 +253,7 @@ isPackageName(const char *filename) { int32_t len; len = static_cast(strlen(filename)) - 4; /* -4: subtract the length of ".dat" */ - return static_cast(len > 0 && 0 == strcmp(filename + len, ".dat")); + return len > 0 && 0 == strcmp(filename + len, ".dat"); } /* This line is required by MinGW because it incorrectly globs the arguments. diff --git a/icu4c/source/tools/makeconv/genmbcs.cpp b/icu4c/source/tools/makeconv/genmbcs.cpp index 774cdc6045d1..25b5ddcb0152 100644 --- a/icu4c/source/tools/makeconv/genmbcs.cpp +++ b/icu4c/source/tools/makeconv/genmbcs.cpp @@ -559,7 +559,7 @@ MBCSIsValid(NewConverter *cnvData, const uint8_t *bytes, int32_t length) { MBCSData *mbcsData=(MBCSData *)cnvData; - return (UBool)(1==ucm_countChars(&mbcsData->ucm->states, bytes, length)); + return 1==ucm_countChars(&mbcsData->ucm->states, bytes, length); } U_CDECL_END static UBool diff --git a/icu4c/source/tools/toolutil/package.cpp b/icu4c/source/tools/toolutil/package.cpp index dd4814927833..e58c6648b647 100644 --- a/icu4c/source/tools/toolutil/package.cpp +++ b/icu4c/source/tools/toolutil/package.cpp @@ -1233,7 +1233,7 @@ UBool Package::checkDependencies() { isMissingItems=false; enumDependencies(this, checkDependency); - return static_cast(!isMissingItems); + return !isMissingItems; } void