Bug 631657 - Bogus WARNING: Overflowed nscoord_MAX in conversion to nscoord; r=roc, a2.0=dbaron
authorPhilipp Wagner <mail@philipp-wagner.com>
Sun, 20 Feb 2011 16:15:58 +0100
changeset 62897 cfa2a5ef17c3f3c564d7a76b366a13982c46e998
parent 62896 7019dd8625a8e49013865d95450565de6897a8df
child 62898 247891ec0f422bf2824f7978bd3d40b1612538cd
push id1
push userroot
push dateTue, 10 Dec 2013 15:46:25 +0000
reviewersroc
bugs631657
milestone2.0b12pre
Bug 631657 - Bogus WARNING: Overflowed nscoord_MAX in conversion to nscoord; r=roc, a2.0=dbaron
gfx/src/nsCoord.h
--- a/gfx/src/nsCoord.h
+++ b/gfx/src/nsCoord.h
@@ -96,22 +96,24 @@ inline nscoord NSToCoordRound(float aVal
   return nscoord(NS_floorf(aValue + 0.5f));
 #endif /* XP_WIN32 && _M_IX86 && !__GNUC__ */
 }
 
 inline nscoord NSToCoordRoundWithClamp(float aValue)
 {
 #ifndef NS_COORD_IS_FLOAT
   // Bounds-check before converting out of float, to avoid overflow
+  NS_WARN_IF_FALSE(aValue <= nscoord_MAX,
+                   "Overflowed nscoord_MAX in conversion to nscoord");
   if (aValue >= nscoord_MAX) {
-    NS_WARNING("Overflowed nscoord_MAX in conversion to nscoord");
     return nscoord_MAX;
   }
+  NS_WARN_IF_FALSE(aValue >= nscoord_MIN,
+                   "Overflowed nscoord_MIN in conversion to nscoord");
   if (aValue <= nscoord_MIN) {
-    NS_WARNING("Overflowed nscoord_MIN in conversion to nscoord");
     return nscoord_MIN;
   }
 #endif
   return NSToCoordRound(aValue);
 }
 
 /**
  * Returns aCoord * aScale, capping the product to nscoord_MAX or nscoord_MIN as
@@ -350,43 +352,47 @@ inline nscoord NSToCoordFloor(float aVal
 {
   return nscoord(NS_floorf(aValue));
 }
 
 inline nscoord NSToCoordFloorClamped(float aValue)
 {
 #ifndef NS_COORD_IS_FLOAT
   // Bounds-check before converting out of float, to avoid overflow
+  NS_WARN_IF_FALSE(aValue <= nscoord_MAX,
+                   "Overflowed nscoord_MAX in conversion to nscoord");
   if (aValue >= nscoord_MAX) {
-    NS_WARNING("Overflowed nscoord_MAX in conversion to nscoord");
     return nscoord_MAX;
   }
+  NS_WARN_IF_FALSE(aValue >= nscoord_MIN,
+                   "Overflowed nscoord_MIN in conversion to nscoord");
   if (aValue <= nscoord_MIN) {
-    NS_WARNING("Overflowed nscoord_MIN in conversion to nscoord");
     return nscoord_MIN;
   }
 #endif
   return NSToCoordFloor(aValue);
 }
 
 inline nscoord NSToCoordCeil(float aValue)
 {
   return nscoord(NS_ceilf(aValue));
 }
 
 inline nscoord NSToCoordCeilClamped(float aValue)
 {
 #ifndef NS_COORD_IS_FLOAT
   // Bounds-check before converting out of float, to avoid overflow
+  NS_WARN_IF_FALSE(aValue <= nscoord_MAX,
+                   "Overflowed nscoord_MAX in conversion to nscoord");
   if (aValue >= nscoord_MAX) {
-    NS_WARNING("Overflowed nscoord_MAX in conversion to nscoord");
     return nscoord_MAX;
   }
+  NS_WARN_IF_FALSE(aValue >= nscoord_MIN,
+                   "Overflowed nscoord_MIN in conversion to nscoord");
   if (aValue <= nscoord_MIN) {
-    NS_WARNING("Overflowed nscoord_MIN in conversion to nscoord");
     return nscoord_MIN;
   }
 #endif
   return NSToCoordCeil(aValue);
 }
 
 /*
  * Int Rounding Functions