From 2a52c6dcf64f96af3bf3c3d27c0248afd9d5119e Mon Sep 17 00:00:00 2001 From: Yoonsang Lee Date: Wed, 10 Jun 2015 17:36:07 +0900 Subject: [PATCH] Fix prevent issue - Unsigned compared against 0 - Since t/step can be negative number, min = static_cast(t/step); and if( min < 0) might cause unexpected behavior. - Introduce new float tLocation variable instead of direct assigning t/step to unsigned min variable. CID 436228 (#1 of 1): Unsigned compared against 0 (NO_EFFECT) unsigned_compare: This less-than-zero comparison of an unsigned value is never true. min < 0U. 95 if( min < 0) Change-Id: Id1be5aaf7a03f04f9cf61b1ad947f08bacb78563 --- dali/internal/event/animation/linear-constrainer-impl.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/dali/internal/event/animation/linear-constrainer-impl.h b/dali/internal/event/animation/linear-constrainer-impl.h index 73b1706..d9d607d 100644 --- a/dali/internal/event/animation/linear-constrainer-impl.h +++ b/dali/internal/event/animation/linear-constrainer-impl.h @@ -90,17 +90,21 @@ struct LinearConstraintFunctor if( mProgress.Size() < valueCount ) { float step = 1.0f / (valueCount-1.0f); - min = static_cast(t/step); - max = min+1; - if( min < 0) + float tLocation = t/step; + if( tLocation < 0) { min = 0; max = 1; } - else if( min >= valueCount-1) + else if( tLocation >= valueCount-1 ) { min = max = valueCount-1; } + else + { + min = static_cast(tLocation); + max = min+1; + } tLocal =(t - min*step) / step; } -- 2.7.4