]> granicus.if.org Git - icu/commitdiff
ICU-10624 Compiler warning cleanups, continued.
authorAndy Heninger <andy.heninger@gmail.com>
Fri, 10 Jan 2014 08:35:00 +0000 (08:35 +0000)
committerAndy Heninger <andy.heninger@gmail.com>
Fri, 10 Jan 2014 08:35:00 +0000 (08:35 +0000)
X-SVN-Rev: 34855

icu4c/source/test/cintltst/capitst.c
icu4c/source/test/cintltst/ccapitst.c
icu4c/source/test/cintltst/cdattst.c
icu4c/source/test/cintltst/cloctst.c
icu4c/source/test/cintltst/cnumtst.c
icu4c/source/test/cintltst/custrtrn.c
icu4c/source/test/intltest/caltest.cpp
icu4c/source/test/intltest/dtfmttst.cpp
icu4c/source/test/intltest/plurults.cpp
icu4c/source/test/intltest/tufmtts.cpp
icu4c/source/tools/pkgdata/pkgdata.cpp

index c5097891b92199a51afe7b44409cea43f23802dc..d4ca6d8d36945febb488569c51c2d6ae3e3af44a 100644 (file)
@@ -1,5 +1,5 @@
 /********************************************************************
- * Copyright (c) 1997-2013, International Business Machines
+ * Copyright (c) 1997-2014, International Business Machines
  * Corporation and others. All Rights Reserved.
  ********************************************************************/
 /*****************************************************************************
@@ -2417,10 +2417,10 @@ static void TestStrcollNull(void) {
     const UChar u16han[] = {0x5c71, 0x5ddd, 0};
     const int32_t u16hanLen = 2;
 
-    const char u8asc[] = {0x49, 0x42, 0x4D, 0};
+    const char *u8asc = "\x49\x42\x4D";
     const int32_t u8ascLen = 3;
 
-    const char u8han[] = {0xE5, 0xB1, 0xB1, 0xE5, 0xB7, 0x9D, 0};
+    const char *u8han = "\xE5\xB1\xB1\xE5\xB7\x9D";
     const int32_t u8hanLen = 6;
 
     coll = ucol_open(NULL, &status);
index fcedd9a34997518d556e5011530b509fafb5365a..b238ee65d7c68bc297d2ef8fcf4433d9cb90aa0d 100644 (file)
@@ -837,7 +837,8 @@ static void TestConvert()
 
 
         /*Reads the BOM*/
-        fread(&BOM, sizeof(UChar), 1, ucs_file_in);
+        size_t numRead = fread(&BOM, sizeof(UChar), 1, ucs_file_in);
+        (void)numRead;
         if (BOM!=0xFEFF && BOM!=0xFFFE) 
         {
             log_err("File Missing BOM...Bailing!\n");
index a84bf96bb62f4b681ab93f08084475dd09e53c86..13ac0c52ecb9dd0c3f8d6e77fa888c69dafee4c8 100644 (file)
@@ -1,6 +1,6 @@
 /********************************************************************
  * COPYRIGHT: 
- * Copyright (c) 1997-2013, International Business Machines Corporation and
+ * Copyright (c) 1997-2014, International Business Machines Corporation and
  * others. All Rights Reserved.
  ********************************************************************/
 /********************************************************************************
@@ -1492,6 +1492,7 @@ static void TestContext(void) {
                     char bbuf1[kBbufMax];
                     char bbuf2[kBbufMax];
                     int32_t len = udat_format(udfmt, today, ubuf, kUbufMax, NULL, &status);
+                    (void)len;
                     if ( U_FAILURE(status) ) {
                         log_err("FAIL: udat_format today for locale %s, capitalizationContext %d, status %s\n",
                                 textRelContextItemPtr->locale, (int)textRelContextItemPtr->capitalizationContext, u_errorName(status) );
index 89b46ad4077007219088bdef9ee00e3ddea937b4..37f3c61b47a8f548d79c5c459a4199d2d329b424 100644 (file)
@@ -1,6 +1,6 @@
 /********************************************************************
  * COPYRIGHT:
- * Copyright (c) 1997-2013, International Business Machines Corporation and
+ * Copyright (c) 1997-2014, International Business Machines Corporation and
  * others. All Rights Reserved.
  ********************************************************************/
 /*****************************************************************************
@@ -1094,6 +1094,7 @@ static void TestDisplayNameBrackets()
             log_data_err("uldn_open fails for displayLocale %s, status=%s\n", itemPtr->displayLocale, u_errorName(status));
         }
 #endif
+    (void)ulen;   /* Suppress variable not used warning */
     }
 }
 
index 4a8f366d1db672973078681fabef3ee980fdb131..202497eca0912054716b72dd1b1cb39ba939c83a 100644 (file)
@@ -1,6 +1,6 @@
 /********************************************************************
  * COPYRIGHT:
- * Copyright (c) 1997-2013, International Business Machines Corporation and
+ * Copyright (c) 1997-2014, International Business Machines Corporation and
  * others. All Rights Reserved.
  ********************************************************************/
 /********************************************************************************
@@ -2339,6 +2339,7 @@ static void TestUNumberingSystem(void) {
                         itemPtr->locale, itemPtr->numsys, itemPtr->radix, itemPtr->isAlgorithmic, numsys, radix, isAlgorithmic);
             }
             ulen = unumsys_getDescription(unumsys, ubuf, kNumSysDescripBufMax, &status);
+            (void)ulen;   // Suppress variable not used warning.
             if ( U_FAILURE(status) || u_strcmp(ubuf, itemPtr->description) != 0 ) {
                 log_data_err("unumsys description for locale %s, description unexpected and/or status %\n", myErrorName(status));
             }
index 847a1f2fe3720de09297b6f4e880529f21e7f680..c30f76d487ae0765f842d978c080155e1be0ecd2 100644 (file)
@@ -1,6 +1,6 @@
 /********************************************************************
  * COPYRIGHT:
- * Copyright (c) 2001-2013, International Business Machines Corporation and
+ * Copyright (c) 2001-2014, International Business Machines Corporation and
  * others. All Rights Reserved.
  ********************************************************************/
 /********************************************************************************
@@ -851,7 +851,7 @@ static void Test_UChar_UTF8_API(void){
          * Test with an illegal lead byte that would be followed by more than 3 trail bytes.
          * See ticket #10371.
          */
-        static const char src[1]={ 0xf8 };
+        static const char src[1]={ (char)0xf8 };
         UChar out16[10];
         err=U_ZERO_ERROR;
         u_strFromUTF8(out16, LENGTHOF(out16), NULL, src, 1, &err);
index 81842ae379a0db8739f944d70d5c46ca06e2ae7e..5c30426e9bb132fda4cdafd0e0d12829bf3b3079 100644 (file)
@@ -1,6 +1,6 @@
 /************************************************************************
  * COPYRIGHT: 
- * Copyright (c) 1997-2013, International Business Machines Corporation
+ * Copyright (c) 1997-2014, International Business Machines Corporation
  * and others. All Rights Reserved.
  ************************************************************************/
 #include "unicode/utypes.h"
@@ -2912,6 +2912,7 @@ void CalendarTest::TestHebrewMonthValidation() {
     // 5777 is NOT a lear year and does not have month Adar I
     pCal->set(5777, HebrewCalendar::ADAR_1, 1);
     d = pCal->getTime(status);
+    (void)d;
     if (status == U_ILLEGAL_ARGUMENT_ERROR) {
         logln("Info: U_ILLEGAL_ARGUMENT_ERROR, because 5777 Adar I 1 is not a valid date.");
     } else {
index 5be24f0edf2eccfb60f085ac57a58d9b6a3e5559..4bcf22dc557aae26349add62ba1bdc188b81154e 100644 (file)
@@ -1,6 +1,6 @@
 /********************************************************************
  * COPYRIGHT:
- * Copyright (c) 1997-2013, International Business Machines
+ * Copyright (c) 1997-2014, International Business Machines
  * Corporation and others. All Rights Reserved.
  ********************************************************************/
 
@@ -4218,38 +4218,38 @@ void DateFormatTest::TestDateFormatLeniency() {
         { NULL,     true,       UnicodeString(""),              UnicodeString(""),                  UnicodeString("") }                
     };
     UErrorCode status = U_ZERO_ERROR;
-    Calendar* cal = Calendar::createInstance(status);
+    LocalPointer<Calendar> cal(Calendar::createInstance(status));
     if (U_FAILURE(status)) {
         dataerrln(UnicodeString("FAIL: Unable to create Calendar for default timezone and locale."));
-    } else {
-        cal->setTime(july022008, status);
-        const TestDateFormatLeniencyItem * itemPtr;
-        for (itemPtr = items; itemPtr->locale != NULL; itemPtr++ ) {
-                                            
-           Locale locale = Locale::createFromName(itemPtr->locale);
-           status = U_ZERO_ERROR;
-           ParsePosition pos(0);
-           SimpleDateFormat * sdmft = new SimpleDateFormat(itemPtr->pattern, locale, status);
-           if (U_FAILURE(status)) {
-               dataerrln("Unable to create SimpleDateFormat - %s", u_errorName(status));
-               continue;
-           }
-           sdmft->setLenient(itemPtr->leniency);
-           sdmft->setBooleanAttribute(UDAT_PARSE_ALLOW_WHITESPACE, itemPtr->leniency, status).setBooleanAttribute(UDAT_PARSE_ALLOW_NUMERIC, itemPtr->leniency, status);
-           /*UDate d = */sdmft->parse(itemPtr->parseString, pos);
-
-           delete sdmft;
-           if(pos.getErrorIndex() > -1)
-               if(itemPtr->expectedResult.length() != 0) {
-                 errln("error: unexpected error - " + itemPtr->parseString + " - error index " + pos.getErrorIndex() + " - leniency " + itemPtr->leniency);
-                 continue;
-               } else {
-                 continue;
-               }
-        }
+        return;
+    }
+    cal->setTime(july022008, status);
+    const TestDateFormatLeniencyItem * itemPtr;
+    LocalPointer<SimpleDateFormat> sdmft;
+    for (itemPtr = items; itemPtr->locale != NULL; itemPtr++ ) {
+                                        
+       Locale locale = Locale::createFromName(itemPtr->locale);
+       status = U_ZERO_ERROR;
+       ParsePosition pos(0);
+       sdmft.adoptInstead(new SimpleDateFormat(itemPtr->pattern, locale, status));
+       if (U_FAILURE(status)) {
+           dataerrln("Unable to create SimpleDateFormat - %s", u_errorName(status));
+           continue;
+       }
+       sdmft->setLenient(itemPtr->leniency);
+       sdmft->setBooleanAttribute(UDAT_PARSE_ALLOW_WHITESPACE, itemPtr->leniency, status).
+              setBooleanAttribute(UDAT_PARSE_ALLOW_NUMERIC, itemPtr->leniency, status);
+       UDate d = sdmft->parse(itemPtr->parseString, pos); 
+       (void)d;
+
+       // TODO: Ticket 10625. Nothing here is checking the expected result when the parse succeeds.
+       
+       if ((pos.getErrorIndex() > -1) && (itemPtr->expectedResult.length() != 0)) {
+           errln("error: unexpected error - " + itemPtr->parseString + 
+                 " - error index " + pos.getErrorIndex() + 
+                 " - leniency " + itemPtr->leniency);
+       }
     }
-    delete cal;
-
 }
 
 #endif /* #if !UCONFIG_NO_FORMATTING */
index 9f8346cb75653f32e28568f851c952cf4f3e422c..8fce96f76db5e53c1cfc2b2d81615c766b6d4cb2 100644 (file)
@@ -1,6 +1,6 @@
 /*
 *******************************************************************************
-* Copyright (C) 2007-2013, International Business Machines Corporation and
+* Copyright (C) 2007-2014, International Business Machines Corporation and
 * others. All Rights Reserved.
 ********************************************************************************
 
@@ -224,7 +224,7 @@ void PluralRulesTest::testAPI(/*char *par*/)
     for (int32_t i=0; i<LENGTHOF(fData); i++) {
         if ((newRules->select(fData[i])== KEYWORD_A) != isKeywordA[i]) {
              errln("File %s, Line %d, ERROR: plural rules for decimal fractions test failed!\n"
-                   "  number = %g, expected %s", __FILE__, __LINE__, fData[i], isKeywordA?"TRUE":"FALSE");
+                   "  number = %g, expected %s", __FILE__, __LINE__, fData[i], isKeywordA[i]?"TRUE":"FALSE");
         }
     }
 
index a1f4104c76ef9242e0771a51dfd9624846e256ee..ce1a9450320f53ceabc0e211cccff0bdd782386f 100644 (file)
@@ -1,5 +1,5 @@
 /********************************************************************
- * Copyright (c) 2008-2013, International Business Machines Corporation and
+ * Copyright (c) 2008-2014, International Business Machines Corporation and
  * others. All Rights Reserved.
  ********************************************************************/
 
@@ -21,6 +21,8 @@
 #include <iostream>
 #endif
 
+#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
+
 void TimeUnitTest::runIndexedTest( int32_t index, UBool exec, const char* &name, char* /*par*/ ) {
     if (exec) logln("TestSuite TimeUnitTest");
     switch (index) {
@@ -387,7 +389,7 @@ void TimeUnitTest::test10219Plurals() {
         dataerrln("generating NumberFormat Object failed: %s", u_errorName(status));
         return;
     }
-    for (int32_t i = 0; i < sizeof(expected) / sizeof(expected[0]); ++i) {
+    for (int32_t i = 0; i < LENGTHOF(expected); ++i) {
         nf->setMaximumFractionDigits(i);
         nf->setRoundingMode(DecimalFormat::kRoundDown);
         tuf.setNumberFormat(*nf, status);
index a7626336b5312967fdf77d51b3e1bb45e46bea88..d3c1eac5dea675da563d1049a2b728b8622f10d0 100644 (file)
@@ -1,5 +1,5 @@
 /******************************************************************************
- *   Copyright (C) 2000-2013, International Business Machines
+ *   Copyright (C) 2000-2014, International Business Machines
  *   Corporation and others.  All Rights Reserved.
  *******************************************************************************
  *   file name:  pkgdata.cpp
@@ -1985,7 +1985,7 @@ static void loadLists(UPKGOptions *o, UErrorCode *status)
       if (cmdBuf[0] != 0) {
           uprv_strncat(cmdBuf, U_FILE_SEP_STRING, 1024);
       }
-      uprv_strncat(cmdBuf, cmd, 1024);
+      uprv_strncat(cmdBuf, cmd, 1023);
       
       if(verbose) {
         fprintf(stdout, "# Calling icu-config: %s\n", cmdBuf);