Skip to content

Commit

Permalink
Fix various -Wdeprecated-enum-float-conversions around the code
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Mårten Nordheim <[email protected]>
Reviewed-by: Edward Welbourne <[email protected]>
  • Loading branch information
marc-kdab committed Jul 27, 2021
1 parent 18113e2 commit 8e0c2d7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/widgets/graphicsview/qsimplex_p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ qreal QSimplex::solver(SolverFactor factor)

// Return the value calculated by the simplex plus the value of the
// fixed variables.
return (factor * valueAt(0, columns - 1)) + resultOffset;
return (qToUnderlying(factor) * valueAt(0, columns - 1)) + resultOffset;
}

/*!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -750,18 +750,16 @@ void tst_QRandomGenerator::qualityReal()
return;
RandomGenerator rng(control);

enum {
SampleSize = 16000,
constexpr int SampleSize = 16000;

// Expected value: sample size times proportion of the range:
PerfectOctile = SampleSize / 8,
PerfectHalf = SampleSize / 2,
// Expected value: sample size times proportion of the range:
constexpr int PerfectOctile = SampleSize / 8;
constexpr int PerfectHalf = SampleSize / 2;

// Variance is (1 - proportion of range) * expected; sqrt() for standard deviations.
// Should usually be within twice that and almost never outside four times:
RangeHalf = 252, // floor(4 * sqrt((1 - 0.5) * PerfectHalf))
RangeOctile = 167 // floor(4 * sqrt((1 - 0.125) * PerfectOctile))
};
// Variance is (1 - proportion of range) * expected; sqrt() for standard deviations.
// Should usually be within twice that and almost never outside four times:
constexpr int RangeHalf = 252; // floor(4 * sqrt((1 - 0.5) * PerfectHalf))
constexpr int RangeOctile = 167; // floor(4 * sqrt((1 - 0.125) * PerfectOctile))

double data[SampleSize];
std::generate(std::begin(data), std::end(data), [&rng] { return rng.generateDouble(); });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -631,9 +631,11 @@ void tst_qnetworkreply::uploadPerformance()
QVERIFY(!QTestEventLoop::instance().timeout());
}

constexpr qint64 MiB = 1024 * 1024;

void tst_qnetworkreply::httpUploadPerformance()
{
enum {UploadSize = 128*1024*1024}; // 128 MB
constexpr qint64 UploadSize = 128 * MiB;

ThreadedDataReaderHttpServer reader;
FixedSizeDataGenerator generator(UploadSize);
Expand Down Expand Up @@ -701,7 +703,7 @@ void tst_qnetworkreply::httpDownloadPerformance()
QFETCH(bool, serverSendsContentLength);
QFETCH(bool, chunkedEncoding);

enum {UploadSize = 128*1024*1024}; // 128 MB
constexpr qint64 UploadSize = 128 * MiB;

HttpDownloadPerformanceServer server(UploadSize, serverSendsContentLength, chunkedEncoding);

Expand Down

0 comments on commit 8e0c2d7

Please sign in to comment.