Commit 9fff036d authored by Ian Petersen's avatar Ian Petersen Committed by Facebook GitHub Bot

Fix implicit conversion warnings in MemoryIdler.h

Summary:
The build with Clang 10 on iOS broke with the following errors:

```
folly/detail/MemoryIdler.h:86:68: error: implicit conversion from 'uint64_t' (aka 'unsigned long long') to 'float' may lose precision [-Werror,-Wimplicit-int-float-conversion]
        static_cast<float>(std::numeric_limits<uint64_t>::max()) * h;
                                                                 ~ ^
```

```
folly/detail/MemoryIdler.h:87:38: error: implicit conversion from 'std::__1::chrono::duration<long long, std::__1::ratio<1, 1000000000> >::rep' (aka 'long long') to 'float' may lose precision [-Werror,-Wimplicit-int-float-conversion]
    auto tics = uint64_t(idleTimeout.count() * (1 + extraFrac));
                         ~~~~~~~~~~~~^~~~~~~ ~
```

This diff fixes the problem by making the existing implicit casts explicit.

Reviewed By: Orvid

Differential Revision: D22490364

fbshipit-source-id: 90bd116290de1d8906140d514f1d4880c3b3b085
parent b1d264ed
...@@ -83,8 +83,10 @@ struct MemoryIdler { ...@@ -83,8 +83,10 @@ struct MemoryIdler {
// multiplying the duration by a floating point doesn't work, grr // multiplying the duration by a floating point doesn't work, grr
auto extraFrac = timeoutVariationFrac / auto extraFrac = timeoutVariationFrac /
static_cast<float>(std::numeric_limits<uint64_t>::max()) * h; static_cast<float>(std::numeric_limits<uint64_t>::max()) *
auto tics = uint64_t(idleTimeout.count() * (1 + extraFrac)); static_cast<float>(h);
auto tics =
uint64_t(static_cast<float>(idleTimeout.count()) * (1 + extraFrac));
return IdleTime(tics); return IdleTime(tics);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment