From c7453cf6767d5be43de878291e7eff371f200b4d Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 1 Nov 2018 09:58:40 +0100 Subject: [PATCH] Testlib: Explicitly cast messages to const char * MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Macro parameters should always be enclosed in braces when used. Plain C strings passed in parantheses are interpreted as const char[], at least by clang-tidy. Implicitly decaying arrays into pointers should be avoided and clang-tidy warns about this. Avoid both problems by always static casting all messages to const char *. Change-Id: I2be668169bec2823f69af3aa75086a31b0b31938 Reviewed-by: Friedemann Kleint Reviewed-by: Mitch Curtis Reviewed-by: Tor Arne Vestbø Reviewed-by: Edward Welbourne --- src/testlib/qtestcase.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/testlib/qtestcase.h b/src/testlib/qtestcase.h index f6891dc941..a6f1711230 100644 --- a/src/testlib/qtestcase.h +++ b/src/testlib/qtestcase.h @@ -67,17 +67,17 @@ do {\ #define QFAIL(message) \ do {\ - QTest::qFail(message, __FILE__, __LINE__);\ + QTest::qFail(static_cast(message), __FILE__, __LINE__);\ return;\ } while (false) #define QVERIFY2(statement, description) \ do {\ if (statement) {\ - if (!QTest::qVerify(true, #statement, (description), __FILE__, __LINE__))\ + if (!QTest::qVerify(true, #statement, static_cast(description), __FILE__, __LINE__))\ return;\ } else {\ - if (!QTest::qVerify(false, #statement, (description), __FILE__, __LINE__))\ + if (!QTest::qVerify(false, #statement, static_cast(description), __FILE__, __LINE__))\ return;\ }\ } while (false) @@ -184,7 +184,7 @@ do { \ #define QSKIP_INTERNAL(statement) \ do {\ - QTest::qSkip(statement, __FILE__, __LINE__);\ + QTest::qSkip(static_cast(statement), __FILE__, __LINE__);\ return;\ } while (false) @@ -200,7 +200,7 @@ do {\ #define QEXPECT_FAIL(dataIndex, comment, mode)\ do {\ - if (!QTest::qExpectFail(dataIndex, comment, QTest::mode, __FILE__, __LINE__))\ + if (!QTest::qExpectFail(dataIndex, static_cast(comment), QTest::mode, __FILE__, __LINE__))\ return;\ } while (false) @@ -217,7 +217,7 @@ do {\ } while (false) #define QWARN(msg)\ - QTest::qWarn(msg, __FILE__, __LINE__) + QTest::qWarn(static_cast(msg), __FILE__, __LINE__) #ifdef QT_TESTCASE_BUILDDIR # define QFINDTESTDATA(basepath)\