You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@mesos.apache.org by Benjamin Bannier <bb...@apache.org> on 2019/08/01 08:37:22 UTC

Review Request 71224: Removed lossy `long` to `double` conversion in a test.

-----------------------------------------------------------
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


Re: Review Request 71224: Removed lossy `long` to `double` conversion in a test.

Posted by Andrei Sekretenko <as...@mesosphere.io>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/71224/#review217028
-----------------------------------------------------------


Ship it!




The comment has been totally misleaing before - fixing it was a right thing.

- Andrei Sekretenko


On Aug. 1, 2019, 9:03 a.m., Benjamin Bannier wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/71224/
> -----------------------------------------------------------
> 
> (Updated Aug. 1, 2019, 9:03 a.m.)
> 
> 
> Review request for mesos and Andrei Sekretenko.
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> 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.
> 
> 
> Diffs
> -----
> 
>   src/tests/master_tests.cpp b9ef13c31a9c3ae16e55d3ae8f9b1538a49cf49a 
> 
> 
> Diff: https://reviews.apache.org/r/71224/diff/3/
> 
> 
> Testing
> -------
> 
> `make check`
> 
> 
> Thanks,
> 
> Benjamin Bannier
> 
>


Re: Review Request 71224: Removed lossy `long` to `double` conversion in a test.

Posted by Benjamin Bannier <bb...@apache.org>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/71224/
-----------------------------------------------------------

(Updated Aug. 1, 2019, 11:03 a.m.)


Review request for mesos and Andrei Sekretenko.


Changes
-------

Tweak existing comment as suggested by asekretenko offline


Repository: mesos


Description
-------

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.


Diffs (updated)
-----

  src/tests/master_tests.cpp b9ef13c31a9c3ae16e55d3ae8f9b1538a49cf49a 


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

Changes: https://reviews.apache.org/r/71224/diff/2-3/


Testing
-------

`make check`


Thanks,

Benjamin Bannier