| Summary: | Fix absolute value warning in LocalizedStringsGtk.cpp | ||||||
|---|---|---|---|---|---|---|---|
| Product: | WebKit | Reporter: | Csaba Osztrogonác <ossy> | ||||
| Component: | New Bugs | Assignee: | Michael Catanzaro <mcatanzaro> | ||||
| Status: | RESOLVED FIXED | ||||||
| Severity: | Normal | CC: | commit-queue, mcatanzaro, mrobinson, pnormand, zan | ||||
| Priority: | P2 | ||||||
| Version: | 528+ (Nightly build) | ||||||
| Hardware: | Unspecified | ||||||
| OS: | Unspecified | ||||||
| Bug Depends on: | |||||||
| Bug Blocks: | 145121 | ||||||
| Attachments: |
|
||||||
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. Created attachment 255248 [details]
Patch
Comment on attachment 255248 [details] Patch Clearing flags on attachment: 255248 Committed r185786: <http://trac.webkit.org/changeset/185786> All reviewed patches have been landed. Closing bug. |
../../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.