Bug 130297

Summary: Double values passed to fabsf() in maxScaleFromTransform()
Product: WebKit Reporter: David Kilzer (:ddkilzer) <ddkilzer>
Component: PlatformAssignee: David Kilzer (:ddkilzer) <ddkilzer>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, darin, dino, mjs, simon.fraser
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch v1
none
Patch for follow-up issue none

Description David Kilzer (:ddkilzer) 2014-03-15 21:46:32 PDT
WebCore/platform/graphics/ca/GraphicsLayerCA.cpp:287:21: 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]
    return std::max(fabsf(decomposeData.scaleX), fabsf(decomposeData.scaleY));
                    ^
WebCore/platform/graphics/ca/GraphicsLayerCA.cpp:287:21: note: use function 'fabs' instead
    return std::max(fabsf(decomposeData.scaleX), fabsf(decomposeData.scaleY));
                    ^~~~~
                    fabs
WebCore/platform/graphics/ca/GraphicsLayerCA.cpp:287:50: 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]
    return std::max(fabsf(decomposeData.scaleX), fabsf(decomposeData.scaleY));
                                                 ^
WebCore/platform/graphics/ca/GraphicsLayerCA.cpp:287:50: note: use function 'fabs' instead
    return std::max(fabsf(decomposeData.scaleX), fabsf(decomposeData.scaleY));
                                                 ^~~~~
                                                 fabs
2 errors generated.
Comment 1 David Kilzer (:ddkilzer) 2014-03-15 22:08:57 PDT
Created attachment 226832 [details]
Patch v1
Comment 2 Darin Adler 2014-03-16 00:58:19 PDT
Comment on attachment 226832 [details]
Patch v1

View in context: https://bugs.webkit.org/attachment.cgi?id=226832&action=review

> Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp:287
> +    return std::max(fabsf(static_cast<float>(decomposeData.scaleX)), fabsf(static_cast<float>(decomposeData.scaleY)));

I’d really prefer we use syntax cast for casting double to float that would not also work to convert, say, int to float.
Comment 3 Darin Adler 2014-03-16 00:58:42 PDT
Comment on attachment 226832 [details]
Patch v1

View in context: https://bugs.webkit.org/attachment.cgi?id=226832&action=review

>> Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp:287
>> +    return std::max(fabsf(static_cast<float>(decomposeData.scaleX)), fabsf(static_cast<float>(decomposeData.scaleY)));
> 
> I’d really prefer we use syntax cast for casting double to float that would not also work to convert, say, int to float.

Seems like we have it! It’s called narrowPrecisionToFloat.
Comment 4 WebKit Commit Bot 2014-03-16 01:28:04 PDT
Comment on attachment 226832 [details]
Patch v1

Clearing flags on attachment: 226832

Committed r165693: <http://trac.webkit.org/changeset/165693>
Comment 5 WebKit Commit Bot 2014-03-16 01:28:08 PDT
All reviewed patches have been landed.  Closing bug.
Comment 6 David Kilzer (:ddkilzer) 2014-03-16 11:52:26 PDT
Reopening for follow-up patch to switch to using narrowPrecisionToFloat() instead.
Comment 7 David Kilzer (:ddkilzer) 2014-03-16 12:00:44 PDT
Created attachment 226850 [details]
Patch for follow-up issue
Comment 8 WebKit Commit Bot 2014-03-16 14:42:16 PDT
Comment on attachment 226850 [details]
Patch for follow-up issue

Clearing flags on attachment: 226850

Committed r165711: <http://trac.webkit.org/changeset/165711>
Comment 9 WebKit Commit Bot 2014-03-16 14:42:19 PDT
All reviewed patches have been landed.  Closing bug.