Skip to content

Commit

Permalink
ICU-22522 Delete unused variables.
Browse files Browse the repository at this point in the history
Clang 16 is more thorough in finding unused variables, so these must be
removed to be able to compile this code using Clang 16 and -Werror.
  • Loading branch information
roubert committed Nov 27, 2023
1 parent 8d3d214 commit e739873
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 20 deletions.
3 changes: 1 addition & 2 deletions icu4c/source/test/cintltst/cbiditst.c
Original file line number Diff line number Diff line change
Expand Up @@ -4539,8 +4539,7 @@ overrideBidiClass(const void *context, UChar32 c) {
DEF, DEF, DEF, LRO, B, RLO, BN, DEF /* 78-7F */
};
static const int nEntries = UPRV_LENGTHOF(customClasses);
const char *dummy = context; /* just to avoid a compiler warning */
dummy++;
(void)context; /* just to avoid a compiler warning */

return c >= nEntries ? U_BIDI_CLASS_DEFAULT : customClasses[c];
}
Expand Down
2 changes: 1 addition & 1 deletion icu4c/source/test/intltest/rbbimonkeytest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ void BreakRules::compileRules(UCHARBUF *rules, UErrorCode &status) {
}

UnicodeString emptyString;
for (int32_t lineNumber=0; ;lineNumber++) { // Loop once per input line.
for (;;) { // Loop once per input line.
if (U_FAILURE(status)) {
return;
}
Expand Down
1 change: 1 addition & 0 deletions icu4c/source/test/intltest/rbbitst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4178,6 +4178,7 @@ void RBBITest::RunMonkey(BreakIterator *bi, RBBIMonkeyKind &mk, const char *name
expectedBreaks[breakPos] = 1;
expectedCount++;
U_ASSERT(expectedCount<testText.length());
(void)expectedCount; // Used by U_ASSERT().
}

// Find the break positions using forward iteration
Expand Down
6 changes: 2 additions & 4 deletions icu4c/source/test/intltest/utxttest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,11 +446,10 @@ void UTextTest::TestCopyMove(const UnicodeString &us, UText *ut, UBool move,
// Compare the results of the two parallel tests
int32_t usi = 0; // UnicodeString position, utf-16 index.
int64_t uti = 0; // UText position, native index.
int32_t cpi; // char32 position (code point index)
UChar32 usc; // code point from Unicode String
UChar32 utc; // code point from UText
utext_setNativeIndex(targetUT, 0);
for (cpi=0; ; cpi++) {
for (;;) {
usc = targetUS.char32At(usi);
utc = utext_next32(targetUT);
if (utc < 0) {
Expand Down Expand Up @@ -522,12 +521,11 @@ void UTextTest::TestReplace(
//
int32_t usi = 0; // UnicodeString position, utf-16 index.
int64_t uti = 0; // UText position, native index.
int32_t cpi; // char32 position (code point index)
UChar32 usc; // code point from Unicode String
UChar32 utc; // code point from UText
int64_t expectedNativeLength = 0;
utext_setNativeIndex(targetUT, 0);
for (cpi=0; ; cpi++) {
for (;;) {
usc = targetUS.char32At(usi);
utc = utext_next32(targetUT);
if (utc < 0) {
Expand Down
18 changes: 8 additions & 10 deletions icu4c/source/tools/genrb/rle.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,12 @@ encodeRunByte(uint16_t* buffer,uint16_t* bufLimit, uint8_t value, int32_t length
return buffer;
}

#define APPEND( buffer, bufLimit, value, num, status) UPRV_BLOCK_MACRO_BEGIN { \
#define APPEND( buffer, bufLimit, value, status) UPRV_BLOCK_MACRO_BEGIN { \
if(buffer<bufLimit){ \
*buffer++=(value); \
}else{ \
*status = U_BUFFER_OVERFLOW_ERROR; \
} \
num++; \
} UPRV_BLOCK_MACRO_END

/**
Expand All @@ -107,29 +106,28 @@ encodeRunByte(uint16_t* buffer,uint16_t* bufLimit, uint8_t value, int32_t length
*/
static uint16_t*
encodeRunShort(uint16_t* buffer,uint16_t* bufLimit, uint16_t value, int32_t length,UErrorCode* status) {
int32_t num=0;
if (length < 4) {
int j=0;
for (; j<length; ++j) {
if (value == (int32_t) ESCAPE){
APPEND(buffer,bufLimit,ESCAPE, num, status);
APPEND(buffer,bufLimit,ESCAPE, status);

}
APPEND(buffer,bufLimit,value,num, status);
APPEND(buffer,bufLimit,value,status);
}
}
else {
if (length == (int32_t) ESCAPE) {
if (value == (int32_t) ESCAPE){
APPEND(buffer,bufLimit,ESCAPE,num,status);
APPEND(buffer,bufLimit,ESCAPE,status);

}
APPEND(buffer,bufLimit,value,num,status);
APPEND(buffer,bufLimit,value,status);
--length;
}
APPEND(buffer,bufLimit,ESCAPE,num,status);
APPEND(buffer,bufLimit,(uint16_t) length, num,status);
APPEND(buffer,bufLimit,(uint16_t)value, num, status); /* Don't need to escape this value */
APPEND(buffer,bufLimit,ESCAPE,status);
APPEND(buffer,bufLimit,(uint16_t) length,status);
APPEND(buffer,bufLimit,(uint16_t)value, status); /* Don't need to escape this value */
}
return buffer;
}
Expand Down
3 changes: 0 additions & 3 deletions icu4c/source/tools/genrb/wrtjava.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,6 @@ string_write_java(const StringResource *res,UErrorCode *status) {
static void
array_write_java(const ArrayResource *res, UErrorCode *status) {

uint32_t i = 0;
const char* arr ="new String[] { \n";
struct SResource *current = nullptr;
UBool allStrings = true;
Expand All @@ -342,7 +341,6 @@ array_write_java(const ArrayResource *res, UErrorCode *status) {
if (res->fCount > 0) {

current = res->fFirst;
i = 0;
while(current != nullptr){
if(!current->isString()){
allStrings = false;
Expand Down Expand Up @@ -370,7 +368,6 @@ array_write_java(const ArrayResource *res, UErrorCode *status) {
if(U_FAILURE(*status)){
return;
}
i++;
current = current->fNext;
}
T_FileStream_write(out,"\n",1);
Expand Down

0 comments on commit e739873

Please sign in to comment.