From a670a00aed4dbc9601df62c1ffd15352f6787bb6 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Mon, 11 Jul 2022 12:22:11 +0200 Subject: [PATCH] Skip semicolon after uses of QTRY_IMPL() and QTRY_LOOP_IMPL() The macros' expansions end with an if-block and a for-block, respectively, so the following semicolon is superfluous. Since we control these macros' use (they're internals), just skip the semicolons, rather than wrapping their bodies in do-while(0). Pick-to: 6.4 Change-Id: I53f7786a66a0dc7709ac9f96d49985edafceec39 Reviewed-by: Ivan Solovev Reviewed-by: Mitch Curtis --- src/testlib/qtestcase.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/testlib/qtestcase.h b/src/testlib/qtestcase.h index 3103cdc41c0..ad941d2ba30 100644 --- a/src/testlib/qtestcase.h +++ b/src/testlib/qtestcase.h @@ -163,10 +163,11 @@ inline void useVerifyThrowsException() {} && !(expr); qt_test_i += step) { \ QTest::qWait(step); \ } +// Ends in a for-block, so doesn't want a following semicolon. #define QTRY_TIMEOUT_DEBUG_IMPL(expr, timeoutValue, step) \ if (!QTest::currentTestFailed() && !(expr)) { \ - QTRY_LOOP_IMPL((expr), 2 * (timeoutValue), step); \ + QTRY_LOOP_IMPL((expr), 2 * (timeoutValue), step) \ if (expr) { \ QFAIL(qPrintable(QTest::Internal::formatTryTimeoutDebugMessage(\ u8"" #expr, timeoutValue, timeoutValue + qt_test_i))); \ @@ -176,13 +177,14 @@ inline void useVerifyThrowsException() {} #define QTRY_IMPL(expr, timeout)\ const int qt_test_step = timeout < 350 ? timeout / 7 + 1 : 50; \ const int qt_test_timeoutValue = timeout; \ - { QTRY_LOOP_IMPL((expr), qt_test_timeoutValue, qt_test_step); } \ + { QTRY_LOOP_IMPL((expr), qt_test_timeoutValue, qt_test_step) } \ QTRY_TIMEOUT_DEBUG_IMPL((expr), qt_test_timeoutValue, qt_test_step) +// Ends with an if-block, so doesn't want a following semicolon. // Will try to wait for the expression to become true while allowing event processing #define QTRY_VERIFY_WITH_TIMEOUT(expr, timeout) \ do { \ - QTRY_IMPL((expr), timeout);\ + QTRY_IMPL((expr), timeout) \ QVERIFY(expr); \ } while (false) @@ -191,7 +193,7 @@ do { \ // Will try to wait for the expression to become true while allowing event processing #define QTRY_VERIFY2_WITH_TIMEOUT(expr, messageExpression, timeout) \ do { \ - QTRY_IMPL((expr), timeout);\ + QTRY_IMPL((expr), timeout) \ QVERIFY2(expr, messageExpression); \ } while (false) @@ -200,7 +202,7 @@ do { \ // Will try to wait for the comparison to become successful while allowing event processing #define QTRY_COMPARE_WITH_TIMEOUT(expr, expected, timeout) \ do { \ - QTRY_IMPL(((expr) == (expected)), timeout);\ + QTRY_IMPL(((expr) == (expected)), timeout) \ QCOMPARE((expr), expected); \ } while (false) @@ -208,7 +210,7 @@ do { \ #define QTRY_COMPARE_OP_WITH_TIMEOUT_IMPL(left, right, op, opId, timeout) \ do { \ - QTRY_IMPL(((left) op (right)), timeout); \ + QTRY_IMPL(((left) op (right)), timeout) \ QCOMPARE_OP_IMPL(left, right, op, opId); \ } while (false)