Skip to content

Commit

Permalink
Fix some emptiness check inefficiencies highlighted by cppcheck.
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartm committed May 7, 2012
1 parent dc1b2ad commit 19897d3
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 31 deletions.
14 changes: 7 additions & 7 deletions mythtv/libs/libmythtv/mpeg/atscstreamdata.cpp
Expand Up @@ -64,7 +64,7 @@ void ATSCStreamData::SetDesiredChannel(int major, int minor)
tvct_vec_t tvcts = GetCachedTVCTs();
cvct_vec_t cvcts = GetCachedCVCTs();

if (mgt && (tvcts.size() || cvcts.size()))
if (mgt && (!tvcts.empty() || !cvcts.empty()))
{
const TerrestrialVirtualChannelTable *tvct = NULL;
const CableVirtualChannelTable *cvct = NULL;
Expand Down Expand Up @@ -387,7 +387,7 @@ bool ATSCStreamData::HandleTables(uint pid, const PSIPTable &psip)
case TableID::NITscte:
{
SCTENetworkInformationTable nit(psip);

QMutexLocker locker(&_listener_lock);
for (uint i = 0; i < _scte_main_listeners.size(); i++)
_scte_main_listeners[i]->HandleNIT(&nit);
Expand All @@ -397,7 +397,7 @@ bool ATSCStreamData::HandleTables(uint pid, const PSIPTable &psip)
case TableID::NTT:
{
NetworkTextTable ntt(psip);

QMutexLocker locker(&_listener_lock);
for (uint i = 0; i < _scte_main_listeners.size(); i++)
_scte_main_listeners[i]->HandleNTT(&ntt);
Expand All @@ -417,7 +417,7 @@ bool ATSCStreamData::HandleTables(uint pid, const PSIPTable &psip)
case TableID::STTscte:
{
SCTESystemTimeTable stt(psip);

QMutexLocker locker(&_listener_lock);
for (uint i = 0; i < _scte_main_listeners.size(); i++)
_scte_main_listeners[i]->HandleSTT(&stt);
Expand All @@ -429,7 +429,7 @@ bool ATSCStreamData::HandleTables(uint pid, const PSIPTable &psip)
case TableID::PIM:
{
ProgramInformationMessageTable pim(psip);

QMutexLocker locker(&_listener_lock);
for (uint i = 0; i < _scte_main_listeners.size(); i++)
_scte_main_listeners[i]->HandlePIM(&pim);
Expand All @@ -440,7 +440,7 @@ bool ATSCStreamData::HandleTables(uint pid, const PSIPTable &psip)
case TableID::PNM:
{
ProgramNameMessageTable pnm(psip);

QMutexLocker locker(&_listener_lock);
for (uint i = 0; i < _scte_main_listeners.size(); i++)
_scte_main_listeners[i]->HandlePNM(&pnm);
Expand All @@ -452,7 +452,7 @@ bool ATSCStreamData::HandleTables(uint pid, const PSIPTable &psip)
case TableID::ADET:
{
AggregateDataEventTable adet(psip);

QMutexLocker locker(&_listener_lock);
for (uint i = 0; i < _scte_main_listeners.size(); i++)
_scte_main_listeners[i]->HandleADET(&adet);
Expand Down
20 changes: 10 additions & 10 deletions mythtv/libs/libmythtv/tv_rec.cpp
Expand Up @@ -152,7 +152,7 @@ bool TVRec::Init(void)
SetRecordingStatus(rsUnknown, __LINE__);

// configure the Channel instance
QString startchannel = GetStartChannel(cardid,
QString startchannel = GetStartChannel(cardid,
CardUtil::GetStartInput(cardid));
if (!CreateChannel(startchannel, true))
return false;
Expand Down Expand Up @@ -470,7 +470,7 @@ RecStatusType TVRec::StartRecording(const ProgramInfo *rcinfo)

// If the needed input is in a shared input group, and we are
// not canceling the recording anyway, check other recorders
if (!cancelNext && has_pending && pendinfo.possibleConflicts.size())
if (!cancelNext && has_pending && !pendinfo.possibleConflicts.empty())
{
LOG(VB_RECORD, LOG_INFO, LOC +
"Checking input group recorders - begin");
Expand Down Expand Up @@ -965,7 +965,7 @@ void TVRec::HandleStateChange(void)

if (desiredNextState == internalState)
{
LOG(VB_GENERAL, LOG_ERR, LOC +
LOG(VB_GENERAL, LOG_ERR, LOC +
"HandleStateChange(): Null transition" + transMsg);
changeState = false;
return;
Expand Down Expand Up @@ -1208,7 +1208,7 @@ void TVRec::run(void)
eitScanStartTime = QDateTime::currentDateTime();
// check whether we should use the EITScanner in this TVRec instance
if (CardUtil::IsEITCapable(genOpt.cardtype) &&
(!GetDTVChannel() || GetDTVChannel()->IsMaster()) &&
(!GetDTVChannel() || GetDTVChannel()->IsMaster()) &&
(dvbOpt.dvb_eitscan || get_use_eit(cardid)))
{
scanner = new EITScanner(cardid);
Expand Down Expand Up @@ -1922,7 +1922,7 @@ bool TVRec::SetupDTVSignalMonitor(bool EITscan)
* \brief This creates a SignalMonitor instance and
* begins signal monitoring.
*
* If the channel exists and there is something to monitor a
* If the channel exists and there is something to monitor a
* SignalMonitor instance is created and SignalMonitor::Start()
* is called to start the signal monitoring thread.
*
Expand Down Expand Up @@ -2278,7 +2278,7 @@ bool TVRec::CheckChannelPrefix(const QString &prefix,
// Now process the lists for the info we need...
is_extra_char_useful = false;
is_complete_valid_channel_on_rec = 0;
needed_spacer = "";
needed_spacer.clear();

if (fchanid.empty())
return false;
Expand Down Expand Up @@ -3172,10 +3172,10 @@ bool TVRec::GetChannelInfo(uint &chanid, uint &sourceid,
QString &callsign, QString &channum,
QString &channame, QString &xmltvid) const
{
callsign = "";
channum = "";
channame = "";
xmltvid = "";
callsign.clear();
channum.clear();
channame.clear();
xmltvid.clear();

if ((!chanid || !sourceid) && !channel)
return false;
Expand Down
24 changes: 12 additions & 12 deletions mythtv/programs/mythfrontend/videodlg.cpp
Expand Up @@ -378,7 +378,7 @@ namespace
{
if (name != "fanart")
{
if (filename.size())
if (!filename.isEmpty())
{
image->SetFilename(filename);
image->Load();
Expand Down Expand Up @@ -730,11 +730,11 @@ class VideoDialogPrivate

void AutomaticParentalAdjustment(VideoMetadata *metadata)
{
if (metadata && m_rating_to_pl.size())
if (metadata && !m_rating_to_pl.empty())
{
QString rating = metadata->GetRating();
for (parental_level_map::const_iterator p = m_rating_to_pl.begin();
rating.length() && p != m_rating_to_pl.end(); ++p)
!rating.isEmpty() && p != m_rating_to_pl.end(); ++p)
{
if (rating.indexOf(p->first) != -1)
{
Expand Down Expand Up @@ -1148,7 +1148,7 @@ void VideoDialog::loadData()

if (m_d->m_type == DLG_GALLERY || m_d->m_type == DLG_BROWSER)
{
if (lastTreeNodePath.size() > 0)
if (!lastTreeNodePath.isEmpty())
{
MythGenericTree *node;

Expand Down Expand Up @@ -1356,7 +1356,7 @@ QString VideoDialog::RemoteImageCheck(QString host, QString filename)

QStringList dirs = GetVideoDirsByHost(host);

if (dirs.size() > 0)
if (!dirs.isEmpty())
{
for (QStringList::const_iterator iter = dirs.begin();
iter != dirs.end(); ++iter)
Expand All @@ -1381,7 +1381,7 @@ QString VideoDialog::RemoteImageCheck(QString host, QString filename)
break;
}

if ((list.size() > 0) && (list.at(0) == fname))
if ((!list.isEmpty()) && (list.at(0) == fname))
result = generate_file_url("Videos", host, filename);

if (!result.isEmpty())
Expand Down Expand Up @@ -1469,7 +1469,7 @@ QString VideoDialog::GetImageFromFolder(VideoMetadata *metadata)

QStringList dirs = GetVideoDirsByHost(host);

if (dirs.size() > 0)
if (!dirs.isEmpty())
{
for (QStringList::const_iterator iter = dirs.begin();
iter != dirs.end(); ++iter)
Expand All @@ -1491,7 +1491,7 @@ QString VideoDialog::GetImageFromFolder(VideoMetadata *metadata)
QRegExp rx(*pattern);
rx.setPatternSyntax(QRegExp::Wildcard);
QStringList matches = tmpList.filter(rx);
if (matches.size() > 0)
if (!matches.isEmpty())
{
fList.clear();
fList.append(subdir + "/" + matches.at(0).split("::").at(1));
Expand Down Expand Up @@ -1619,7 +1619,7 @@ QString VideoDialog::GetCoverImage(MythGenericTree *node)

QStringList dirs = GetVideoDirsByHost(host);

if (dirs.size() > 0)
if (!dirs.isEmpty())
{
for (QStringList::const_iterator iter = dirs.begin();
iter != dirs.end(); ++iter)
Expand All @@ -1642,7 +1642,7 @@ QString VideoDialog::GetCoverImage(MythGenericTree *node)
QRegExp rx(*pattern);
rx.setPatternSyntax(QRegExp::Wildcard);
QStringList matches = tmpList.filter(rx);
if (matches.size() > 0)
if (!matches.isEmpty())
{
fList.clear();
fList.append(subdir + "/" + matches.at(0).split("::").at(1));
Expand Down Expand Up @@ -2592,7 +2592,7 @@ MythMenu *VideoDialog::CreateInfoMenu()
VideoMetadata *metadata = GetMetadata(GetItemCurrent());
if (metadata)
{
if (metadata->GetCast().size())
if (!metadata->GetCast().empty())
menu->AddItem(tr("View Cast"), SLOT(ShowCastDialog()));
if (!metadata->GetHomepage().isEmpty())
menu->AddItem(tr("View Homepage"), SLOT(ShowHomepage()));
Expand Down Expand Up @@ -3096,7 +3096,7 @@ void VideoDialog::playVideoWithTrailers()
gCoreContext->GetNumSetting("mythvideo.TrailersRandomCount");

int i = 0;
while (trailers.size() && i < trailersToPlay)
while (!trailers.isEmpty() && i < trailersToPlay)
{
++i;
QString trailer = trailers.takeAt(random() % trailers.size());
Expand Down
4 changes: 2 additions & 2 deletions mythtv/programs/mythwelcome/welcomedialog.cpp
Expand Up @@ -346,7 +346,7 @@ void WelcomeDialog::updateScreen(void)
else
{
// update recording
if (m_isRecording && m_tunerList.size())
if (m_isRecording && !m_tunerList.empty())
{
if (m_screenTunerNo >= m_tunerList.size())
m_screenTunerNo = 0;
Expand Down Expand Up @@ -389,7 +389,7 @@ void WelcomeDialog::updateScreen(void)
m_screenScheduledNo = 0;

ProgramInfo progInfo = m_scheduledList[m_screenScheduledNo];

InfoMap infomap;
progInfo.ToMap(infomap);

Expand Down

0 comments on commit 19897d3

Please sign in to comment.