Fix some warnings from clang
authorLars Knoll <lars.knoll@nokia.com>
Wed, 1 Feb 2012 16:04:19 +0000 (17:04 +0100)
committerQt by Nokia <qt-info@nokia.com>
Thu, 2 Feb 2012 00:56:03 +0000 (01:56 +0100)
One of them was a real error, that could
lead to Data::alloc containing wrong values.

Change-Id: I48315ef6fd59188630107ebbe7bf8dbaa5da689e
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
src/corelib/json/qjson.cpp
src/corelib/json/qjsonarray.cpp
src/corelib/json/qjsonwriter.cpp

index e8c2712..4f7372a 100644 (file)
@@ -127,7 +127,7 @@ void Data::compact()
 
     free(header);
     header = h;
-    alloc = alloc;
+    this->alloc = alloc;
     compactionCounter = 0;
 }
 
index ad9ca7b..0eb1974 100644 (file)
@@ -257,7 +257,7 @@ void QJsonArray::prepend(const QJsonValue &value)
  */
 void QJsonArray::append(const QJsonValue &value)
 {
-    insert(a ? a->length : 0, value);
+    insert(a ? (int)a->length : 0, value);
 }
 
 /*!
@@ -330,7 +330,7 @@ QJsonValue QJsonArray::takeAt(int i)
  */
 void QJsonArray::insert(int i, const QJsonValue &value)
 {
-    Q_ASSERT (i >= 0 && i <= (int)(a ? a->length : 0));
+    Q_ASSERT (i >= 0 && i <= (a ? (int)a->length : 0));
 
     bool compressed;
     int valueSize = QJsonPrivate::Value::requiredStorage(value, &compressed);
index aa6dc5d..d544e61 100644 (file)
@@ -261,7 +261,7 @@ static void objectContentToJson(const QJsonPrivate::Object *o, QByteArray &json,
 
 void Writer::objectToJson(const QJsonPrivate::Object *o, QByteArray &json, int indent, bool compact)
 {
-    json.reserve(json.size() + (o ? o->size : 16));
+    json.reserve(json.size() + (o ? (int)o->size : 16));
     json += compact ? "{" : "{\n";
     objectContentToJson(o, json, indent + (compact ? 0 : 1), compact);
     json += QByteArray(4*indent, ' ');
@@ -270,7 +270,7 @@ void Writer::objectToJson(const QJsonPrivate::Object *o, QByteArray &json, int i
 
 void Writer::arrayToJson(const QJsonPrivate::Array *a, QByteArray &json, int indent, bool compact)
 {
-    json.reserve(json.size() + (a ? a->size : 16));
+    json.reserve(json.size() + (a ? (int)a->size : 16));
     json += compact ? "[" : "[\n";
     arrayContentToJson(a, json, indent + (compact ? 0 : 1), compact);
     json += QByteArray(4*indent, ' ');