Skip to content

Commit

Permalink
Keep an unsigned counter from going negative
Browse files Browse the repository at this point in the history
Issue found by clang.  This issue would likely be fairly rare, but it exists
and should be fixed.

Fixes #10479.

Signed-off-by: Gavin Hurlbut <ghurlbut@mythtv.org>
  • Loading branch information
garybuhrmaster authored and Beirdo committed Mar 21, 2012
1 parent fd42b59 commit 414159d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion mythtv/programs/mythcommflag/ClassicCommDetector.cpp
Expand Up @@ -2229,7 +2229,9 @@ bool ClassicCommDetector::FrameIsInBreakMap(
}
}

for (uint64_t i = f; i >= 0; i--)
// We want from f down to 0, but without wrapping the counter to negative
// on an unsigned counter.
for (uint64_t i = (f + 1); i-- > 0; )
{
if (breakMap.contains(i))
{
Expand Down

6 comments on commit 414159d

@jyavenard
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code isn't equivalent.
Should be using i-1 wherever it was using i.

@Beirdo
Copy link
Member

@Beirdo Beirdo commented on 414159d Mar 22, 2012 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jyavenard
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad. Too late and not enough sleep

@garybuhrmaster
Copy link
Contributor Author

@garybuhrmaster garybuhrmaster commented on 414159d Mar 22, 2012 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@garybuhrmaster
Copy link
Contributor Author

@garybuhrmaster garybuhrmaster commented on 414159d Mar 22, 2012 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Beirdo
Copy link
Member

@Beirdo Beirdo commented on 414159d Mar 22, 2012 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.