Skip to content

Commit

Permalink
cppcheck: Fix several "known condition" warnings in mythfrontend.
Browse files Browse the repository at this point in the history
These are cases where a variable has already been checked for nullptr,
and if true the function has exited. There is no need to have
additional nullptr tests on the same variable.
  • Loading branch information
linuxdude42 committed Oct 2, 2020
1 parent 574ef22 commit 041b216
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 37 deletions.
46 changes: 18 additions & 28 deletions mythtv/programs/mythfrontend/playbackbox.cpp
Expand Up @@ -1232,7 +1232,7 @@ void PlaybackBox::updateIcons(const ProgramInfo *pginfo)
}
}

if (iconState && !haveIcon)
if (!haveIcon)
iconState->Reset();
}

Expand Down Expand Up @@ -3722,18 +3722,15 @@ void PlaybackBox::toggleWatched(void)
if (!pginfo)
return;

if (pginfo)
{
bool on = !pginfo->IsWatched();
pginfo->SaveWatched(on);
item->DisplayState((on)?"yes":"on", "watched");
updateIcons(pginfo);
bool on = !pginfo->IsWatched();
pginfo->SaveWatched(on);
item->DisplayState((on)?"yes":"on", "watched");
updateIcons(pginfo);

// A refill affects the responsiveness of the UI and we only
// need to rebuild the list if the watch list is displayed
if (m_viewMask & VIEW_WATCHLIST)
UpdateUILists();
}
// A refill affects the responsiveness of the UI and we only
// need to rebuild the list if the watch list is displayed
if (m_viewMask & VIEW_WATCHLIST)
UpdateUILists();
}

void PlaybackBox::toggleAutoExpire()
Expand All @@ -3748,14 +3745,10 @@ void PlaybackBox::toggleAutoExpire()
if (!pginfo)
return;

if (pginfo)
{
bool on = !pginfo->IsAutoExpirable();
pginfo->SaveAutoExpire(
(on) ? kNormalAutoExpire : kDisableAutoExpire, true);
item->DisplayState((on)?"yes":"no", "autoexpire");
updateIcons(pginfo);
}
bool on = !pginfo->IsAutoExpirable();
pginfo->SaveAutoExpire((on) ? kNormalAutoExpire : kDisableAutoExpire, true);
item->DisplayState((on)?"yes":"no", "autoexpire");
updateIcons(pginfo);
}

void PlaybackBox::togglePreserveEpisode()
Expand All @@ -3770,13 +3763,10 @@ void PlaybackBox::togglePreserveEpisode()
if (!pginfo)
return;

if (pginfo)
{
bool on = !pginfo->IsPreserved();
pginfo->SavePreserve(on);
item->DisplayState(on?"yes":"no", "preserve");
updateIcons(pginfo);
}
bool on = !pginfo->IsPreserved();
pginfo->SavePreserve(on);
item->DisplayState(on?"yes":"no", "preserve");
updateIcons(pginfo);
}

void PlaybackBox::toggleView(ViewMask itemMask, bool setOn)
Expand Down Expand Up @@ -5076,7 +5066,7 @@ void PlaybackBox::setPlayGroup(QString newPlayGroup)
}
doClearPlaylist();
}
else if (tmpItem)
else
{
RecordingInfo ri(*tmpItem);
ri.ApplyRecordPlayGroupChange(newPlayGroup);
Expand Down
13 changes: 4 additions & 9 deletions mythtv/programs/mythfrontend/progdetails.cpp
Expand Up @@ -182,7 +182,7 @@ void ProgDetails::PowerPriorities(const QString & ptable)
tests.append(qMakePair(QString("capturecard.recpriority"),
QString("capturecard.recpriority")));

if (recordid && prefinputpri)
if (prefinputpri)
{
pwrpri = QString("(capturecard.cardid = record.prefinput) * %1")
.arg(prefinputpri);
Expand Down Expand Up @@ -258,8 +258,6 @@ void ProgDetails::PowerPriorities(const QString & ptable)
sclause.remove(';');
pwrpri = QString("(%1) * %2").arg(sclause)
.arg(query.value(0).toInt());
if (!recordid && pwrpri.indexOf("RECTABLE") != -1)
continue;
pwrpri.replace("RECTABLE", "record");

desc = pwrpri;
Expand All @@ -269,12 +267,9 @@ void ProgDetails::PowerPriorities(const QString & ptable)
}
}

if (recordid)
{
recmatch = QString("INNER JOIN record "
" ON ( record.recordid = %1 ) ")
.arg(recordid);
}
recmatch = QString("INNER JOIN record "
" ON ( record.recordid = %1 ) ")
.arg(recordid);

for (const auto & [label, csqlStart] : qAsConst(tests))
{
Expand Down

0 comments on commit 041b216

Please sign in to comment.