Fix warnings in benchmarks from QFile::open being [[nodiscard]]
Pick-to: 6.5 Change-Id: I8a80af3614a92645be2d64d02ce81e9d263468c8 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit 1c3ee86f183d46709c070ccd44970e05dc70f83d) Reviewed-by: Marc Mutz <marc.mutz@qt.io> (cherry picked from commit 288ef3479eb261f8afa15c4c0f28bdd0fed59982) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
d822091039
commit
e1d742ae3b
@ -29,7 +29,7 @@ public slots:
|
||||
|
||||
for (uint i=0; i<10000; ++i) {
|
||||
QFile file(testdir.absolutePath() + "/testfile_" + QString::number(i));
|
||||
file.open(QIODevice::WriteOnly);
|
||||
QVERIFY2(file.open(QIODevice::WriteOnly), qPrintable(file.fileName()));
|
||||
}
|
||||
}
|
||||
void cleanupTestCase()
|
||||
|
@ -226,7 +226,7 @@ void tst_qfile::readBigFile()
|
||||
switch (testType) {
|
||||
case QFileBenchmark: {
|
||||
QFile file(tempDir.filename);
|
||||
file.open(QIODevice::ReadOnly|textMode|bufferedMode);
|
||||
Q_UNUSED(file.open(QIODevice::ReadOnly|textMode|bufferedMode));
|
||||
QBENCHMARK {
|
||||
while(!file.atEnd())
|
||||
file.read(blockSize);
|
||||
@ -238,7 +238,7 @@ void tst_qfile::readBigFile()
|
||||
#ifdef QT_BUILD_INTERNAL
|
||||
case QFSFileEngineBenchmark: {
|
||||
QFSFileEngine fse(tempDir.filename);
|
||||
fse.open(QIODevice::ReadOnly | textMode | bufferedMode, std::nullopt);
|
||||
Q_UNUSED(fse.open(QIODevice::ReadOnly | textMode | bufferedMode, std::nullopt));
|
||||
QBENCHMARK {
|
||||
//qWarning() << fse.supportsExtension(QAbstractFileEngine::AtEndExtension);
|
||||
while (fse.read(buffer, blockSize)) {}
|
||||
@ -313,7 +313,7 @@ void tst_qfile::seek()
|
||||
switch (testType) {
|
||||
case QFileBenchmark: {
|
||||
QFile file(tempDir.filename);
|
||||
file.open(QIODevice::ReadOnly);
|
||||
Q_UNUSED(file.open(QIODevice::ReadOnly));
|
||||
QBENCHMARK {
|
||||
i=(i+1)%sp_size;
|
||||
file.seek(seekpos[i]);
|
||||
@ -324,7 +324,7 @@ void tst_qfile::seek()
|
||||
#ifdef QT_BUILD_INTERNAL
|
||||
case QFSFileEngineBenchmark: {
|
||||
QFSFileEngine fse(tempDir.filename);
|
||||
fse.open(QIODevice::ReadOnly | QIODevice::Unbuffered, std::nullopt);
|
||||
Q_UNUSED(fse.open(QIODevice::ReadOnly | QIODevice::Unbuffered, std::nullopt));
|
||||
QBENCHMARK {
|
||||
i=(i+1)%sp_size;
|
||||
fse.seek(seekpos[i]);
|
||||
@ -392,7 +392,7 @@ void tst_qfile::open()
|
||||
case QFileBenchmark: {
|
||||
QBENCHMARK {
|
||||
QFile file(tempDir.filename);
|
||||
file.open(QIODevice::ReadOnly);
|
||||
Q_UNUSED(file.open(QIODevice::ReadOnly));
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
@ -401,7 +401,7 @@ void tst_qfile::open()
|
||||
case QFSFileEngineBenchmark: {
|
||||
QBENCHMARK {
|
||||
QFSFileEngine fse(tempDir.filename);
|
||||
fse.open(QIODevice::ReadOnly | QIODevice::Unbuffered, std::nullopt);
|
||||
Q_UNUSED(fse.open(QIODevice::ReadOnly | QIODevice::Unbuffered, std::nullopt));
|
||||
fse.close();
|
||||
}
|
||||
}
|
||||
@ -503,7 +503,7 @@ void tst_qfile::readSmallFiles()
|
||||
QList<QFile*> fileList;
|
||||
for (const QString &file : files) {
|
||||
QFile *f = new QFile(tempDir.filePath(file));
|
||||
f->open(QIODevice::ReadOnly|textMode|bufferedMode);
|
||||
Q_UNUSED(f->open(QIODevice::ReadOnly|textMode|bufferedMode));
|
||||
fileList.append(f);
|
||||
}
|
||||
|
||||
@ -525,7 +525,7 @@ void tst_qfile::readSmallFiles()
|
||||
QList<QFSFileEngine*> fileList;
|
||||
for (const QString &file : files) {
|
||||
QFSFileEngine *fse = new QFSFileEngine(tempDir.filePath(file));
|
||||
fse->open(QIODevice::ReadOnly | textMode | bufferedMode, std::nullopt);
|
||||
Q_UNUSED(fse->open(QIODevice::ReadOnly | textMode | bufferedMode, std::nullopt));
|
||||
fileList.append(fse);
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ void tst_QIODevice::read_old()
|
||||
|
||||
{
|
||||
QFile file(name);
|
||||
file.open(QIODevice::WriteOnly);
|
||||
Q_UNUSED(file.open(QIODevice::WriteOnly));
|
||||
file.seek(size);
|
||||
file.write("x", 1);
|
||||
file.close();
|
||||
@ -49,7 +49,7 @@ void tst_QIODevice::read_old()
|
||||
|
||||
QBENCHMARK {
|
||||
QFile file(name);
|
||||
file.open(QIODevice::ReadOnly);
|
||||
Q_UNUSED(file.open(QIODevice::ReadOnly));
|
||||
QByteArray ba;
|
||||
qint64 s = size - 1024;
|
||||
file.seek(512);
|
||||
@ -70,7 +70,7 @@ void tst_QIODevice::peekAndRead()
|
||||
|
||||
{
|
||||
QFile file(name);
|
||||
file.open(QIODevice::WriteOnly);
|
||||
Q_UNUSED(file.open(QIODevice::WriteOnly));
|
||||
file.seek(size);
|
||||
file.write("x", 1);
|
||||
file.close();
|
||||
@ -78,7 +78,7 @@ void tst_QIODevice::peekAndRead()
|
||||
|
||||
QBENCHMARK {
|
||||
QFile file(name);
|
||||
file.open(QIODevice::ReadOnly);
|
||||
Q_UNUSED(file.open(QIODevice::ReadOnly));
|
||||
|
||||
QByteArray ba(size / 1024, Qt::Uninitialized);
|
||||
while (!file.atEnd()) {
|
||||
|
@ -34,7 +34,7 @@ void tst_QTemporaryFile::openclose()
|
||||
QBENCHMARK {
|
||||
for (qint64 i = 0; i < amount; ++i) {
|
||||
QTemporaryFile file;
|
||||
file.open();
|
||||
Q_UNUSED(file.open());
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
@ -50,7 +50,7 @@ void tst_QTemporaryFile::readwrite()
|
||||
QBENCHMARK {
|
||||
for (qint64 i = 0; i < amount; ++i) {
|
||||
QTemporaryFile file;
|
||||
file.open();
|
||||
Q_UNUSED(file.open());
|
||||
file.write(data);
|
||||
file.seek(0);
|
||||
file.read(dataSize);
|
||||
|
@ -56,7 +56,7 @@ void BenchmarkQtJson::parseNumbers()
|
||||
QString testFile = QFINDTESTDATA("numbers.json");
|
||||
QVERIFY2(!testFile.isEmpty(), "cannot find test file numbers.json!");
|
||||
QFile file(testFile);
|
||||
file.open(QFile::ReadOnly);
|
||||
QVERIFY2(file.open(QFile::ReadOnly), "cannot open test file number.json!");
|
||||
QByteArray testJson = file.readAll();
|
||||
|
||||
QBENCHMARK {
|
||||
@ -70,7 +70,7 @@ void BenchmarkQtJson::parseJson()
|
||||
QString testFile = QFINDTESTDATA("test.json");
|
||||
QVERIFY2(!testFile.isEmpty(), "cannot find test file test.json!");
|
||||
QFile file(testFile);
|
||||
file.open(QFile::ReadOnly);
|
||||
QVERIFY2(file.open(QFile::ReadOnly), "cannot open test file test.json!");
|
||||
QByteArray testJson = file.readAll();
|
||||
|
||||
QBENCHMARK {
|
||||
@ -84,7 +84,7 @@ void BenchmarkQtJson::parseJsonToVariant()
|
||||
QString testFile = QFINDTESTDATA("test.json");
|
||||
QVERIFY2(!testFile.isEmpty(), "cannot find test file test.json!");
|
||||
QFile file(testFile);
|
||||
file.open(QFile::ReadOnly);
|
||||
QVERIFY2(file.open(QFile::ReadOnly), "cannot open test file test.json!");
|
||||
QByteArray testJson = file.readAll();
|
||||
|
||||
QBENCHMARK {
|
||||
|
@ -83,7 +83,8 @@ void tst_LanceBench::initTestCase()
|
||||
std::sort(qpsFiles.begin(), qpsFiles.end());
|
||||
for (const QString& fileName : std::as_const(qpsFiles)) {
|
||||
QFile file(scriptsDir + fileName);
|
||||
file.open(QFile::ReadOnly);
|
||||
QVERIFY2(file.open(QFile::ReadOnly),
|
||||
qPrintable(QString::fromLatin1("Failed to open %1").arg(fileName)));
|
||||
QByteArray cont = file.readAll();
|
||||
scripts.insert(fileName, QString::fromUtf8(cont).split(QLatin1Char('\n'), Qt::SkipEmptyParts));
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ public:
|
||||
|
||||
void qfile_vs_qnetworkaccessmanager::initTestCase()
|
||||
{
|
||||
testFile.open();
|
||||
QVERIFY2(testFile.open(), "Cannot open temporary file");
|
||||
QByteArray qba(1*1024*1024, 'x'); // 1 MB
|
||||
for (int i = 0; i < 100; i++) {
|
||||
testFile.write(qba);
|
||||
|
Loading…
x
Reference in New Issue
Block a user