Skip to content

Commit

Permalink
tidy: Silence a couple of misleading "infinite loop" warnings.
Browse files Browse the repository at this point in the history
The clang-tidy "infinite loop" checker pointed out a couple of places
that look like infinite loops, because the loop variable isn't updated
anywhere inside of the loop.  All of these are written in the form:

    while ( x=fn() )
        {...}

What clang-tidy doesn't see is that inside the function is an iterator
that will eventually return 0 and cause the loop to exit.  Tell
clang-tidy to ignore these loops in the future.

https://clang.llvm.org/extra/clang-tidy/checks/bugprone-infinite-loop.html
  • Loading branch information
linuxdude42 committed Nov 20, 2019
1 parent 7d29637 commit f6a1e3f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions mythtv/libs/libmyth/audio/audiooutputalsa.cpp
Expand Up @@ -361,6 +361,7 @@ AudioOutputSettings* AudioOutputALSA::GetOutputSettings(bool passthrough)
"(using plugin?)");
}

// NOLINTNEXTLINE(bugprone-infinite-loop)
while (int rate = settings->GetNextRate())
if(snd_pcm_hw_params_test_rate(m_pcm_handle, params, rate, 0) >= 0)
settings->AddSupportedRate(rate);
Expand Down
2 changes: 2 additions & 0 deletions mythtv/libs/libmyth/audio/audiooutputnull.cpp
Expand Up @@ -55,11 +55,13 @@ AudioOutputSettings* AudioOutputNULL::GetOutputSettings(bool /*digital*/)
// Pretend that we support everything
AudioOutputSettings *settings = new AudioOutputSettings();

// NOLINTNEXTLINE(bugprone-infinite-loop)
while (int rate = settings->GetNextRate())
{
settings->AddSupportedRate(rate);
}

// NOLINTNEXTLINE(bugprone-infinite-loop)
while (AudioFormat fmt = settings->GetNextFormat())
{
settings->AddSupportedFormat(fmt);
Expand Down
1 change: 1 addition & 0 deletions mythtv/libs/libmyth/audio/audiooutputoss.cpp
Expand Up @@ -50,6 +50,7 @@ AudioOutputSettings* AudioOutputOSS::GetOutputSettings(bool /*digital*/)
return nullptr;
}

// NOLINTNEXTLINE(bugprone-infinite-loop)
while (int rate = settings->GetNextRate())
{
int rate2 = rate;
Expand Down

0 comments on commit f6a1e3f

Please sign in to comment.