Fix warnings about truncations in constants.
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>
Tue, 3 Apr 2012 07:43:05 +0000 (09:43 +0200)
committerQt by Nokia <qt-info@nokia.com>
Tue, 3 Apr 2012 19:02:32 +0000 (21:02 +0200)
Change-Id: I46872c5b2866454112092c1ec5efbfe15db5af33
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
src/corelib/io/qtemporarydir.cpp
src/corelib/json/qjsonparser.cpp
src/corelib/kernel/qcoreapplication_win.cpp
src/corelib/mimetypes/qmimemagicrule.cpp
src/gui/text/qtextengine.cpp
src/gui/text/qzip.cpp
src/network/access/qnetworkcookie.cpp
src/tools/qdoc/tokenizer.cpp

index f8cd2e7..579d569 100644 (file)
@@ -99,11 +99,11 @@ static char *mkdtemp(char *templateName)
 {
     static const char letters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
 
-    const int length = strlen(templateName);
+    const size_t length = strlen(templateName);
 
     char *XXXXXX = templateName + length - 6;
 
-    if ((length < 6) || strncmp(XXXXXX, "XXXXXX", 6))
+    if ((length < 6u) || strncmp(XXXXXX, "XXXXXX", 6))
         return 0;
 
     for (int i = 0; i < 256; ++i) {
index 6de3db8..9b11c9a 100644 (file)
@@ -821,7 +821,7 @@ bool Parser::parseString(bool *latin1)
     // no unicode string, we are done
     if (*latin1) {
         // write string length
-        *(QJsonPrivate::qle_ushort *)(data + stringPos) = current - outStart - sizeof(ushort);
+        *(QJsonPrivate::qle_ushort *)(data + stringPos) = ushort(current - outStart - sizeof(ushort));
         int pos = reserveSpace((4 - current) & 3);
         while (pos & 3)
             data[pos++] = 0;
index c1f7c8a..7cc1f0e 100644 (file)
@@ -109,7 +109,7 @@ Q_CORE_EXPORT QString qAppFileName()                // get application file name
         size = MAX_PATH * i;
         b = reinterpret_cast<wchar_t *>(realloc(b, (size + 1) * sizeof(wchar_t)));
         if (b)
-            v = GetModuleFileName(NULL, b, size);
+            v = GetModuleFileName(NULL, b, DWORD(size));
     } while (b && v == size);
 
     if (b)
index 1dee62f..8421516 100644 (file)
@@ -267,7 +267,7 @@ QMimeMagicRule::QMimeMagicRule(QMimeMagicRule::Type theType,
             d->mask = QByteArray::fromHex(QByteArray::fromRawData(d->mask.constData() + 2, d->mask.size() - 2));
             Q_ASSERT(d->mask.size() == d->pattern.size());
         } else {
-            d->mask.fill(static_cast<char>(0xff), d->pattern.size());
+            d->mask.fill(char(-1), d->pattern.size());
         }
         d->mask.squeeze();
         d->matchFunction = matchString;
index 3d58d91..7d36627 100644 (file)
@@ -63,7 +63,7 @@
 
 QT_BEGIN_NAMESPACE
 
-static const float smallCapsFraction = 0.7;
+static const float smallCapsFraction = 0.7f;
 
 namespace {
 // Helper class used in QTextEngine::itemize
index 337326d..1491c1e 100644 (file)
@@ -505,7 +505,7 @@ void QZipReaderPrivate::scanFiles()
     int num_dir_entries = 0;
     EndOfDirectory eod;
     while (start_of_directory == -1) {
-        int pos = device->size() - sizeof(EndOfDirectory) - i;
+        const int pos = device->size() - int(sizeof(EndOfDirectory)) - i;
         if (pos < 0 || i > 65535) {
             qWarning() << "QZip: EndOfDirectory not found";
             return;
index 0dbfdb2..7174acc 100644 (file)
@@ -606,7 +606,7 @@ static bool checkStaticArray(int &val, const QByteArray &dateString, int at, con
                 val = j;
                 return true;
             }
-            i += strlen(str) + 1;
+            i += int(strlen(str)) + 1;
             ++j;
         }
     }
index c87764b..7d9039e 100644 (file)
@@ -116,7 +116,7 @@ static int hashKword(const char *s, int len)
 
 static void insertKwordIntoHash(const char *s, int number)
 {
-    int k = hashKword(s, strlen(s));
+    int k = hashKword(s, int(strlen(s)));
     while (kwordHashTable[k]) {
         if (++k == KwordHashTableSize)
             k = 0;
@@ -166,7 +166,7 @@ int Tokenizer::getToken()
                 yyCh = getChar();
             } while (isalnum(yyCh) || yyCh == '_');
 
-            int k = hashKword(yyLex, yyLexLen);
+            int k = hashKword(yyLex, int(yyLexLen));
             for (;;) {
                 int i = kwordHashTable[k];
                 if (i == 0) {