This is an automated email from the ASF dual-hosted git repository. bbannier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mesos.git
commit 731e90e8adb0560221db4703b449282c3906914b Author: Benjamin Bannier <[email protected]> AuthorDate: Thu Aug 1 10:30:56 2019 +0200 Removed lossy `long` to `double` conversion in a test. The code intends to construct a seconds value too large to fit into the internal representation in nanoseconds, but since the `long` value was passed to a function expecting a `double` the value will implicitly be converted. As the `long` value is large, `double` is not able to represent all possible `long` values which can lead to lossy conversions. This is exactly what happened here. Recent clang has a warning to catch such issues at compile time if possible, ``` ../src/tests/master_tests.cpp:7194:34: warning: implicit conversion from 'long' to 'double' changes value from 99999999999999999 to 1.0E+17 [-Wimplicit-int-float-conversion] framework.set_failover_timeout(99999999999999999); ~~~~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~ ``` This patch changes the value to `1e+17` (a `double` value) which removes the lossy conversion, and still accomplishes what the test required. Review: https://reviews.apache.org/r/71224 --- src/tests/master_tests.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/tests/master_tests.cpp b/src/tests/master_tests.cpp index b9ef13c..0a1ba41 100644 --- a/src/tests/master_tests.cpp +++ b/src/tests/master_tests.cpp @@ -7188,10 +7188,10 @@ TEST_F(MasterTest, RejectFrameworkWithInvalidFailoverTimeout) FrameworkInfo framework = DEFAULT_FRAMEWORK_INFO; // Add invalid failover timeout to the FrameworkInfo. - // As the timeout is represented using nanoseconds as an int64, the - // following value converted to seconds is too large and does not - // fit in int64. - framework.set_failover_timeout(99999999999999999); + // As the timeout is internally represented using nanoseconds as an + // int64, the following value in seconds is too large and cannot be + // internally represented. + framework.set_failover_timeout(1e+17); MockScheduler sched; MesosSchedulerDriver driver(
