From 414159df9ea07cdf64ea36ca920f5d35242fd38a Mon Sep 17 00:00:00 2001 From: Gary Buhrmaster Date: Wed, 21 Mar 2012 12:24:24 -0700 Subject: [PATCH] Keep an unsigned counter from going negative 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 --- mythtv/programs/mythcommflag/ClassicCommDetector.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mythtv/programs/mythcommflag/ClassicCommDetector.cpp b/mythtv/programs/mythcommflag/ClassicCommDetector.cpp index 98304c702f4..71a2351a900 100644 --- a/mythtv/programs/mythcommflag/ClassicCommDetector.cpp +++ b/mythtv/programs/mythcommflag/ClassicCommDetector.cpp @@ -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)) {