]> granicus.if.org Git - icu/commitdiff
ICU-21015 Fixing gcc compiler warnings
authorShane F. Carr <shane@unicode.org>
Tue, 31 Mar 2020 03:21:24 +0000 (22:21 -0500)
committerShane F. Carr <shane@unicode.org>
Fri, 3 Apr 2020 06:56:07 +0000 (01:56 -0500)
icu4c/source/i18n/dtptngen.cpp
icu4c/source/i18n/dtptngen_impl.h
icu4c/source/i18n/unicode/basictz.h
icu4c/source/i18n/unicode/numsys.h
icu4c/source/test/cintltst/ccapitst.c
icu4c/source/test/intltest/convtest.cpp
icu4c/source/test/intltest/rbbitst.cpp
icu4c/source/tools/pkgdata/pkgdata.cpp

index 26ebee2d2021b3a8cdaa5e249bf4c87d423d52a0..02be4f054b8a1a6493d6be76254d73073df99d43 100644 (file)
@@ -2197,6 +2197,11 @@ DateTimeMatcher::DateTimeMatcher(const DateTimeMatcher& other) {
     copyFrom(other.skeleton);
 }
 
+DateTimeMatcher& DateTimeMatcher::operator=(const DateTimeMatcher& other) {
+    copyFrom(other.skeleton);
+    return *this;
+}
+
 
 void
 DateTimeMatcher::set(const UnicodeString& pattern, FormatParser* fp) {
index 95219f0ba257f51484158e98f699572ea88de2cc..ade9f57331e769067d1361fc94655bf470ff91bf 100644 (file)
@@ -238,6 +238,7 @@ public:
     int32_t getDistance(const DateTimeMatcher& other, int32_t includeMask, DistanceInfo& distanceInfo) const;
     DateTimeMatcher();
     DateTimeMatcher(const DateTimeMatcher& other);
+    DateTimeMatcher& operator=(const DateTimeMatcher& other);
     virtual ~DateTimeMatcher();
     int32_t getFieldMask() const;
 };
index c4d08768987d69c38c0ae4874b71cf9173932406..fc2cb8e59f768482d0348eb92b1a54f9815e5eb4 100644 (file)
@@ -206,6 +206,12 @@ protected:
      */
     BasicTimeZone(const BasicTimeZone& source);
 
+    /**
+     * Copy assignment.
+     * @stable ICU 3.8
+     */
+    BasicTimeZone& operator=(const BasicTimeZone&) = default;
+
     /**
      * Gets the set of TimeZoneRule instances applicable to the specified time and after.
      * @param start     The start date used for extracting time zone rules
index b2b16fa0d0e72361a984cf135cb62bd7c09573e0..7def7032e1b1efcb0c69efb0e6f8ce63b428ff4f 100644 (file)
@@ -73,6 +73,12 @@ public:
      */
     NumberingSystem(const NumberingSystem& other);
 
+    /**
+     * Copy assignment.
+     * @stable ICU 4.2
+     */
+    NumberingSystem& operator=(const NumberingSystem& other) = default;
+
     /**
      * Destructor.
      * @stable ICU 4.2
index 73663f12459cec0a9dbbf73513af78e85eac262e..aae16f98f44f88677c8ba09e3b4916c05f7f96a7 100644 (file)
@@ -3035,7 +3035,7 @@ static void TestJ1968(void) {
 
     err = U_ZERO_ERROR;
     myConvName[UCNV_MAX_CONVERTER_NAME_LENGTH-1] = ',';
-    strncpy(myConvName + UCNV_MAX_CONVERTER_NAME_LENGTH, "locale=", 7);
+    memcpy(myConvName + UCNV_MAX_CONVERTER_NAME_LENGTH, "locale=", 7);
     cnv = ucnv_open(myConvName, &err);
     if (cnv || err != U_ILLEGAL_ARGUMENT_ERROR) {
         log_err("4) Didn't get U_ILLEGAL_ARGUMENT_ERROR as expected %s\n", u_errorName(err));
index 53d8cfdbd1202212b3565e2490d72bc3e10201ef..949bd3b84860a6391e223349c97ee930a800ca6f 100644 (file)
@@ -1185,9 +1185,13 @@ ConversionTest::ToUnicodeCase(ConversionCase &cc, UConverterToUCallback callback
             cc.offsets=NULL;
         }
         else {
-            memset(resultOffsets, -1, UPRV_LENGTHOF(resultOffsets));
+            for (int32_t i = 0; i < UPRV_LENGTHOF(resultOffsets); i++) {
+                resultOffsets[i] = -1;
+            }
+        }
+        for (int32_t i = 0; i < UPRV_LENGTHOF(result); i++) {
+            result[i] = -1;
         }
-        memset(result, -1, UPRV_LENGTHOF(result));
         errorCode.reset();
         resultLength=stepToUnicode(cc, cnv.getAlias(),
                                 result, UPRV_LENGTHOF(result),
@@ -1615,8 +1619,12 @@ ConversionTest::FromUnicodeCase(ConversionCase &cc, UConverterFromUCallback call
     ok=TRUE;
     for(i=0; i<UPRV_LENGTHOF(steps) && ok; ++i) {
         step=steps[i].step;
-        memset(resultOffsets, -1, UPRV_LENGTHOF(resultOffsets));
-        memset(result, -1, UPRV_LENGTHOF(result));
+        for (int32_t i = 0; i < UPRV_LENGTHOF(resultOffsets); i++) {
+            resultOffsets[i] = -1;
+        }
+        for (int32_t i = 0; i < UPRV_LENGTHOF(result); i++) {
+            result[i] = -1;
+        }
         errorCode=U_ZERO_ERROR;
         resultLength=stepFromUnicode(cc, cnv,
                                 result, UPRV_LENGTHOF(result),
index 92e7adef592dd165ad7a4f17f84ee85095ead9a8..d5728bd6833c83b9af2c0cfb36889d5ecb90bada 100644 (file)
@@ -4285,7 +4285,7 @@ void RBBITest::RunMonkey(BreakIterator *bi, RBBIMonkeyKind &mk, const char *name
                     u_charName(c, U_EXTENDED_CHAR_NAME, cName, sizeof(cName), &status);
 
                     char buffer[200];
-                    snprintf(buffer, 200,
+                    auto ret = snprintf(buffer, UPRV_LENGTHOF(buffer),
                              "%4s %3i :  %1s  %1s  %10s  %-*s  %-40s  %-40s",
                              currentLineFlag.c_str(),
                              ci,
@@ -4295,6 +4295,8 @@ void RBBITest::RunMonkey(BreakIterator *bi, RBBIMonkeyKind &mk, const char *name
                              classNameSize,
                              mk.classNameFromCodepoint(c).c_str(),
                              mk.getAppliedRule(ci).c_str(), cName);
+                    (void)ret;
+                    U_ASSERT(0 <= ret && ret < UPRV_LENGTHOF(buffer));
 
                     // Output the error
                     if (ci == i) {
index ea75302a9849ba1ad9f106aba8f0ca1654e5241f..5ab682e4df8cb639b4654704108d2907c5e237ca 100644 (file)
@@ -46,6 +46,7 @@
 #include "flagparser.h"
 #include "filetools.h"
 #include "charstr.h"
+#include "uassert.h"
 
 #if U_HAVE_POPEN
 # include <unistd.h>
@@ -1132,12 +1133,15 @@ static int32_t pkg_installLibrary(const char *installDir, const char *targetDir,
     int32_t result = 0;
     char cmd[SMALL_BUFFER_MAX_SIZE];
 
-    sprintf(cmd, "cd %s && %s %s %s%s%s",
+    auto ret = snprintf(cmd,
+            SMALL_BUFFER_MAX_SIZE,
+            "cd %s && %s %s %s%s%s",
             targetDir,
             pkgDataFlags[INSTALL_CMD],
             libFileNames[LIB_FILE_VERSION],
-            installDir, PKGDATA_FILE_SEP_STRING, libFileNames[LIB_FILE_VERSION]
-            );
+            installDir, PKGDATA_FILE_SEP_STRING, libFileNames[LIB_FILE_VERSION]);
+    (void)ret;
+    U_ASSERT(0 <= ret && ret < SMALL_BUFFER_MAX_SIZE);
 
     result = runCommand(cmd);
 
@@ -1255,10 +1259,14 @@ static int32_t pkg_installFileMode(const char *installDir, const char *srcDir, c
                     buffer[bufferLength-1] = 0;
                 }
 
-                sprintf(cmd, "%s %s%s%s %s%s%s",
+                auto ret = snprintf(cmd,
+                        SMALL_BUFFER_MAX_SIZE,
+                        "%s %s%s%s %s%s%s",
                         pkgDataFlags[INSTALL_CMD],
                         srcDir, PKGDATA_FILE_SEP_STRING, buffer,
                         installDir, PKGDATA_FILE_SEP_STRING, buffer);
+                (void)ret;
+                U_ASSERT(0 <= ret && ret < SMALL_BUFFER_MAX_SIZE);
 
                 result = runCommand(cmd);
                 if (result != 0) {
@@ -1690,12 +1698,20 @@ static int32_t pkg_createWithoutAssemblyCode(UPKGOptions *o, const char *targetD
                             break;
                         }
                     }
-                    sprintf(newName, "%s_%s",
+                    auto ret = snprintf(newName,
+                            SMALL_BUFFER_MAX_SIZE,
+                            "%s_%s",
                             DATA_PREFIX[n],
                             newNameTmp);
-                    sprintf(dataName, "%s_%s",
+                    (void)ret;
+                    U_ASSERT(0 <= ret && ret < SMALL_BUFFER_MAX_SIZE);
+                    ret = snprintf(dataName,
+                            SMALL_BUFFER_MAX_SIZE,
+                            "%s_%s",
                             o->shortName,
                             DATA_PREFIX[n]);
+                    (void)ret;
+                    U_ASSERT(0 <= ret && ret < SMALL_BUFFER_MAX_SIZE);
                 }
                 if (newName[0] != 0) {
                     break;