Fix prevent issue - Unsigned compared against 0 21/40921/2
authorYoonsang Lee <ysang114.lee@samsung.com>
Wed, 10 Jun 2015 08:36:07 +0000 (17:36 +0900)
committerYoonsang Lee <ysang114.lee@samsung.com>
Thu, 11 Jun 2015 00:36:34 +0000 (09:36 +0900)
- Since t/step can be negative number, min = static_cast<int>(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.

<Prevent message>
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

index 73b1706..d9d607d 100644 (file)
@@ -90,17 +90,21 @@ struct LinearConstraintFunctor
       if( mProgress.Size() < valueCount )
       {
         float step = 1.0f / (valueCount-1.0f);
-        min = static_cast<int>(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<size_t>(tLocation);
+          max = min+1;
+        }
 
         tLocal =(t - min*step) / step;
       }