Skip to content

Commit

Permalink
Replace unconditional 'if' statements with conditional compilation.
Browse files Browse the repository at this point in the history
Clang-tidy wants to remove a number of clauses behind an 'if (false)'
statement, since this code will never be compiled.  Replace the 'if
(false)' with an '#if 0' to keep the code without getting false
positives from clang-tidy.

Code pointed out by clang-tidy's "simplify boolean expression" check.

https://clang.llvm.org/extra/clang-tidy/checks/readability-simplify-boolean-expr.html
  • Loading branch information
linuxdude42 committed Mar 26, 2019
1 parent ad0e62e commit b97106f
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 57 deletions.
37 changes: 18 additions & 19 deletions mythplugins/mythmusic/mythmusic/visualize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1129,32 +1129,31 @@ bool Piano::process_all_types(VisualNode *node, bool /*this_will_be_displayed*/)
{
magnitude2 = q1*q1 + q2*q2 - q1*q2*coeff;

if (false) // This is RMS of signal
#if 0
// This is RMS of signal
magnitude_av = sqrt(magnitude2)/(goertzel_data)n_samples; // Should be 0<magnitude_av<.5
#else
// This is pure magnitude of signal
magnitude_av = magnitude2/(goertzel_data)n_samples/(goertzel_data)n_samples; // Should be 0<magnitude_av<.25
#endif

#if 0
// Take logs everywhere, and shift up to [0, ??]
if(magnitude_av > 0.0f)
{
magnitude_av = sqrt(magnitude2)/(goertzel_data)n_samples; // Should be 0<magnitude_av<.5
magnitude_av = log(magnitude_av);
}
if (true) // This is pure magnitude of signal
else
{
magnitude_av = magnitude2/(goertzel_data)n_samples/(goertzel_data)n_samples; // Should be 0<magnitude_av<.25
magnitude_av = PIANO_MIN_VOL;
}
magnitude_av -= PIANO_MIN_VOL;

if (false) // Take logs everywhere, and shift up to [0, ??]
if (magnitude_av < 0.0f)
{
if(magnitude_av > 0.0f)
{
magnitude_av = log(magnitude_av);
}
else
{
magnitude_av = PIANO_MIN_VOL;
}
magnitude_av -= PIANO_MIN_VOL;

if (magnitude_av < 0.0f)
{
magnitude_av = 0.0;
}
magnitude_av = 0.0;
}
#endif

if (magnitude_av > (goertzel_data)0.01)
{
Expand Down
4 changes: 3 additions & 1 deletion mythtv/libs/libmyth/audio/audiooutput_omx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ AudioOutputOMX::AudioOutputOMX(const AudioSettings &settings) :
for (unsigned port = 0; port < m_audiorender.Ports(); ++port)
{
m_audiorender.ShowPortDef(port, LOG_DEBUG, VB_AUDIO);
if (false) m_audiorender.ShowFormats(port, LOG_DEBUG, VB_AUDIO);
#if 0
m_audiorender.ShowFormats(port, LOG_DEBUG, VB_AUDIO);
#endif
}

InitSettings(settings);
Expand Down
4 changes: 3 additions & 1 deletion mythtv/libs/libmyth/omxcontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -744,9 +744,11 @@ OMX_ERRORTYPE OMXComponentCtx::Event( OMXComponent &cmpnt,
break;

case OMX_EventBufferFlag:
if (false) LOG(VB_PLAYBACK, LOG_DEBUG, LOCB(cmpnt) + QString(
#if 0
LOG(VB_PLAYBACK, LOG_DEBUG, LOCB(cmpnt) + QString(
"EventBufferFlag: port=%1 flags=%2")
.arg(nData1).arg(HeaderFlags(nData2)) );
#endif
break;

case OMX_EventResourcesAcquired:
Expand Down
43 changes: 21 additions & 22 deletions mythtv/libs/libmythtv/previewgeneratorqueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,28 +494,27 @@ QString PreviewGeneratorQueue::GeneratePreviewImage(

bool preview_exists = previewLastModified.isValid();

if (false)
{
QString alttext = (bookmark_ts.isValid()) ? QString() :
QString("\n\t\t\tcmp_ts: %1")
.arg(cmp_ts.toString(Qt::ISODate));
LOG(VB_GENERAL, LOG_INFO,
QString("previewLastModified: %1\n\t\t\t"
"bookmark_ts: %2%3\n\t\t\t"
"pginfo.lastmodified: %4")
.arg(previewLastModified.toString(Qt::ISODate))
.arg(bookmark_ts.toString(Qt::ISODate))
.arg(alttext)
.arg(pginfo.GetLastModifiedTime(MythDate::ISODate)) +
QString("Title: %1\n\t\t\t")
.arg(pginfo.toString(ProgramInfo::kTitleSubtitle)) +
QString("File '%1' \n\t\t\tCache '%2'")
.arg(filename).arg(ret_file) +
QString("\n\t\t\tPreview Exists: %1, Bookmark Updated: %2, "
"Need Preview: %3")
.arg(preview_exists).arg(bookmark_updated)
.arg((bookmark_updated || !preview_exists)));
}
#if 0
QString alttext = (bookmark_ts.isValid()) ? QString() :
QString("\n\t\t\tcmp_ts: %1")
.arg(cmp_ts.toString(Qt::ISODate));
LOG(VB_GENERAL, LOG_INFO,
QString("previewLastModified: %1\n\t\t\t"
"bookmark_ts: %2%3\n\t\t\t"
"pginfo.lastmodified: %4")
.arg(previewLastModified.toString(Qt::ISODate))
.arg(bookmark_ts.toString(Qt::ISODate))
.arg(alttext)
.arg(pginfo.GetLastModifiedTime(MythDate::ISODate)) +
QString("Title: %1\n\t\t\t")
.arg(pginfo.toString(ProgramInfo::kTitleSubtitle)) +
QString("File '%1' \n\t\t\tCache '%2'")
.arg(filename).arg(ret_file) +
QString("\n\t\t\tPreview Exists: %1, Bookmark Updated: %2, "
"Need Preview: %3")
.arg(preview_exists).arg(bookmark_updated)
.arg((bookmark_updated || !preview_exists)));
#endif

needs_gen = bookmark_updated || !preview_exists;

Expand Down
4 changes: 3 additions & 1 deletion mythtv/libs/libmythtv/privatedecoder_omx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ PrivateDecoderOMX::PrivateDecoderOMX() :
for (unsigned port = 0; port < m_videc.Ports(); ++port)
{
m_videc.ShowPortDef(port, LOG_DEBUG);
if (false) m_videc.ShowFormats(port, LOG_DEBUG);
#if 0
m_videc.ShowFormats(port, LOG_DEBUG);
#endif
}
}

Expand Down
8 changes: 6 additions & 2 deletions mythtv/libs/libmythtv/videoout_omx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,9 @@ VideoOutputOMX::VideoOutputOMX() :
for (unsigned port = 0; port < m_render.Ports(); ++port)
{
m_render.ShowPortDef(port, LOG_DEBUG);
if (false) m_render.ShowFormats(port, LOG_DEBUG);
#if 0
m_render.ShowFormats(port, LOG_DEBUG);
#endif
}

if (OMX_ErrorNone != m_imagefx.Init(OMX_IndexParamImageInit))
Expand All @@ -316,7 +318,9 @@ VideoOutputOMX::VideoOutputOMX() :
for (unsigned port = 0; port < m_imagefx.Ports(); ++port)
{
m_imagefx.ShowPortDef(port, LOG_DEBUG);
if (false) m_imagefx.ShowFormats(port, LOG_DEBUG);
#if 0
m_imagefx.ShowFormats(port, LOG_DEBUG);
#endif
}
}

Expand Down
22 changes: 11 additions & 11 deletions mythtv/programs/mythfilldatabase/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -620,19 +620,19 @@ int main(int argc, char *argv[])
found += updt.numRowsAffected();
LOG(VB_GENERAL, LOG_INFO, QString(" Found %1").arg(found));

if (true) // limit MSqlQuery's lifetime
#if 1
// limit MSqlQuery's lifetime
MSqlQuery query2(MSqlQuery::InitCon());
query2.prepare("SELECT count(previouslyshown) "
"FROM program WHERE previouslyshown = 1;");
if (query2.exec() && query2.next())
{
MSqlQuery query2(MSqlQuery::InitCon());
query2.prepare("SELECT count(previouslyshown) "
"FROM program WHERE previouslyshown = 1;");
if (query2.exec() && query2.next())
{
if (query2.value(0).toInt() != 0)
gCoreContext->SaveSettingOnHost("HaveRepeats", "1", nullptr);
else
gCoreContext->SaveSettingOnHost("HaveRepeats", "0", nullptr);
}
if (query2.value(0).toInt() != 0)
gCoreContext->SaveSettingOnHost("HaveRepeats", "1", nullptr);
else
gCoreContext->SaveSettingOnHost("HaveRepeats", "0", nullptr);
}
#endif

LOG(VB_GENERAL, LOG_INFO, "\n"
"===============================================================\n"
Expand Down

0 comments on commit b97106f

Please sign in to comment.