Fix IsPowerOfTwo can be overflowed return value 16/37016/5
authordaemyung jang <dm86.jang@samsung.com>
Wed, 18 Mar 2015 06:19:25 +0000 (15:19 +0900)
committerjang <dm86.jang@samsung.com>
Thu, 19 Mar 2015 11:19:26 +0000 (04:19 -0700)
Change-Id: I1ccc0a174dc9164400aee00e48a08f1c8ca33182

dali/public-api/math/math-utils.h

index cb56fd5..25a26a7 100644 (file)
@@ -35,10 +35,10 @@ namespace Dali
  */
 inline unsigned int NextPowerOfTwo( unsigned int i )
 {
-  DALI_ASSERT_DEBUG(i <= 1U << (sizeof(unsigned) * 8 - 1) && "Return type cannot represent the next power of two greater than the argument.");
-  if(i==0)
+  DALI_ASSERT_DEBUG(i <= 1u << (sizeof(unsigned) * 8 - 1) && "Return type cannot represent the next power of two greater than the argument.");
+  if(i==0u)
   {
-    return 1;
+    return 1u;
   }
 
   i--;
@@ -59,7 +59,7 @@ inline unsigned int NextPowerOfTwo( unsigned int i )
  */
 inline bool IsPowerOfTwo( unsigned int i )
 {
-  return (i != 0) && ((i & (i - 1)) == 0);
+  return (i != 0u) && ((i & (i - 1u)) == 0u);
 }
 
 /**