ICU-11428 Various compiler warning fixes.

X-SVN-Rev: 36903
This commit is contained in:
Andy Heninger 2014-12-19 23:41:18 +00:00
parent 67f2494005
commit b3c29ef95e
12 changed files with 41 additions and 33 deletions

View File

@ -882,7 +882,7 @@ static UBool compareBinaryFiles(const char* defaultTZFileName, const char* TZFil
if (tzInfo->defaultTZBuffer == NULL) {
rewind(tzInfo->defaultTZFilePtr);
tzInfo->defaultTZBuffer = (char*)uprv_malloc(sizeof(char) * tzInfo->defaultTZFileSize);
fread(tzInfo->defaultTZBuffer, 1, tzInfo->defaultTZFileSize, tzInfo->defaultTZFilePtr);
sizeFileRead = fread(tzInfo->defaultTZBuffer, 1, tzInfo->defaultTZFileSize, tzInfo->defaultTZFilePtr);
}
rewind(file);
while(sizeFileLeft > 0) {

View File

@ -1320,7 +1320,7 @@ _appendLDMLExtensionAsKeywords(const char* ldmlext, ExtensionListEntry** appendT
/* BCP47 representation of LDML key/type pairs */
while (!isDone) {
const char *pNextBcpKey = NULL;
int32_t nextBcpKeyLen;
int32_t nextBcpKeyLen = 0;
UBool emitKeyword = FALSE;
if (*pTag) {

View File

@ -1377,7 +1377,7 @@ CollationDataBuilder::buildContext(ConditionalCE32 *head, UErrorCode &errorCode)
// Build the contractions trie.
contractionBuilder.clear();
// Entry for an empty suffix, to be stored before the trie.
uint32_t emptySuffixCE32;
uint32_t emptySuffixCE32 = 0;
uint32_t flags = 0;
if(firstCond->context.length() == suffixStart) {
// There is a mapping for the prefix and the single character c. (p|c)

View File

@ -427,15 +427,15 @@ TimeZone::createTimeZone(const UnicodeString& ID)
*/
TimeZone* result = createSystemTimeZone(ID);
if (result == 0) {
if (result == NULL) {
U_DEBUG_TZ_MSG(("failed to load system time zone with id - falling to custom"));
result = createCustomTimeZone(ID);
}
if (result == 0) {
if (result == NULL) {
U_DEBUG_TZ_MSG(("failed to load time zone with id - falling to Etc/Unknown(GMT)"));
const TimeZone& unknown = getUnknown();
if (&unknown == NULL) { // Illegal NULL reference!
U_DEBUG_TZ_MSG(("failed to getUnknown()"));
if (_UNKNOWN_ZONE == NULL) { // Cannot test (&unknown == NULL) because the
U_DEBUG_TZ_MSG(("failed to getUnknown()")); // behavior of NULL references is undefined.
} else {
result = unknown.clone();
}

View File

@ -2422,14 +2422,13 @@ static void TestGetKeywordValuesForLocale(void) {
UErrorCode status = U_ZERO_ERROR;
UEnumeration *keywordValues = NULL;
int32_t i, n, size, valueLength;
int32_t i, n, size;
const char *locale = NULL, *value = NULL;
UBool errorOccurred = FALSE;
for (i = 0; i < UPRV_LENGTHOF(PREFERRED) && !errorOccurred; i++) {
locale = PREFERRED[i][0];
value = NULL;
valueLength = 0;
size = 0;
keywordValues = ucol_getKeywordValuesForLocale("collation", locale, TRUE, &status);
@ -2438,6 +2437,7 @@ static void TestGetKeywordValuesForLocale(void) {
break;
}
size = uenum_count(keywordValues, &status);
(void)size;
for (n = 0; (value = PREFERRED[i][n+1]) != NULL; n++) {
if (!uenum_contains(keywordValues, value, &status)) {

View File

@ -4376,7 +4376,7 @@ static const char* inverseBasic(UBiDi *pBiDi, const char *srcChars, int32_t srcL
int32_t destLen;
UChar src[MAXLEN], dest2[MAXLEN];
if (pBiDi == NULL || src == NULL) {
if (pBiDi == NULL || srcChars == NULL) {
return NULL;
}
ubidi_setReorderingOptions(pBiDi, option);

View File

@ -445,7 +445,7 @@ void IntlTest::setICU_DATA() {
}
else {
/* __FILE__ on MSVC7 does not contain the directory */
u_setDataDirectory(".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING "data" U_FILE_SEP_STRING "out" U_FILE_SEP_STRING);
u_setDataDirectory(".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING "data" U_FILE_SEP_STRING "out" U_FILE_SEP_STRING);
return;
}
}
@ -1602,7 +1602,8 @@ const char *IntlTest::getSourceTestData(UErrorCode& /*err*/) {
}
else {
/* We're in icu/source/test/intltest/Platform/(Debug|Release) */
srcDataDir = ".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING "test" U_FILE_SEP_STRING "testdata"U_FILE_SEP_STRING;
srcDataDir = ".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING
"test" U_FILE_SEP_STRING "testdata" U_FILE_SEP_STRING;
}
#endif
return srcDataDir;
@ -1702,13 +1703,13 @@ const char * IntlTest::pathToDataDirectory()
}
else {
/* __FILE__ on MSVC7 does not contain the directory */
FILE *file = fopen(".." U_FILE_SEP_STRING ".."U_FILE_SEP_STRING "data" U_FILE_SEP_STRING "Makefile.in", "r");
FILE *file = fopen(".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING "data" U_FILE_SEP_STRING "Makefile.in", "r");
if (file) {
fclose(file);
fgDataDir = ".." U_FILE_SEP_STRING ".."U_FILE_SEP_STRING "data" U_FILE_SEP_STRING;
fgDataDir = ".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING "data" U_FILE_SEP_STRING;
}
else {
fgDataDir = ".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING ".."U_FILE_SEP_STRING "data" U_FILE_SEP_STRING;
fgDataDir = ".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING "data" U_FILE_SEP_STRING;
}
}
}

View File

@ -2136,6 +2136,7 @@ void LocaleTest::checkRegisteredCollators(const char *expectExtra) {
foundExpected = TRUE;
logln(UnicodeString("Found expected registered collator: ","") + expectStr);
}
(void)foundExpected; // Hush unused variable compiler warning.
if( oldHash.geti(*locStr) == 0 ) {
if(expectExtra != NULL && expectStr==*locStr) {

View File

@ -1,6 +1,6 @@
/*
**********************************************************************
* Copyright (C) 2004-2013, International Business Machines
* Copyright (C) 2004-2014, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
* file name: filetst.c
@ -239,7 +239,7 @@ static void TestFileFromICU(UFILE *myFile) {
myString[2] = '!';
myString[3] = '!';
u_austrncpy(myString, myUString, sizeof(myUString)/sizeof(*myUString));
if (myString == NULL || strcmp(myString, "\t\n") != 0) {
if (strcmp(myString, "\t\n") != 0) {
log_err("u_fgets got \"%s\"\n", myString);
}
@ -247,7 +247,7 @@ static void TestFileFromICU(UFILE *myFile) {
log_err("u_fgets did not return myUString\n");
}
u_austrncpy(myString, myUString, sizeof(myUString)/sizeof(*myUString));
if (myString == NULL || strcmp(myString, "Pointer to integer (Count) %n: n=1 n=1\n") != 0) {
if (strcmp(myString, "Pointer to integer (Count) %n: n=1 n=1\n") != 0) {
log_err("u_fgets got \"%s\"\n", myString);
}
@ -255,7 +255,7 @@ static void TestFileFromICU(UFILE *myFile) {
log_err("u_fgets did not return myUString\n");
}
u_austrncpy(myString, myUString, sizeof(myUString)/sizeof(*myUString));
if (myString == NULL || strcmp(myString, "Pointer to integer Value: 37\n") != 0) {
if (strcmp(myString, "Pointer to integer Value: 37\n") != 0) {
log_err("u_fgets got \"%s\"\n", myString);
}
@ -263,7 +263,7 @@ static void TestFileFromICU(UFILE *myFile) {
log_err("u_fgets did not return myUString\n");
}
u_austrncpy(myString, myUString, sizeof(myUString)/sizeof(*myUString));
if (myString == NULL || strcmp(myString, "This is a long test123456789012345678901234567890123456789012345678901234567890\n") != 0) {
if (strcmp(myString, "This is a long test123456789012345678901234567890123456789012345678901234567890\n") != 0) {
log_err("u_fgets got \"%s\"\n", myString);
}
@ -275,7 +275,7 @@ static void TestFileFromICU(UFILE *myFile) {
log_err("u_fgets did not return myUString\n");
}
u_austrncpy(myString, myUString, sizeof(myUString)/sizeof(*myUString));
if (myString == NULL || strcmp(myString, "") != 0) {
if (strcmp(myString, "") != 0) {
log_err("u_fgets got \"%s\"\n", myString);
}
@ -283,7 +283,7 @@ static void TestFileFromICU(UFILE *myFile) {
log_err("u_fgets did not return myUString\n");
}
u_austrncpy(myString, myUString, sizeof(myUString)/sizeof(*myUString));
if (myString == NULL || strcmp(myString, "\t") != 0) {
if (strcmp(myString, "\t") != 0) {
log_err("u_fgets got \"%s\"\n", myString);
}

View File

@ -1,7 +1,7 @@
/*
*******************************************************************************
*
* Copyright (C) 1999-2013, International Business Machines
* Copyright (C) 1999-2014, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
@ -97,7 +97,8 @@ PortableFontInstance::PortableFontInstance(const char *fileName, float pointSize
// read in the directory
SFNTDirectory tempDir;
fread(&tempDir, sizeof tempDir, 1, fFile);
size_t numRead = fread(&tempDir, sizeof tempDir, 1, fFile);
(void)numRead;
le_int32 dirSize = sizeof tempDir + ((SWAPW(tempDir.numTables) - ANY_NUMBER) * sizeof(DirectoryEntry));
const LETag headTag = LE_HEAD_TABLE_TAG;
@ -116,7 +117,7 @@ PortableFontInstance::PortableFontInstance(const char *fileName, float pointSize
}
fseek(fFile, 0L, SEEK_SET);
fread((void *) fDirectory, sizeof(char), dirSize, fFile);
numRead = fread((void *) fDirectory, sizeof(char), dirSize, fFile);
//
// We calculate these numbers 'cause some fonts
@ -242,7 +243,8 @@ const void *PortableFontInstance::readTable(LETag tag, le_uint32 *length) const
if (table != NULL) {
fseek(fFile, SWAPL(entry->offset), SEEK_SET);
fread(table, sizeof(char), *length, fFile);
size_t numRead = fread(table, sizeof(char), *length, fFile);
(void)numRead;
}
return table;

View File

@ -1,6 +1,6 @@
/***************************************************************************
*
* Copyright (C) 1998-2013, International Business Machines
* Copyright (C) 1998-2014, International Business Machines
* Corporation and others. All Rights Reserved.
*
************************************************************************/
@ -121,6 +121,9 @@ CMAPMapper *CMAPMapper::createUnicodeMapper(const CMAPTable *cmap)
{
subtable = (const CMAPEncodingSubtable *) ((const char *) cmap + foundOffset);
//printf("%s:%d: using subtable #%d/%d type %d:%d\n", __FILE__, __LINE__, foundTable, nSubtables, foundPlatformID, foundPlatformSpecificID);
(void)foundPlatformID; // Suppress unused variable compiler warnings.
(void)foundTable;
(void)foundPlatformSpecificID;
} else {
printf("%s:%d: could not find subtable.\n", __FILE__, __LINE__);
return NULL;

View File

@ -415,15 +415,16 @@ const char *getSourceTestData() {
#ifdef U_TOPSRCDIR
srcDataDir = U_TOPSRCDIR U_FILE_SEP_STRING "test" U_FILE_SEP_STRING "testdata" U_FILE_SEP_STRING;
#else
srcDataDir = ".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING"test"U_FILE_SEP_STRING"testdata"U_FILE_SEP_STRING;
FILE *f = fopen(".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING"test"U_FILE_SEP_STRING"testdata"U_FILE_SEP_STRING"rbbitst.txt", "r");
srcDataDir = ".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING "test" U_FILE_SEP_STRING "testdata" U_FILE_SEP_STRING;
FILE *f = fopen(".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING "test" U_FILE_SEP_STRING "testdata" U_FILE_SEP_STRING "rbbitst.txt", "r");
if (f != NULL) {
/* We're in icu/source/test/letest/ */
fclose(f);
} else {
/* We're in icu/source/test/letest/(Debug|Release) */
srcDataDir = ".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING"test"U_FILE_SEP_STRING"testdata"U_FILE_SEP_STRING;
srcDataDir = ".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING "test"
U_FILE_SEP_STRING "testdata" U_FILE_SEP_STRING;
}
#endif
@ -1028,13 +1029,13 @@ static const char *ctest_dataOutDir()
}
else {
/* __FILE__ on MSVC7 does not contain the directory */
FILE *file = fopen(".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING "data" U_FILE_SEP_STRING "Makefile.in", "r");
FILE *file = fopen(".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING "data" U_FILE_SEP_STRING "Makefile.in", "r");
if (file) {
fclose(file);
dataOutDir = ".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING "data" U_FILE_SEP_STRING "out" U_FILE_SEP_STRING;
dataOutDir = ".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING "data" U_FILE_SEP_STRING "out" U_FILE_SEP_STRING;
}
else {
dataOutDir = ".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING "data" U_FILE_SEP_STRING "out" U_FILE_SEP_STRING;
dataOutDir = ".." U_FILE_SEP_STRING".." U_FILE_SEP_STRING".." U_FILE_SEP_STRING "data" U_FILE_SEP_STRING "out" U_FILE_SEP_STRING;
}
}
}