mesos-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Benjamin Bannier <bbann...@apache.org>
Subject Review Request 71224: Removed lossy `long` to `double` conversion in a test.
Date Thu, 01 Aug 2019 08:37:22 GMT

-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/71224/
-----------------------------------------------------------

Review request for mesos and Andrei Sekretenko.


Repository: mesos


Description
-------

The code intends to construct a seconds value to 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.


Diffs
-----

  src/tests/master_tests.cpp b9ef13c31a9c3ae16e55d3ae8f9b1538a49cf49a 


Diff: https://reviews.apache.org/r/71224/diff/1/


Testing
-------

`make check`


Thanks,

Benjamin Bannier


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message