From 19897d35458f16a345fc2630b3194813a546562d Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Mon, 7 May 2012 22:25:19 +0100 Subject: [PATCH] Fix some emptiness check inefficiencies highlighted by cppcheck. --- mythtv/libs/libmythtv/mpeg/atscstreamdata.cpp | 14 +++++------ mythtv/libs/libmythtv/tv_rec.cpp | 20 ++++++++-------- mythtv/programs/mythfrontend/videodlg.cpp | 24 +++++++++---------- mythtv/programs/mythwelcome/welcomedialog.cpp | 4 ++-- 4 files changed, 31 insertions(+), 31 deletions(-) diff --git a/mythtv/libs/libmythtv/mpeg/atscstreamdata.cpp b/mythtv/libs/libmythtv/mpeg/atscstreamdata.cpp index bb4c5ee2076..df1c38591a5 100644 --- a/mythtv/libs/libmythtv/mpeg/atscstreamdata.cpp +++ b/mythtv/libs/libmythtv/mpeg/atscstreamdata.cpp @@ -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; @@ -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); @@ -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); @@ -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); @@ -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); @@ -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); @@ -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); diff --git a/mythtv/libs/libmythtv/tv_rec.cpp b/mythtv/libs/libmythtv/tv_rec.cpp index 28031234493..4630b6f72eb 100644 --- a/mythtv/libs/libmythtv/tv_rec.cpp +++ b/mythtv/libs/libmythtv/tv_rec.cpp @@ -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; @@ -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"); @@ -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; @@ -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); @@ -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. * @@ -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; @@ -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; diff --git a/mythtv/programs/mythfrontend/videodlg.cpp b/mythtv/programs/mythfrontend/videodlg.cpp index 3cc51bcfd7f..8364c0c6778 100644 --- a/mythtv/programs/mythfrontend/videodlg.cpp +++ b/mythtv/programs/mythfrontend/videodlg.cpp @@ -378,7 +378,7 @@ namespace { if (name != "fanart") { - if (filename.size()) + if (!filename.isEmpty()) { image->SetFilename(filename); image->Load(); @@ -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) { @@ -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; @@ -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) @@ -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()) @@ -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) @@ -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)); @@ -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) @@ -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)); @@ -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())); @@ -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()); diff --git a/mythtv/programs/mythwelcome/welcomedialog.cpp b/mythtv/programs/mythwelcome/welcomedialog.cpp index 90b7d0f833e..8b47675bf6b 100644 --- a/mythtv/programs/mythwelcome/welcomedialog.cpp +++ b/mythtv/programs/mythwelcome/welcomedialog.cpp @@ -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; @@ -389,7 +389,7 @@ void WelcomeDialog::updateScreen(void) m_screenScheduledNo = 0; ProgramInfo progInfo = m_scheduledList[m_screenScheduledNo]; - + InfoMap infomap; progInfo.ToMap(infomap);