Fixed conversion warning in `duration.hpp`. While `ns()` and our other types are `int64_t`, the variables to which we're assigning are (by definition of `struct timeval`) a `time_t` or a `long` (depending on platform). We cast it because there is no alternative, and we otherwise generate hundreds of warnings. We cast to `decltype(...)` because the type is different depending on platform.
Review: https://reviews.apache.org/r/59865/ Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/10754aea Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/10754aea Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/10754aea Branch: refs/heads/master Commit: 10754aea690516f9003c8063a6ce5f3f2d592967 Parents: 83a6182 Author: Andrew Schwartzmeyer <[email protected]> Authored: Wed Jun 21 14:27:57 2017 -0700 Committer: Joseph Wu <[email protected]> Committed: Wed Jun 21 14:27:57 2017 -0700 ---------------------------------------------------------------------- 3rdparty/stout/include/stout/duration.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/10754aea/3rdparty/stout/include/stout/duration.hpp ---------------------------------------------------------------------- diff --git a/3rdparty/stout/include/stout/duration.hpp b/3rdparty/stout/include/stout/duration.hpp index 5608fbf..b0cd77b 100644 --- a/3rdparty/stout/include/stout/duration.hpp +++ b/3rdparty/stout/include/stout/duration.hpp @@ -99,8 +99,9 @@ public: // Explicitly compute `tv_sec` and `tv_usec` instead of using `us` and // `secs` to avoid converting `int64_t` -> `double` -> `long`. - t.tv_sec = ns() / SECONDS; - t.tv_usec = (ns() / MICROSECONDS) - (t.tv_sec * SECONDS / MICROSECONDS); + t.tv_sec = static_cast<decltype(t.tv_sec)>(ns() / SECONDS); + t.tv_usec = static_cast<decltype(t.tv_usec)>( + (ns() / MICROSECONDS) - (t.tv_sec * SECONDS / MICROSECONDS)); return t; }
