PlatformTimeRanges::nearest() truncates closestDelta values from double to float
authorddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 16 Mar 2014 17:05:15 +0000 (17:05 +0000)
committerddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 16 Mar 2014 17:05:15 +0000 (17:05 +0000)
<http://webkit.org/b/130298>

Reviewed by Darin Adler.

Fixes the following build failures using trunk clang:

    WebCore/platform/graphics/PlatformTimeRanges.cpp:210:28: error: absolute value function 'fabsf' given an argument of type 'double' but has parameter of type 'float' which may cause truncation of value [-Werror,-Wabsolute-value]
                closestDelta = fabsf(startTime - time);
                               ^
    WebCore/platform/graphics/PlatformTimeRanges.cpp:210:28: note: use function 'fabs' instead
                closestDelta = fabsf(startTime - time);
                               ^~~~~
                               fabs
    WebCore/platform/graphics/PlatformTimeRanges.cpp:214:28: error: absolute value function 'fabsf' given an argument of type 'double' but has parameter of type 'float' which may cause truncation of value [-Werror,-Wabsolute-value]
                closestDelta = fabsf(endTime - time);
                               ^
    WebCore/platform/graphics/PlatformTimeRanges.cpp:214:28: note: use function 'fabs' instead
                closestDelta = fabsf(endTime - time);
                               ^~~~~
                               fabs

* platform/graphics/PlatformTimeRanges.cpp:
(WebCore::PlatformTimeRanges::nearest): Extract start and end
time deltas into local variables so they don't have to be
computed twice, using fabs() instead of fabsf().

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@165701 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/PlatformTimeRanges.cpp

index fa52ac091a211697d56eb79f995f4d9462d8775e..96b729d67adb5f3634f4c055bbd1cfa86aba10e8 100644 (file)
@@ -1,3 +1,32 @@
+2014-03-16  David Kilzer  <ddkilzer@apple.com>
+
+        PlatformTimeRanges::nearest() truncates closestDelta values from double to float
+        <http://webkit.org/b/130298>
+
+        Reviewed by Darin Adler.
+
+        Fixes the following build failures using trunk clang:
+
+            WebCore/platform/graphics/PlatformTimeRanges.cpp:210:28: error: absolute value function 'fabsf' given an argument of type 'double' but has parameter of type 'float' which may cause truncation of value [-Werror,-Wabsolute-value]
+                        closestDelta = fabsf(startTime - time);
+                                       ^
+            WebCore/platform/graphics/PlatformTimeRanges.cpp:210:28: note: use function 'fabs' instead
+                        closestDelta = fabsf(startTime - time);
+                                       ^~~~~
+                                       fabs
+            WebCore/platform/graphics/PlatformTimeRanges.cpp:214:28: error: absolute value function 'fabsf' given an argument of type 'double' but has parameter of type 'float' which may cause truncation of value [-Werror,-Wabsolute-value]
+                        closestDelta = fabsf(endTime - time);
+                                       ^
+            WebCore/platform/graphics/PlatformTimeRanges.cpp:214:28: note: use function 'fabs' instead
+                        closestDelta = fabsf(endTime - time);
+                                       ^~~~~
+                                       fabs
+
+        * platform/graphics/PlatformTimeRanges.cpp:
+        (WebCore::PlatformTimeRanges::nearest): Extract start and end
+        time deltas into local variables so they don't have to be
+        computed twice, using fabs() instead of fabsf().
+
 2014-03-16  Darin Adler  <darin@apple.com>
 
         Optimize hasTagName when called on an HTMLElement
index 98d2f8de8144a4472e706c818a44f021a54b6da5..cf2a2eabce6ed25af9c24bca7a5d6a9d284d0984 100644 (file)
@@ -205,13 +205,17 @@ double PlatformTimeRanges::nearest(double time) const
         double endTime = end(ndx, ignoreInvalid);
         if (time >= startTime && time <= endTime)
             return time;
-        if (fabs(startTime - time) < closestDelta) {
+
+        double startTimeDelta = fabs(startTime - time);
+        if (startTimeDelta < closestDelta) {
             closestTime = startTime;
-            closestDelta = fabsf(startTime - time);
+            closestDelta = startTimeDelta;
         }
-        if (fabs(endTime - time) < closestDelta) {
+
+        double endTimeDelta = fabs(endTime - time);
+        if (endTimeDelta < closestDelta) {
             closestTime = endTime;
-            closestDelta = fabsf(endTime - time);
+            closestDelta = endTimeDelta;
         }
     }
     return closestTime;