From f8a5bb3c3213d03c12093998752c22cf67d5501c Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 30 Sep 2021 12:52:15 +0200 Subject: [PATCH] Use %.6g rather than %s and QByteArray::number() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The comment against the use of this claimed qvsnprintf() lacks 64-bit support, which is probably untrue by now but certainly irrelevant as the value being formatted is a qreal, not a 64-bit integral type. Since %g wants a double, make the value passed explicitly double by casting its denominator. Casting its numerator to qreal was superfluous as that's its type already. Change-Id: I5ff885fbeb9b638b2b0507061e0a19e3b8522143 Reviewed-by: Thiago Macieira Reviewed-by: Tor Arne Vestbø --- src/testlib/qxmltestlogger.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/testlib/qxmltestlogger.cpp b/src/testlib/qxmltestlogger.cpp index 716a99d80d..89c4cbb765 100644 --- a/src/testlib/qxmltestlogger.cpp +++ b/src/testlib/qxmltestlogger.cpp @@ -198,7 +198,7 @@ static const char *incidentFormatString(bool noDescription, bool noTag) static const char *benchmarkResultFormatString() { - return "\n"; + return "\n"; } static const char *messageFormatString(bool noDescription, bool noTag) @@ -266,13 +266,12 @@ void QXmlTestLogger::addBenchmarkResult(const QBenchmarkResult &result) benchmarkMetricName(result.metric)); xmlQuote("edTag, result.context.tag.toUtf8().constData()); - const qreal valuePerIteration = qreal(result.value) / qreal(result.iterations); QTest::qt_asprintf( &buf, QTest::benchmarkResultFormatString(), quotedMetric.constData(), quotedTag.constData(), - QByteArray::number(valuePerIteration).constData(), //no 64-bit qsnprintf support + result.value / double(result.iterations), result.iterations); outputString(buf.constData()); }