Fix various -Wdeprecated-enum-float-conversions around the code

In two cases, it was as easy as replacing an unnamed enum's values
with constexpr variables. In the case of QSimplex, I opted for
qToUnderlying(), as the enum made sense on its own.

Change-Id: Ifcf5be14bd2f35e50adabdbd7ecdb2e83f6bf5b4
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
Marc Mutz 2021-07-23 21:26:35 +02:00
parent 18113e22e9
commit 8e0c2d7d22
3 changed files with 13 additions and 13 deletions

View File

@ -551,7 +551,7 @@ qreal QSimplex::solver(SolverFactor factor)
// Return the value calculated by the simplex plus the value of the // Return the value calculated by the simplex plus the value of the
// fixed variables. // fixed variables.
return (factor * valueAt(0, columns - 1)) + resultOffset; return (qToUnderlying(factor) * valueAt(0, columns - 1)) + resultOffset;
} }
/*! /*!

View File

@ -750,18 +750,16 @@ void tst_QRandomGenerator::qualityReal()
return; return;
RandomGenerator rng(control); RandomGenerator rng(control);
enum { constexpr int SampleSize = 16000;
SampleSize = 16000,
// Expected value: sample size times proportion of the range: // Expected value: sample size times proportion of the range:
PerfectOctile = SampleSize / 8, constexpr int PerfectOctile = SampleSize / 8;
PerfectHalf = SampleSize / 2, constexpr int PerfectHalf = SampleSize / 2;
// Variance is (1 - proportion of range) * expected; sqrt() for standard deviations. // Variance is (1 - proportion of range) * expected; sqrt() for standard deviations.
// Should usually be within twice that and almost never outside four times: // Should usually be within twice that and almost never outside four times:
RangeHalf = 252, // floor(4 * sqrt((1 - 0.5) * PerfectHalf)) constexpr int RangeHalf = 252; // floor(4 * sqrt((1 - 0.5) * PerfectHalf))
RangeOctile = 167 // floor(4 * sqrt((1 - 0.125) * PerfectOctile)) constexpr int RangeOctile = 167; // floor(4 * sqrt((1 - 0.125) * PerfectOctile))
};
double data[SampleSize]; double data[SampleSize];
std::generate(std::begin(data), std::end(data), [&rng] { return rng.generateDouble(); }); std::generate(std::begin(data), std::end(data), [&rng] { return rng.generateDouble(); });

View File

@ -631,9 +631,11 @@ void tst_qnetworkreply::uploadPerformance()
QVERIFY(!QTestEventLoop::instance().timeout()); QVERIFY(!QTestEventLoop::instance().timeout());
} }
constexpr qint64 MiB = 1024 * 1024;
void tst_qnetworkreply::httpUploadPerformance() void tst_qnetworkreply::httpUploadPerformance()
{ {
enum {UploadSize = 128*1024*1024}; // 128 MB constexpr qint64 UploadSize = 128 * MiB;
ThreadedDataReaderHttpServer reader; ThreadedDataReaderHttpServer reader;
FixedSizeDataGenerator generator(UploadSize); FixedSizeDataGenerator generator(UploadSize);
@ -701,7 +703,7 @@ void tst_qnetworkreply::httpDownloadPerformance()
QFETCH(bool, serverSendsContentLength); QFETCH(bool, serverSendsContentLength);
QFETCH(bool, chunkedEncoding); QFETCH(bool, chunkedEncoding);
enum {UploadSize = 128*1024*1024}; // 128 MB constexpr qint64 UploadSize = 128 * MiB;
HttpDownloadPerformanceServer server(UploadSize, serverSendsContentLength, chunkedEncoding); HttpDownloadPerformanceServer server(UploadSize, serverSendsContentLength, chunkedEncoding);