QTestLib: Fix various clang warnings
- Fix else after return/break - Fix use of int as boolean literal - Use range-based for in some cases - Avoid copies by using const-ref - Remove unnecessary null-check before delete Task-number: QTBUG-69413 Change-Id: I69f46e6deaa55ef70a8b3a61e6539c79a64aaa23 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
parent
afb8ba3fd2
commit
111df3b5e0
@ -66,8 +66,7 @@ void QBenchmarkGlobalData::setMode(Mode mode)
|
||||
{
|
||||
mode_ = mode;
|
||||
|
||||
if (measurer)
|
||||
delete measurer;
|
||||
delete measurer;
|
||||
measurer = createMeasurer();
|
||||
}
|
||||
|
||||
@ -98,11 +97,8 @@ QBenchmarkMeasurerBase * QBenchmarkGlobalData::createMeasurer()
|
||||
|
||||
int QBenchmarkGlobalData::adjustMedianIterationCount()
|
||||
{
|
||||
if (medianIterationCount != -1) {
|
||||
return medianIterationCount;
|
||||
} else {
|
||||
return measurer->adjustMedianCount(1);
|
||||
}
|
||||
return medianIterationCount != -1
|
||||
? medianIterationCount : measurer->adjustMedianCount(1);
|
||||
}
|
||||
|
||||
|
||||
|
@ -66,7 +66,7 @@ public:
|
||||
virtual bool isMeasurementAccepted(qint64 measurement) = 0;
|
||||
virtual int adjustIterationCount(int suggestion) = 0;
|
||||
virtual int adjustMedianCount(int suggestion) = 0;
|
||||
virtual bool repeatCount() { return 1; }
|
||||
virtual bool repeatCount() { return true; }
|
||||
virtual bool needsWarmupIteration() { return false; }
|
||||
virtual QTest::QBenchmarkMetric metricType() = 0;
|
||||
};
|
||||
|
@ -67,7 +67,7 @@ public:
|
||||
bool isMeasurementAccepted(qint64 measurement) override;
|
||||
int adjustIterationCount(int suggestion) override;
|
||||
int adjustMedianCount(int suggestion) override;
|
||||
bool repeatCount() override { return 1; }
|
||||
bool repeatCount() override { return true; }
|
||||
bool needsWarmupIteration() override { return true; }
|
||||
QTest::QBenchmarkMetric metricType() override;
|
||||
|
||||
|
@ -168,7 +168,7 @@ QString QBenchmarkValgrindUtils::outFileBase(qint64 pid)
|
||||
// Returns \c true upon success, otherwise false.
|
||||
bool QBenchmarkValgrindUtils::runCallgrindSubProcess(const QStringList &origAppArgs, int &exitCode)
|
||||
{
|
||||
const QString execFile(origAppArgs.at(0));
|
||||
const QString &execFile = origAppArgs.at(0);
|
||||
QStringList args;
|
||||
args << QLatin1String("--tool=callgrind") << QLatin1String("--instr-atstart=yes")
|
||||
<< QLatin1String("--quiet")
|
||||
@ -177,7 +177,7 @@ bool QBenchmarkValgrindUtils::runCallgrindSubProcess(const QStringList &origAppA
|
||||
// pass on original arguments that make sense (e.g. avoid wasting time producing output
|
||||
// that will be ignored anyway) ...
|
||||
for (int i = 1; i < origAppArgs.size(); ++i) {
|
||||
const QString arg(origAppArgs.at(i));
|
||||
const QString &arg = origAppArgs.at(i);
|
||||
if (arg == QLatin1String("-callgrind"))
|
||||
continue;
|
||||
args << arg; // ok to pass on
|
||||
|
@ -222,9 +222,7 @@ QString QTeamCityLogger::tcEscapedString(const QString &str) const
|
||||
{
|
||||
QString formattedString;
|
||||
|
||||
for (int i = 0; i < str.length(); i++) {
|
||||
QChar ch = str.at(i);
|
||||
|
||||
for (QChar ch : str) {
|
||||
switch (ch.toLatin1()) {
|
||||
case '\n':
|
||||
formattedString.append(QLatin1String("|n"));
|
||||
|
@ -210,11 +210,10 @@ static bool checkCondition(const QByteArray &condition)
|
||||
static const QSet<QByteArray> matchedConditions = activeConditions();
|
||||
QList<QByteArray> conds = condition.split(' ');
|
||||
|
||||
for (int i = 0; i < conds.size(); ++i) {
|
||||
QByteArray c = conds.at(i);
|
||||
for (QByteArray c : conds) {
|
||||
bool result = c.startsWith('!');
|
||||
if (result)
|
||||
c = c.mid(1);
|
||||
c.remove(0, 1);
|
||||
|
||||
result ^= matchedConditions.contains(c);
|
||||
if (!result)
|
||||
|
@ -1040,7 +1040,7 @@ public:
|
||||
void run() override {
|
||||
QMutexLocker locker(&mutex);
|
||||
waitCondition.wakeAll();
|
||||
while (1) {
|
||||
while (true) {
|
||||
int t = timeout.loadRelaxed();
|
||||
if (!t)
|
||||
break;
|
||||
@ -1273,10 +1273,8 @@ char *toHexRepresentation(const char *ba, int length)
|
||||
++o;
|
||||
if (i == len)
|
||||
break;
|
||||
else {
|
||||
result[o] = ' ';
|
||||
++o;
|
||||
}
|
||||
result[o] = ' ';
|
||||
++o;
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -180,23 +180,20 @@ inline static bool isEmpty(const char *str)
|
||||
static const char *incidentFormatString(bool noDescription, bool noTag)
|
||||
{
|
||||
if (noDescription) {
|
||||
if (noTag)
|
||||
return "<Incident type=\"%s\" file=\"%s\" line=\"%d\" />\n";
|
||||
else
|
||||
return "<Incident type=\"%s\" file=\"%s\" line=\"%d\">\n"
|
||||
return noTag
|
||||
? "<Incident type=\"%s\" file=\"%s\" line=\"%d\" />\n"
|
||||
: "<Incident type=\"%s\" file=\"%s\" line=\"%d\">\n"
|
||||
" <DataTag><![CDATA[%s%s%s%s]]></DataTag>\n"
|
||||
"</Incident>\n";
|
||||
} else {
|
||||
if (noTag)
|
||||
return "<Incident type=\"%s\" file=\"%s\" line=\"%d\">\n"
|
||||
" <Description><![CDATA[%s%s%s%s]]></Description>\n"
|
||||
"</Incident>\n";
|
||||
else
|
||||
return "<Incident type=\"%s\" file=\"%s\" line=\"%d\">\n"
|
||||
" <DataTag><![CDATA[%s%s%s]]></DataTag>\n"
|
||||
" <Description><![CDATA[%s]]></Description>\n"
|
||||
"</Incident>\n";
|
||||
}
|
||||
return noTag
|
||||
? "<Incident type=\"%s\" file=\"%s\" line=\"%d\">\n"
|
||||
" <Description><![CDATA[%s%s%s%s]]></Description>\n"
|
||||
"</Incident>\n"
|
||||
: "<Incident type=\"%s\" file=\"%s\" line=\"%d\">\n"
|
||||
" <DataTag><![CDATA[%s%s%s]]></DataTag>\n"
|
||||
" <Description><![CDATA[%s]]></Description>\n"
|
||||
"</Incident>\n";
|
||||
}
|
||||
|
||||
static const char *benchmarkResultFormatString()
|
||||
|
Loading…
x
Reference in New Issue
Block a user