Skip to content

Commit

Permalink
Tidy: Don't use floating point variables as loop counter.
Browse files Browse the repository at this point in the history
The clang-tidy "cert-flp30-c" checker pointed out two locations where
a floating point variable was used as a loop counter.  Because of the
limitations of floating point variables, it is considered bad practice
and non-portable to use them as loop counters.  These two instances
are trivial enough that it shouldn't be a problem, but its easy to
correct them to use an integer loop counter.

https://clang.llvm.org/extra/clang-tidy/checks/cert-flp30-c.html
  • Loading branch information
linuxdude42 committed Dec 1, 2019
1 parent 41e631b commit 0779444
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions mythtv/libs/libmythui/DisplayResScreen.cpp
Expand Up @@ -139,10 +139,10 @@ int DisplayResScreen::FindBestMatch(const DisplayResVector& dsr,
{
while (!end)
{
for (double precision = 0.001;
precision < 1.0;
precision *= 10.0)
double precisions1[] = {0.001, 0.01, 0.1};
for (uint p = 0; p < sizeof(precisions1); p++)
{
double precision = precisions1[p];
for (size_t j=0; j < rates.size(); ++j)
{
// Multiple of target_rate will do
Expand All @@ -158,10 +158,10 @@ int DisplayResScreen::FindBestMatch(const DisplayResVector& dsr,
}
// Can't find exact frame rate, so try rounding to the
// nearest integer, so 23.97Hz will work with 24Hz etc
for (double precision = 0.01;
precision < 2.0;
precision *= 10.0)
double precisions2[] = {0.01, 0.1, 1};
for (uint p = 0; p < sizeof(precisions2); p++)
{
double precision = precisions2[p];
double rounded = round(videorate);
for (size_t j=0; j < rates.size(); ++j)
{
Expand Down

0 comments on commit 0779444

Please sign in to comment.