Fix some compiler warnings in tests.
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>
Fri, 23 Mar 2012 10:44:19 +0000 (11:44 +0100)
committerQt by Nokia <qt-info@nokia.com>
Tue, 27 Mar 2012 14:35:39 +0000 (16:35 +0200)
- Unused variables
- Deprecated conversion from const char * to char *.

Change-Id: Iea0b9c4613ea74cead6d95ba12ad1028f531cbff
Reviewed-by: Jason McDonald <jason.mcdonald@nokia.com>
tests/auto/corelib/tools/qstring/tst_qstring.cpp
tests/auto/network/socket/qlocalsocket/example/server/main.cpp
tests/auto/testlib/selftests/differentexec/tst_differentexec.cpp
tests/auto/testlib/selftests/strcmp/tst_strcmp.cpp
tests/auto/tools/qmake/testcompiler.cpp
tests/auto/widgets/graphicsview/qgraphicslayoutitem/tst_qgraphicslayoutitem.cpp
tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
tests/auto/xml/sax/qxmlinputsource/tst_qxmlinputsource.cpp

index f007d44..4eabd61 100644 (file)
@@ -718,6 +718,11 @@ void tst_QString::acc_01()
     }
 }
 
+#ifdef Q_CC_GNU
+#    pragma GCC diagnostic push
+#    pragma GCC diagnostic ignored "-Wformat-security"
+#endif
+
 void tst_QString::isNull()
 {
     QString a;
@@ -728,6 +733,10 @@ void tst_QString::isNull()
     QVERIFY(!a.isNull());
 }
 
+#ifdef Q_CC_GNU
+#    pragma GCC diagnostic pop
+#endif
+
 void tst_QString::isEmpty()
 {
     QString a;
index d066e4e..909bb68 100644 (file)
@@ -72,7 +72,7 @@ public:
             if (n == 0)
                 break;
            qDebug() << "Read" << str;
-            if ("exit" == str)
+            if (!qstrcmp(str, "exit"))
                 qApp->quit();
 
             if (socket->write(str, 100) < 0) {
index 91b14e5..f32a5e7 100644 (file)
@@ -76,7 +76,7 @@ private slots:
 
 int main()
 {
-    char *argv[] = {"appName", "slotName"};
+    char *argv[] = { const_cast<char *>("appName"), const_cast<char *>("slotName") };
     int argc = 2;
 
     tst_TestA testA;
index 20bfc22..73de6df 100644 (file)
@@ -65,7 +65,7 @@ void tst_StrCmp::compareCharStars() const
     QCOMPARE(str1, "foo");
     QCOMPARE(str1, str1);
 
-    char *str2 = "foo";
+    char *str2 = const_cast<char *>("foo");
     QCOMPARE("foo", str2);
     QCOMPARE(str2, "foo");
     QCOMPARE(str2, str2);
@@ -88,8 +88,8 @@ void tst_StrCmp::compareByteArray() const
     QCOMPARE(ba.constData(), "bar");
     QCOMPARE(ba.constData(), "foo");
 
-    char *bar = "bar";
-    char *foo = "foo";
+    char *bar = const_cast<char *>("bar");
+    char *foo = const_cast<char *>("foo");
 
     QEXPECT_FAIL("", "Next test should fail", Continue);
     QCOMPARE(ba.data(), bar);
index 4e5dc26..3b77b1e 100644 (file)
@@ -128,7 +128,7 @@ TestCompiler::~TestCompiler()
 
 bool TestCompiler::errorOut()
 {
-    qDebug(qPrintable(testOutput_.join("\n")));
+    qDebug("%s", qPrintable(testOutput_.join(QStringLiteral("\n"))));
     return false;
 }
 
index acb9155..4f15f96 100644 (file)
@@ -287,17 +287,15 @@ void tst_QGraphicsLayoutItem::setMaximumSize()
 void tst_QGraphicsLayoutItem::setMinimumSize_data()
 {
     QTest::addColumn<QSizeF>("size");
-    QTest::addColumn<QSizeF>("outputSize");
-    QTest::newRow("-1") << QSizeF(-1, -1) << QSizeF(0, 0);
-    QTest::newRow("0") << QSizeF(0, 0) << QSizeF(0, 0);
-    QTest::newRow("10") << QSizeF(10, 10) << QSizeF(10, 10);
+    QTest::newRow("-1") << QSizeF(-1, -1);
+    QTest::newRow("0") << QSizeF(0, 0);
+    QTest::newRow("10") << QSizeF(10, 10);
 }
 
 // void setMinimumSize(QSizeF const& size) public
 void tst_QGraphicsLayoutItem::setMinimumSize()
 {
     QFETCH(QSizeF, size);
-    QFETCH(QSizeF, outputSize);
     SubQGraphicsLayoutItem layoutItem;
     QSizeF oldSize = layoutItem.minimumSize();
 
index be7c58f..c6c8131 100644 (file)
@@ -238,10 +238,9 @@ public:
         openedEditor = new QWidget(parent);
         return openedEditor;
     }
-    void destroyEditor(QWidget *editor, const QModelIndex &index) const
+    void destroyEditor(QWidget *editor, const QModelIndex &) const
     {
         calledVirtualDtor = true;
-        // QAbstractItemDelegate::destroyEditor(editor,index);
         editor->deleteLater();
     }
 
index f93d979..d8b193f 100644 (file)
@@ -118,9 +118,9 @@ class ServerAndClient : public QObject
 public:
     ServerAndClient(QEventLoop &ev) : success(false)
                                     , eventLoop(ev)
-                                    , isBody(false)
                                     , bodyBytesRead(0)
                                     , bodyLength(-1)
+                                    , isBody(false)
     {
         setObjectName("serverAndClient");
         tcpServer = new QTcpServer(this);