RESOLVED FIXED 145919
Fix absolute value warning in LocalizedStringsGtk.cpp
https://bugs.webkit.org/show_bug.cgi?id=145919
Summary Fix absolute value warning in LocalizedStringsGtk.cpp
Csaba Osztrogonác
Reported 2015-06-12 04:14:11 PDT
../../Source/WebCore/platform/gtk/LocalizedStringsGtk.cpp:667:36: warning: using integer absolute value function 'abs' when argument is of floating point type [-Wabsolute-value] int seconds = static_cast<int>(abs(time)); ^ ../../Source/WebCore/platform/gtk/LocalizedStringsGtk.cpp:667:36: note: use function 'std::abs' instead int seconds = static_cast<int>(abs(time)); ^~~ std::abs 1 warning generated. This code was introduced in http://trac.webkit.org/changeset/142463 , but it seems something is still wrong here.
Attachments
Patch (1.61 KB, patch)
2015-06-19 16:52 PDT, Michael Catanzaro
no flags
Michael Catanzaro
Comment 1 2015-06-19 16:51:53 PDT
There are two things wrong: * Clang warns when passing a float to ::abs() because ::abs() will truncate the value, returning an int. If you are passing in a float, there's a high probability you wants to use std::abs() to receive a float instead. * The current code casts the result of ::abs(), an int, to an int, which is pointless. We could remove the cast, but that would not avoid the clang warning. This is a very strange case that a compiler warning requires us to use an unnecessary cast.
Michael Catanzaro
Comment 2 2015-06-19 16:52:07 PDT
WebKit Commit Bot
Comment 3 2015-06-19 18:25:40 PDT
Comment on attachment 255248 [details] Patch Clearing flags on attachment: 255248 Committed r185786: <http://trac.webkit.org/changeset/185786>
WebKit Commit Bot
Comment 4 2015-06-19 18:25:44 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.