Commit d4a28e37 authored by Ori Shalev's avatar Ori Shalev Committed by Facebook Github Bot

Fix implicit float conversion in MemoryIdler

Summary:
After an innocent inclusion of "folly/futures/Future.h" in some cachelib code (D9372014), some gcc builds fail with:
    folly/detail/MemoryIdler.h:88:30: error: conversion to 'float' alters 'long unsigned int' constant value [-Werror=float-conversion]

It seems like this has been worked-around previously by ignoring warnings in outer code such as here:
diffusion/FBS/browse/master/fbcode/cachelib/common/Utils.h$7-10

Reviewed By: yfeldblum

Differential Revision: D9381592

fbshipit-source-id: 00ec25600ae473baeee5caaef9989d66a9a64a59
parent 26aeda1a
......@@ -84,8 +84,8 @@ struct MemoryIdler {
std::chrono::system_clock::now().time_since_epoch().count()));
// multiplying the duration by a floating point doesn't work, grr
auto extraFrac =
timeoutVariationFrac / std::numeric_limits<uint64_t>::max() * h;
auto extraFrac = timeoutVariationFrac /
static_cast<float>(std::numeric_limits<uint64_t>::max()) * h;
auto tics = uint64_t(idleTimeout.count() * (1 + extraFrac));
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