Get rid of compiler warnings with MSVC
authorOlivier Goffart <olivier.goffart@nokia.com>
Wed, 27 Jul 2011 17:01:15 +0000 (19:01 +0200)
committerQt by Nokia <qt-info@nokia.com>
Thu, 28 Jul 2011 11:16:50 +0000 (13:16 +0200)
Change-Id: Ibd027c502a5b8bcbfc6dae71c4f244f1080d4064
Reviewed-on: http://codereview.qt.nokia.com/2303
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
src/corelib/tools/qbytearray.cpp
src/corelib/tools/qbytearray.h
src/corelib/tools/qstring.cpp

index 9f21b72..11ebd8a 100644 (file)
@@ -904,7 +904,7 @@ QByteArray &QByteArray::operator=(const char *str)
         x = const_cast<Data *>(&shared_empty.ba);
     } else {
         int len = qstrlen(str);
-        if (d->ref != 1 || len > d->alloc || (len < d->size && len < d->alloc >> 1))
+        if (d->ref != 1 || len > int(d->alloc) || (len < d->size && len < int(d->alloc) >> 1))
             realloc(len);
         x = d;
         memcpy(x->data(), str, len + 1); // include null terminator
@@ -1432,9 +1432,10 @@ void QByteArray::resize(int size)
         x->data()[size] = '\0';
         d = x;
     } else {
-        if (d->ref != 1 || size > d->alloc || (!d->capacityReserved && size < d->size && size < d->alloc >> 1))
+        if (d->ref != 1 || size > int(d->alloc)
+            || (!d->capacityReserved && size < d->size && size < int(d->alloc) >> 1))
             realloc(qAllocMore(size, sizeof(Data)));
-        if (d->alloc >= size) {
+        if (int(d->alloc) >= size) {
             d->size = size;
             d->data()[size] = '\0';
         }
@@ -1563,7 +1564,7 @@ QByteArray &QByteArray::prepend(const char *str)
 QByteArray &QByteArray::prepend(const char *str, int len)
 {
     if (str) {
-        if (d->ref != 1 || d->size + len > d->alloc)
+        if (d->ref != 1 || d->size + len > int(d->alloc))
             realloc(qAllocMore(d->size + len, sizeof(Data)));
         memmove(d->data()+len, d->data(), d->size);
         memcpy(d->data(), str, len);
@@ -1581,7 +1582,7 @@ QByteArray &QByteArray::prepend(const char *str, int len)
 
 QByteArray &QByteArray::prepend(char ch)
 {
-    if (d->ref != 1 || d->size + 1 > d->alloc)
+    if (d->ref != 1 || d->size + 1 > int(d->alloc))
         realloc(qAllocMore(d->size + 1, sizeof(Data)));
     memmove(d->data()+1, d->data(), d->size);
     d->data()[0] = ch;
@@ -1619,7 +1620,7 @@ QByteArray &QByteArray::append(const QByteArray &ba)
     if ((d == &shared_null.ba || d == &shared_empty.ba) && !IS_RAW_DATA(ba.d)) {
         *this = ba;
     } else if (ba.d != &shared_null.ba) {
-        if (d->ref != 1 || d->size + ba.d->size > d->alloc)
+        if (d->ref != 1 || d->size + ba.d->size > int(d->alloc))
             realloc(qAllocMore(d->size + ba.d->size, sizeof(Data)));
         memcpy(d->data() + d->size, ba.d->data(), ba.d->size);
         d->size += ba.d->size;
@@ -1653,7 +1654,7 @@ QByteArray& QByteArray::append(const char *str)
 {
     if (str) {
         int len = qstrlen(str);
-        if (d->ref != 1 || d->size + len > d->alloc)
+        if (d->ref != 1 || d->size + len > int(d->alloc))
             realloc(qAllocMore(d->size + len, sizeof(Data)));
         memcpy(d->data() + d->size, str, len + 1); // include null terminator
         d->size += len;
@@ -1678,7 +1679,7 @@ QByteArray &QByteArray::append(const char *str, int len)
     if (len < 0)
         len = qstrlen(str);
     if (str && len) {
-        if (d->ref != 1 || d->size + len > d->alloc)
+        if (d->ref != 1 || d->size + len > int(d->alloc))
             realloc(qAllocMore(d->size + len, sizeof(Data)));
         memcpy(d->data() + d->size, str, len); // include null terminator
         d->size += len;
@@ -1695,7 +1696,7 @@ QByteArray &QByteArray::append(const char *str, int len)
 
 QByteArray& QByteArray::append(char ch)
 {
-    if (d->ref != 1 || d->size + 1 > d->alloc)
+    if (d->ref != 1 || d->size + 1 > int(d->alloc))
         realloc(qAllocMore(d->size + 1, sizeof(Data)));
     d->data()[d->size++] = ch;
     d->data()[d->size] = '\0';
@@ -2204,7 +2205,7 @@ QByteArray QByteArray::repeated(int times) const
 
     QByteArray result;
     result.reserve(resultSize);
-    if (result.d->alloc != resultSize)
+    if (int(result.d->alloc) != resultSize)
         return QByteArray(); // not enough memory
 
     memcpy(result.d->data(), d->data(), d->size);
index 4190ffa..5cf4c15 100644 (file)
@@ -439,10 +439,10 @@ inline int QByteArray::capacity() const
 { return d->alloc; }
 
 inline void QByteArray::reserve(int asize)
-{ if (d->ref != 1 || asize > d->alloc) realloc(asize); d->capacityReserved = true; }
+{ if (d->ref != 1 || asize > int(d->alloc)) realloc(asize); d->capacityReserved = true; }
 
 inline void QByteArray::squeeze()
-{ if (d->size < d->alloc) realloc(d->size); d->capacityReserved = false; }
+{ if (d->size < int(d->alloc)) realloc(d->size); d->capacityReserved = false; }
 
 class Q_CORE_EXPORT QByteRef {
     QByteArray &a;
index 9e23819..9ce5eea 100644 (file)
@@ -1267,10 +1267,10 @@ void QString::resize(int size)
             QString::free(d);
         d = x;
     } else {
-        if (d->ref != 1 || size > d->alloc ||
-            (!d->capacityReserved && size < d->size && size < d->alloc >> 1))
+        if (d->ref != 1 || size > int(d->alloc) ||
+            (!d->capacityReserved && size < d->size && size < int(d->alloc) >> 1))
             realloc(grow(size));
-        if (d->alloc >= size) {
+        if (int(d->alloc) >= size) {
             d->size = size;
             d->data()[size] = '\0';
         }
@@ -1560,7 +1560,7 @@ QString &QString::append(const QString &str)
         if (d == &shared_null.str) {
             operator=(str);
         } else {
-            if (d->ref != 1 || d->size + str.d->size > d->alloc)
+            if (d->ref != 1 || d->size + str.d->size > int(d->alloc))
                 realloc(grow(d->size + str.d->size));
             memcpy(d->data() + d->size, str.d->data(), str.d->size * sizeof(QChar));
             d->size += str.d->size;
@@ -1580,7 +1580,7 @@ QString &QString::append(const QLatin1String &str)
     const uchar *s = (const uchar *)str.latin1();
     if (s) {
         int len = qstrlen((char *)s);
-        if (d->ref != 1 || d->size + len > d->alloc)
+        if (d->ref != 1 || d->size + len > int(d->alloc))
             realloc(grow(d->size + len));
         ushort *i = d->data() + d->size;
         while ((*i++ = *s++))
@@ -1623,7 +1623,7 @@ QString &QString::append(const QLatin1String &str)
 */
 QString &QString::append(QChar ch)
 {
-    if (d->ref != 1 || d->size + 1 > d->alloc)
+    if (d->ref != 1 || d->size + 1 > int(d->alloc))
         realloc(grow(d->size + 1));
     d->data()[d->size++] = ch.unicode();
     d->data()[d->size] = '\0';
@@ -3550,8 +3550,8 @@ static QByteArray toLatin1_helper(const QChar *data, int length)
             const __m128i questionMark = _mm_set1_epi16('?');
             // SSE has no compare instruction for unsigned comparison.
             // The variables must be shiffted + 0x8000 to be compared
-            const __m128i signedBitOffset = _mm_set1_epi16(0x8000);
-            const __m128i thresholdMask = _mm_set1_epi16(0xff + 0x8000);
+            const __m128i signedBitOffset = _mm_set1_epi16(short(0x8000));
+            const __m128i thresholdMask = _mm_set1_epi16(short(0xff + 0x8000));
             for (int i = 0; i < chunkCount; ++i) {
                 __m128i chunk1 = _mm_loadu_si128((__m128i*)src); // load
                 src += 8;
@@ -6152,7 +6152,7 @@ QString QString::repeated(int times) const
 
     QString result;
     result.reserve(resultSize);
-    if (result.d->alloc != resultSize)
+    if (int(result.d->alloc) != resultSize)
         return QString(); // not enough memory
 
     memcpy(result.d->data(), d->data(), d->size * sizeof(ushort));