From b67c367e0eb81a9062009abb6d5893e91719ca3e Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 28 Sep 2021 15:36:41 +0200 Subject: [PATCH] Tidy up testlib's parsing of -callgrind parameter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Invert a condition to turn a nested if (that was missing one of its layers of braces) into an else-if chain, split some long strings to limit line length. Change-Id: I10d90487a09affe981aa11c3588281aeb3666df5 Reviewed-by: Tor Arne Vestbø Reviewed-by: Thiago Macieira --- src/testlib/qtestcase.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index 8d0d549f17f..9a93c41b5c4 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -734,15 +734,18 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, const char *const argv[], bool QTest::noCrashHandler = true; #if QT_CONFIG(valgrind) } else if (strcmp(argv[i], "-callgrind") == 0) { - if (QBenchmarkValgrindUtils::haveValgrind()) - if (QFileInfo(QDir::currentPath()).isWritable()) { - QBenchmarkGlobalData::current->setMode(QBenchmarkGlobalData::CallgrindParentProcess); - } else { - fprintf(stderr, "WARNING: Current directory not writable. Using the walltime measurer.\n"); - } - else { - fprintf(stderr, "WARNING: Valgrind not found or too old. Make sure it is installed and in your path. " - "Using the walltime measurer.\n"); + if (!QBenchmarkValgrindUtils::haveValgrind()) { + fprintf(stderr, + "WARNING: Valgrind not found or too old. " + "Make sure it is installed and in your path. " + "Using the walltime measurer.\n"); + } else if (QFileInfo(QDir::currentPath()).isWritable()) { + QBenchmarkGlobalData::current->setMode( + QBenchmarkGlobalData::CallgrindParentProcess); + } else { + fprintf(stderr, + "WARNING: Current directory not writable. " + "Using the walltime measurer.\n"); } } else if (strcmp(argv[i], "-callgrindchild") == 0) { // "private" option QBenchmarkGlobalData::current->setMode(QBenchmarkGlobalData::CallgrindChildProcess);