Skip to content

Commit

Permalink
cppcheck: Fix "non-boolean returned from bool function" warnings.
Browse files Browse the repository at this point in the history
I compared the before/after versions of one of these functions. Both
versions compile to exactly the same set if assembly instructions.
This is true when compiling with the optimizer, and when compiling
without the optimizer.
  • Loading branch information
linuxdude42 committed Jul 12, 2022
1 parent 3e57db9 commit 202280e
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 28 deletions.
10 changes: 5 additions & 5 deletions mythtv/libs/libmythtv/mpeg/atsctables.h
Expand Up @@ -278,18 +278,18 @@ class MTV_PUBLIC VirtualChannelTable : public PSIPTable
// access_controlled 1 25.2
bool IsAccessControlled(uint i) const
{
return bool(m_ptrs[i][26] & 0x20);
return ( m_ptrs[i][26] & 0x20 ) != 0;
}
// hidden 1 25.3
bool IsHidden(uint i) const
{
return bool(m_ptrs[i][26] & 0x10);
return ( m_ptrs[i][26] & 0x10 ) != 0;
}
// reserved 2 25.4 3
// hide_guide 1 25.6
bool IsHiddenInGuide(uint i) const
{
return bool(m_ptrs[i][26] & 0x2);
return ( m_ptrs[i][26] & 0x02 ) != 0;
}
// reserved 6 25.7 0x3f
// service_type 6 26.2
Expand Down Expand Up @@ -492,12 +492,12 @@ class MTV_PUBLIC CableVirtualChannelTable : public VirtualChannelTable
// path_select 1 26.4
bool IsPathSelect(uint i) const
{
return bool(m_ptrs[i][26] & 0x8);
return ( m_ptrs[i][26] & 0x08 ) != 0;
}
// out_of_band 1 26.5
bool IsOutOfBand(uint i) const
{
return bool(m_ptrs[i][26] & 0x4);
return ( m_ptrs[i][26] & 0x04 ) != 0;
}
// hide_guide 1 26.6
// reserved 3 26.7 7
Expand Down
8 changes: 4 additions & 4 deletions mythtv/libs/libmythtv/mpeg/dvbtables.h
Expand Up @@ -150,14 +150,14 @@ class MTV_PUBLIC ServiceDescriptionTable : public PSIPTable
uint ServiceID(uint i) const { return (m_ptrs[i][0]<<8) | (m_ptrs[i][1]); }
// reserved_future_use 6 2.0+p
// EIT_schedule_flag 1 2.6+p
bool HasEITSchedule(uint i) const { return bool(m_ptrs[i][2] & 0x2); }
bool HasEITSchedule(uint i) const { return ( m_ptrs[i][2] & 0x02 ) != 0; }
// EIT_present_following 1 2.7+p
bool HasEITPresentFollowing(uint i) const
{ return bool(m_ptrs[i][2] & 0x1); }
{ return ( m_ptrs[i][2] & 0x01 ) != 0; }
/// running_status 3 3.0+p
uint RunningStatus(uint i) const { return (m_ptrs[i][3] & 0xE0) >> 5; }
/// free_CA_mode 1 3.3+p
bool IsEncrypted(uint i) const { return bool(m_ptrs[i][3] & 0x10); }
bool IsEncrypted(uint i) const { return ( m_ptrs[i][3] & 0x10 ) != 0; }
/// desc_loop_length 12 3.4+p
uint ServiceDescriptorsLength(uint i) const
{ return ((m_ptrs[i][3]<<8) | (m_ptrs[i][4])) & 0xfff; }
Expand Down Expand Up @@ -358,7 +358,7 @@ class MTV_PUBLIC DVBEventInformationTable : public PSIPTable
// running_status 3 10.0+x
uint RunningStatus(uint i) const { return m_ptrs[i][10] >> 5; }
// free_CA_mode 1 10.3+x
bool IsScrambled(uint i) const { return bool(m_ptrs[i][10] & 0x10); }
bool IsScrambled(uint i) const { return ( m_ptrs[i][10] & 0x10 ) != 0; }
// descriptors_loop_len 12 10.4+x
uint DescriptorsLength(uint i) const
{ return ((m_ptrs[i][10]<<8) | (m_ptrs[i][11])) & 0xfff; }
Expand Down
20 changes: 10 additions & 10 deletions mythtv/libs/libmythtv/mpeg/mpegtables.h
Expand Up @@ -1228,42 +1228,42 @@ class MTV_PUBLIC AdaptationFieldControl
*/
bool Discontinuity(void) const { return ( m_data[1] & 0x80 ) != 0; }
// random_access_indicator (?) 1 1.1
bool RandomAccess(void) const { return bool(m_data[1] & 0x40); }
bool RandomAccess(void) const { return ( m_data[1] & 0x40 ) != 0; }
// elementary_stream_priority_indicator 1 1.2
bool Priority(void) const { return bool(m_data[1] & 0x20); }
bool Priority(void) const { return ( m_data[1] & 0x20 ) != 0; }

// Each of the following extends the adaptation header. In order:

/** PCR flag (we have PCR data) 1 1.3
* (adds 6 bytes after adaptation header)
*/
bool PCR(void) const { return bool(m_data[1] & 0x10); }
bool PCR(void) const { return ( m_data[1] & 0x10 ) != 0; }
/** OPCR flag (we have OPCR data) 1 1.4
* (adds 6 bytes) ((Original) Program Clock Reference; used to time output)
*/
bool OPCR(void) const { return bool(m_data[1] & 0x08); }
bool OPCR(void) const { return ( m_data[1] & 0x08 ) != 0; }
/** splicing_point_flag 1 1.5
* (adds 1 byte) (we have splice point data)
* Splice data is packets until a good splice point for
* e.g. commercial insertion -- if these are still set,
* might be a good way to recognize potential commercials
* for flagging.
*/
bool SplicingPoint(void) const { return bool(m_data[1] & 0x04); }
bool SplicingPoint(void) const { return ( m_data[1] & 0x04 ) != 0; }
// transport_private_data_flag 1 1.6
// (adds 1 byte)
bool PrivateTransportData(void) const { return bool(m_data[1] & 0x02); }
bool PrivateTransportData(void) const { return ( m_data[1] & 0x02 ) != 0; }
// adaptation_field_extension_flag 1 1.7
bool FieldExtension(void) const { return bool(m_data[1] & 0x1); }
bool FieldExtension(void) const { return ( m_data[1] & 0x01 ) != 0; }
// extension length 8 2.0
uint ExtensionLength(void) const { return m_data[2]; }
// ltw flag 1 3.0
// (adds 2 bytes)
bool LTW(void) const { return bool(m_data[3] & 0x80); }
bool LTW(void) const { return ( m_data[3] & 0x80 ) != 0; }
// piecewise_rate_flag (adds 3 bytes) 1 3.1
bool PiecewiseRate(void) const { return bool(m_data[3] & 0x40); }
bool PiecewiseRate(void) const { return ( m_data[3] & 0x40 ) != 0; }
// seamless_splice_flag (adds 5 bytes) 1 3.2
bool SeamlessSplice(void) const { return bool(m_data[3] & 0x20); }
bool SeamlessSplice(void) const { return ( m_data[3] & 0x20 ) != 0; }
// unused flags 5 3.3

private:
Expand Down
18 changes: 9 additions & 9 deletions mythtv/libs/libmythtv/mpeg/tspacket.h
Expand Up @@ -81,12 +81,12 @@ class MTV_PUBLIC TSHeader
bool HasSync(void) const { return SYNC_BYTE == m_tsData[0]; }
//1.0 1 bit transport_packet_error (if set discard immediately:
// modem error)
bool TransportError(void) const { return bool(m_tsData[1]&0x80); }
bool TransportError(void) const { return ( m_tsData[1] & 0x80 ) != 0; }
//1.1 1 bit payload_unit_start_indicator
// (if set this packet starts a section, and has pointerField)
bool PayloadStart(void) const { return bool(m_tsData[1]&0x40); }
bool PayloadStart(void) const { return ( m_tsData[1] & 0x40 ) != 0; }
//1.2 1 bit transport_priority (ignore)
bool Priority(void) const { return bool(m_tsData[1]&0x20); }
bool Priority(void) const { return ( m_tsData[1] & 0x20 ) != 0; }
//1.3 13 bit PID (packet ID, which transport stream)
inline unsigned int PID(void) const {
return ((m_tsData[1] << 8) + m_tsData[2]) & 0x1fff;
Expand All @@ -107,17 +107,17 @@ class MTV_PUBLIC TSHeader
unsigned int ContinuityCounter(void) const { return m_tsData[3] & 0xf; }

// shortcuts
bool Scrambled(void) const { return bool(m_tsData[3]&0x80); }
bool HasAdaptationField(void) const { return bool(m_tsData[3] & 0x20); }
bool Scrambled(void) const { return ( m_tsData[3] & 0x80 ) != 0; }
bool HasAdaptationField(void) const { return ( m_tsData[3] & 0x20 ) != 0; }
size_t AdaptationFieldSize(void) const
{ return (HasAdaptationField() ? static_cast<size_t>(data()[4]) : 0); }
bool HasPayload(void) const { return bool(m_tsData[3] & 0x10); }
bool HasPayload(void) const { return ( m_tsData[3] & 0x10 ) != 0; }

bool GetDiscontinuityIndicator(void) const
{ return AdaptationFieldSize() > 0 && bool(data()[5] & 0x80); }
{ return (AdaptationFieldSize() > 0) && ((data()[5] & 0x80 ) != 0); }

bool HasPCR(void) const { return AdaptationFieldSize() > 0 &&
bool(data()[5] & 0x10); }
bool HasPCR(void) const { return (AdaptationFieldSize() > 0) &&
((data()[5] & 0x10 ) != 0); }

/*
The PCR field is a 42 bit field in the adaptation field of the
Expand Down

0 comments on commit 202280e

Please sign in to comment.