Skip to content

Commit

Permalink
tidy: Use the boolean literal value 'false' instead of the number '0'.
Browse files Browse the repository at this point in the history
The clang-tidy "use boolean literal" check pointed out macros what
used a 'while (0)' clause at the end instead of 'while (false)'.
Changes were pointed out by clang-tidy and made by hand.

https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-bool-literals.html
  • Loading branch information
linuxdude42 committed Mar 26, 2019
1 parent 262f88d commit b701303
Show file tree
Hide file tree
Showing 18 changed files with 43 additions and 43 deletions.
2 changes: 1 addition & 1 deletion mythtv/libs/libmyth/omxcontext.cpp
Expand Up @@ -1110,7 +1110,7 @@ const char *Command2String(OMX_COMMANDTYPE cmd)
(_n) &= ~OMX_BUFFERFLAG_##_f;\
(_l) << STR(_f);\
}\
} while(0)
} while(false)

QString HeaderFlags(OMX_U32 nFlags)
{
Expand Down
28 changes: 14 additions & 14 deletions mythtv/libs/libmyth/programinfo.cpp
Expand Up @@ -1248,7 +1248,7 @@ bool ProgramInfo::QueryRecordedIdFromPathname(const QString &pathname,
return false;
}

#define INT_TO_LIST(x) do { list << QString::number(x); } while (0)
#define INT_TO_LIST(x) do { list << QString::number(x); } while (false)

#if QT_VERSION < QT_VERSION_CHECK(5,8,0)
#define DATETIME_TO_LIST(x) INT_TO_LIST((x).toTime_t())
Expand All @@ -1259,15 +1259,15 @@ bool ProgramInfo::QueryRecordedIdFromPathname(const QString &pathname,
} else { \
INT_TO_LIST(kInvalidDateTime); \
} \
} while (0)
} while (false)
#endif

#define LONGLONG_TO_LIST(x) do { list << QString::number(x); } while (0)
#define LONGLONG_TO_LIST(x) do { list << QString::number(x); } while (false)

#define STR_TO_LIST(x) do { list << (x); } while (0)
#define DATE_TO_LIST(x) do { list << (x).toString(Qt::ISODate); } while (0)
#define STR_TO_LIST(x) do { list << (x); } while (false)
#define DATE_TO_LIST(x) do { list << (x).toString(Qt::ISODate); } while (false)

#define FLOAT_TO_LIST(x) do { list << QString("%1").arg(x); } while (0)
#define FLOAT_TO_LIST(x) do { list << QString("%1").arg(x); } while (false)

/** \fn ProgramInfo::ToStringList(QStringList&) const
* \brief Serializes ProgramInfo into a QStringList which can be passed
Expand Down Expand Up @@ -1345,17 +1345,17 @@ void ProgramInfo::ToStringList(QStringList &list) const
clear(); \
return false; \
} \
ts = *it++; } while (0)
ts = *it++; } while (false)

#define INT_FROM_LIST(x) do { NEXT_STR(); (x) = ts.toLongLong(); } while (0)
#define ENUM_FROM_LIST(x, y) do { NEXT_STR(); (x) = ((y)ts.toInt()); } while (0)
#define INT_FROM_LIST(x) do { NEXT_STR(); (x) = ts.toLongLong(); } while (false)
#define ENUM_FROM_LIST(x, y) do { NEXT_STR(); (x) = ((y)ts.toInt()); } while (false)

#if QT_VERSION < QT_VERSION_CHECK(5,8,0)
#define DATETIME_FROM_LIST(x) \
do { NEXT_STR(); \
x = (ts.toUInt() == kInvalidDateTime ? \
QDateTime() : MythDate::fromTime_t(ts.toUInt())); \
} while (0)
} while (false)
#else
#define DATETIME_FROM_LIST(x) \
do { NEXT_STR(); \
Expand All @@ -1364,16 +1364,16 @@ void ProgramInfo::ToStringList(QStringList &list) const
} else { \
(x) = MythDate::fromSecsSinceEpoch(ts.toLongLong()); \
} \
} while (0)
} while (false)
#endif
#define DATE_FROM_LIST(x) \
do { NEXT_STR(); (x) = ((ts.isEmpty()) || (ts == "0000-00-00")) ? \
QDate() : QDate::fromString(ts, Qt::ISODate); \
} while (0)
} while (false)

#define STR_FROM_LIST(x) do { NEXT_STR(); (x) = ts; } while (0)
#define STR_FROM_LIST(x) do { NEXT_STR(); (x) = ts; } while (false)

#define FLOAT_FROM_LIST(x) do { NEXT_STR(); (x) = ts.toFloat(); } while (0)
#define FLOAT_FROM_LIST(x) do { NEXT_STR(); (x) = ts.toFloat(); } while (false)

/** \fn ProgramInfo::FromStringList(QStringList::const_iterator&,
QStringList::const_iterator)
Expand Down
12 changes: 6 additions & 6 deletions mythtv/libs/libmythbase/filesysteminfo.cpp
Expand Up @@ -26,8 +26,8 @@ using namespace std;
#include "mythcoreutil.h"

// for serialization
#define INT_TO_LIST(x) do { list << QString::number(x); } while (0)
#define STR_TO_LIST(x) do { list << (x); } while (0)
#define INT_TO_LIST(x) do { list << QString::number(x); } while (false)
#define STR_TO_LIST(x) do { list << (x); } while (false)

// for deserialization
#define NEXT_STR() do { if (it == listend) \
Expand All @@ -36,10 +36,10 @@ using namespace std;
clear(); \
return false; \
} \
ts = *it++; } while (0)
#define INT_FROM_LIST(x) do { NEXT_STR(); (x) = ts.toLongLong(); } while (0)
#define ENUM_FROM_LIST(x, y) do { NEXT_STR(); (x) = ((y)ts.toInt()); } while (0)
#define STR_FROM_LIST(x) do { NEXT_STR(); (x) = ts; } while (0)
ts = *it++; } while (false)
#define INT_FROM_LIST(x) do { NEXT_STR(); (x) = ts.toLongLong(); } while (false)
#define ENUM_FROM_LIST(x, y) do { NEXT_STR(); (x) = ((y)ts.toInt()); } while (false)
#define STR_FROM_LIST(x) do { NEXT_STR(); (x) = ts; } while (false)

#define LOC QString("FileSystemInfo: ")

Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythbase/mythscheduler.h
Expand Up @@ -11,7 +11,7 @@ class RecordingInfo;

typedef std::deque<RecordingInfo*> RecList;
#define SORT_RECLIST(LIST, ORDER) \
do { std::stable_sort((LIST).begin(), (LIST).end(), ORDER); } while (0)
do { std::stable_sort((LIST).begin(), (LIST).end(), ORDER); } while (false)

typedef RecList::const_iterator RecConstIter;
typedef RecList::iterator RecIter;
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythfreemheg/Logging.h
Expand Up @@ -37,13 +37,13 @@ extern FILE *__mhlogStream;
do { \
if (__level & __mhlogoptions) \
__mhlog(__text); \
} while (0)
} while (false)

#define MHERROR(__text) \
do { \
if (MHLogError & __mhlogoptions) \
__mhlog(__text); \
throw "Failed"; \
} while (0)
} while (false)

#endif
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/avformatdecoder.cpp
Expand Up @@ -215,7 +215,7 @@ static int has_codec_parameters(AVStream *st)
#define FAIL(errmsg) do { \
LOG(VB_PLAYBACK, LOG_DEBUG, LOC + (errmsg)); \
return 0; \
} while (0)
} while (false)

switch (st->codecpar->codec_type)
{
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/cc708decoder.cpp
Expand Up @@ -123,7 +123,7 @@ do { \
cc->m_temp_str_size[service_num]); \
cc->m_temp_str_size[service_num] = 0; \
} \
} while (0)
} while (false)

static void parse_cc_service_stream(CC708Reader* cc, uint service_num)
{
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/deletemap.cpp
Expand Up @@ -19,7 +19,7 @@
LOG(VB_GENERAL, LOG_ERR, LOC + "Cannot edit outside edit mode."); \
return; \
} \
} while(0)
} while(false)

void DeleteMap::Push(const QString &undoMessage)
{
Expand Down
10 changes: 5 additions & 5 deletions mythtv/libs/libmythtv/dtvconfparser.cpp
Expand Up @@ -41,22 +41,22 @@
#include "channelutil.h"

#define PARSE_SKIP(VAR) do { \
if (it == tokens.end()) return false; ++it; } while(0)
if (it == tokens.end()) return false; ++it; } while(false)

#define PARSE_CONF(VAR) do { \
if (it == tokens.end() || !(VAR).ParseConf(*it++)) \
return false; } while(0)
return false; } while(false)

#define PARSE_STR(VAR) do { \
if (it != tokens.end()) (VAR) = *it++; else return false; } while(0)
if (it != tokens.end()) (VAR) = *it++; else return false; } while(false)

#define PARSE_UINT(VAR) do { \
if (it != tokens.end()) \
(VAR) = (*it++).toUInt(); else return false; } while(0)
(VAR) = (*it++).toUInt(); else return false; } while(false)

#define PARSE_UINT_1000(VAR) do { \
if (it != tokens.end()) \
(VAR) = (*it++).toUInt() * 1000ULL; else return false; } while(0)
(VAR) = (*it++).toUInt() * 1000ULL; else return false; } while(false)


QString DTVChannelInfo::toString() const
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/inputinfo.cpp
Expand Up @@ -9,7 +9,7 @@ void InputInfo::Clear(void)
*this = blank;
}

#define NEXT() do { ++it; if (it == end) return false; } while (0)
#define NEXT() do { ++it; if (it == end) return false; } while (false)
bool InputInfo::FromStringList(QStringList::const_iterator &it,
QStringList::const_iterator end)
{
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/mpeg/mpegdescriptors.cpp
Expand Up @@ -375,7 +375,7 @@ QString MPEGDescriptor::DescriptorTagString(void) const

#define SET_STRING(DESC_NAME) do { \
if (IsValid()) { DESC_NAME d(_data, DescriptorLength()+2); \
if (d.IsValid()) str = d.toString(); } } while (0)
if (d.IsValid()) str = d.toString(); } } while (false)

QString MPEGDescriptor::toString() const
{
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/mpeg/pespacket.cpp
Expand Up @@ -103,7 +103,7 @@ bool PESPacket::AddTSPacket(const TSPacket* packet, bool &broken)
*/
void PESPacket::GetAsTSPackets(vector<TSPacket> &output, uint cc) const
{
#define INCR_CC(_CC_) do { (_CC_) = ((_CC_) + 1) & 0xf; } while (0)
#define INCR_CC(_CC_) do { (_CC_) = ((_CC_) + 1) & 0xf; } while (false)
uint last_byte_of_pesdata = Length() + 4 - 1;
uint size = last_byte_of_pesdata + _pesdata - _fullbuffer;

Expand Down
Expand Up @@ -38,7 +38,7 @@ QString getVideoProps(unsigned char props);
#else
#define PRINT_EVENT(a)
#endif
#define TEST_AND_ADD(t,m,s) do{if ((t) & (m)) {(s) += " | "#m;(t) &= ~(m);}}while(0)
#define TEST_AND_ADD(t,m,s) do{if ((t) & (m)) {(s) += " | "#m;(t) &= ~(m);}}while(false)

QString getSubtitleType(unsigned char type)
{
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythtv/tv_play.cpp
Expand Up @@ -2094,8 +2094,8 @@ TVState TV::RemoveRecording(TVState state)
#define TRANSITION(ASTATE,BSTATE) \
((ctxState == (ASTATE)) && (desiredNextState == (BSTATE)))

#define SET_NEXT() do { nextState = desiredNextState; changed = true; } while(0)
#define SET_LAST() do { nextState = ctxState; changed = true; } while(0)
#define SET_NEXT() do { nextState = desiredNextState; changed = true; } while(false)
#define SET_LAST() do { nextState = ctxState; changed = true; } while(false)

static QString tv_i18n(const QString &msg)
{
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythtv/tv_rec.cpp
Expand Up @@ -980,8 +980,8 @@ void TVRec::FinishedRecording(RecordingInfo *curRec, RecordingQuality *recq)

#define TRANSITION(ASTATE,BSTATE) \
((m_internalState == (ASTATE)) && (m_desiredNextState == (BSTATE)))
#define SET_NEXT() do { nextState = m_desiredNextState; changed = true; } while(0)
#define SET_LAST() do { nextState = m_internalState; changed = true; } while(0)
#define SET_NEXT() do { nextState = m_desiredNextState; changed = true; } while(false)
#define SET_LAST() do { nextState = m_internalState; changed = true; } while(false)

/** \fn TVRec::HandleStateChange(void)
* \brief Changes the internalState to the desiredNextState if possible.
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/vaapicontext.cpp
Expand Up @@ -27,7 +27,7 @@
ok = arg1; \
if (!ok) \
LOG(VB_GENERAL, LOG_ERR, LOC + (arg2)); \
} while(0)
} while(false)

QString profileToString(VAProfile profile);
QString entryToString(VAEntrypoint entry);
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/videoout_vdpau.cpp
Expand Up @@ -24,7 +24,7 @@
{ \
LOG(VB_GENERAL, LOG_ERR, LOC + QString("IsErrored() in %1").arg(Loc)); \
return; \
} while(0)
} while(false)

void VideoOutputVDPAU::GetRenderOptions(render_opts &opts)
{
Expand Down
2 changes: 1 addition & 1 deletion mythtv/programs/mythfrontend/statusbox.cpp
Expand Up @@ -749,7 +749,7 @@ void StatusBox::doScheduleStatus()
.arg(statusText[rtype]); \
AddLogLine(tmpstr, helpmsg, tmpstr, tmpstr, fstate);\
} \
} while (0)
} while (false)
ADD_STATUS_LOG_LINE(RecStatus::Recording, "");
ADD_STATUS_LOG_LINE(RecStatus::Tuning, "");
ADD_STATUS_LOG_LINE(RecStatus::Failing, "error");
Expand Down

0 comments on commit b701303

Please sign in to comment.