[mythtv-commits] Ticket #12996: Fix compiler warnings in trunk
MythTV
noreply at mythtv.org
Fri Feb 10 19:53:16 UTC 2017
#12996: Fix compiler warnings in trunk
--------------------------------------+-----------------------------
Reporter: David Hampton <mythtv@…> | Owner:
Type: Patch - Bug Fix | Status: new
Priority: minor | Milestone: 29.0
Component: MythTV - General | Version: Master Head
Severity: medium | Resolution:
Keywords: | Ticket locked: 0
--------------------------------------+-----------------------------
Comment (by dekarl):
Replying to [comment:4 David Hampton <mythtv@…>]:
> the latter simply shuts up the compiler by generating a fake reference
to the variable.
David, thanks for joining in and helping with handling the heaps of
compiler warnings.
The goal is to silence false positives and to fix all bugs that are
pointed out by the warnings. Just shutting the compiler up may make it
harder to actually identify genuine bugs.
Here's an example from audioconvert.h:
{{{
bool operator==(AudioConvert& rhs) const
{ return m_in == rhs.m_in && m_out == rhs.m_out; }
bool operator!=(AudioConvert& rhs) const
- { return m_in != m_out; }
+ { Q_UNUSED(rhs); return m_in != m_out; }
}}}
These are binary operators. And one of them is completely ignoring the
right-hand-side symbol. That looks very much like a real bug.
A better fix would be mimicking the operator== like this (just making it
up on the fly):
{{{
bool operator==(AudioConvert& rhs) const
{ return m_in == rhs.m_in && m_out == rhs.m_out; }
bool operator!=(AudioConvert& rhs) const
- { return m_in != m_out; }
+ { return m_in != rhs.m_in || m_out != rhs.m_out; }
}}}
Maybe add some extra parentheses so its easier for a human to read. (not
everyone has the precedence order memorized)
{{{
bool operator==(AudioConvert& rhs) const
- { return m_in == rhs.m_in && m_out == rhs.m_out; }
+ { return (m_in == rhs.m_in) && (m_out == rhs.m_out); }
bool operator!=(AudioConvert& rhs) const
- { return m_in != m_out; }
+ { return (m_in != rhs.m_in) || (m_out != rhs.m_out); }
}}}
--
Ticket URL: <https://code.mythtv.org/trac/ticket/12996#comment:5>
MythTV <http://www.mythtv.org>
MythTV Media Center
More information about the mythtv-commits
mailing list