summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>2012-04-17 17:26:29 +0200
committerQt by Nokia <qt-info@nokia.com>2012-04-20 12:46:47 +0200
commit6331894524911f28f7b29333e3e5cdbcca5b5e8f (patch)
tree5bae8332f1c8315bbda155a2bfd538d3a245d27c /src/corelib/tools
parenta8a5b38b000ee8d4eed099bfc0a8a3528df6ad17 (diff)
Fix MSVC conversion warnings in new bytearray code.
Change-Id: Ifc81564daf3fef0d7f08ae8d250ba41d3b1d5b0f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Diffstat (limited to 'src/corelib/tools')
-rw-r--r--src/corelib/tools/qarraydata.cpp2
-rw-r--r--src/corelib/tools/qarraydata.h2
-rw-r--r--src/corelib/tools/qbytearray.cpp21
3 files changed, 13 insertions, 12 deletions
diff --git a/src/corelib/tools/qarraydata.cpp b/src/corelib/tools/qarraydata.cpp
index f1b88d5051..328d39cde9 100644
--- a/src/corelib/tools/qarraydata.cpp
+++ b/src/corelib/tools/qarraydata.cpp
@@ -82,7 +82,7 @@ QArrayData *QArrayData::allocate(size_t objectSize, size_t alignment,
// Allocate additional space if array is growing
if (options & Grow)
- capacity = qAllocMore(objectSize * capacity, headerSize) / objectSize;
+ capacity = qAllocMore(objectSize * capacity, headerSize) / int(objectSize);
size_t allocSize = headerSize + objectSize * capacity;
diff --git a/src/corelib/tools/qarraydata.h b/src/corelib/tools/qarraydata.h
index 78fbc9cf32..4d79c92cec 100644
--- a/src/corelib/tools/qarraydata.h
+++ b/src/corelib/tools/qarraydata.h
@@ -169,7 +169,7 @@ struct QTypedArrayData
result->offset = reinterpret_cast<const char *>(data)
- reinterpret_cast<const char *>(result);
- result->size = n;
+ result->size = int(n);
}
return result;
}
diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp
index 42150efd63..b5e7f285ad 100644
--- a/src/corelib/tools/qbytearray.cpp
+++ b/src/corelib/tools/qbytearray.cpp
@@ -131,7 +131,7 @@ char *qstrcpy(char *dst, const char *src)
if (!src)
return 0;
#if defined(_MSC_VER) && _MSC_VER >= 1400
- int len = strlen(src);
+ const int len = int(strlen(src));
// This is actually not secure!!! It will be fixed
// properly in a later release!
if (len >= 0 && strcpy_s(dst, len+1, src) == 0)
@@ -914,12 +914,13 @@ QByteArray &QByteArray::operator=(const char *str)
} else if (!*str) {
x = Data::allocate(0);
} else {
- int len = strlen(str);
- if (d->ref.isShared() || uint(len) + 1u > d->alloc
- || (len < d->size && uint(len) + 1u < uint(d->alloc >> 1)))
- reallocData(uint(len) + 1u, d->detachFlags());
+ const int len = int(strlen(str));
+ const uint fullLen = len + 1;
+ if (d->ref.isShared() || fullLen > d->alloc
+ || (len < d->size && fullLen < uint(d->alloc >> 1)))
+ reallocData(fullLen, d->detachFlags());
x = d;
- memcpy(x->data(), str, uint(len) + 1u); // include null terminator
+ memcpy(x->data(), str, fullLen); // include null terminator
x->size = len;
}
x->ref.ref();
@@ -1322,7 +1323,7 @@ QByteArray::QByteArray(const char *data, int size)
d = Data::sharedNull();
} else {
if (size < 0)
- size = strlen(data);
+ size = int(strlen(data));
if (!size) {
d = Data::allocate(0);
} else {
@@ -1631,7 +1632,7 @@ QByteArray &QByteArray::append(const QByteArray &ba)
QByteArray& QByteArray::append(const char *str)
{
if (str) {
- int len = strlen(str);
+ const int len = int(strlen(str));
if (d->ref.isShared() || uint(d->size + len) + 1u > d->alloc)
reallocData(uint(d->size + len) + 1u, d->detachFlags() | Data::Grow);
memcpy(d->data() + d->size, str, len + 1); // include null terminator
@@ -2515,7 +2516,7 @@ bool QByteArray::startsWith(const char *str) const
{
if (!str || !*str)
return true;
- int len = strlen(str);
+ const int len = int(strlen(str));
if (d->size < len)
return false;
return qstrncmp(d->data(), str, len) == 0;
@@ -2560,7 +2561,7 @@ bool QByteArray::endsWith(const char *str) const
{
if (!str || !*str)
return true;
- int len = strlen(str);
+ const int len = int(strlen(str));
if (d->size < len)
return false;
return qstrncmp(d->data() + d->size - len, str, len) == 0;