----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/11331/#review25248 -----------------------------------------------------------
Should Duration::create also guard against being less than LLONG_MIN? 3rdparty/libprocess/3rdparty/stout/include/stout/duration.hpp <https://reviews.apache.org/r/11331/#comment49741> Is this reliable? The spec does not specify how this behaves, see section 5 of the C++ spec: "If during the evaluation of an expression, the result is not mathematically defined or not in the range of rep- resentable values for its type, the behavior is undefined, unless such an expression is a constant expression (5.19), in which case the program is ill-formed. [Note: most existing implementations of C++ ignore integer overflows. ..." Most C++ implementations will do the right thing (I think), but I would prefer to be explicit rather than relying on overflow: e.g. if (duration_ < Duration::zero()) { stream << '-'; // Duration::min() may not be representable as a positive Duration. if (duration_ == Duration::min()) { duration = Duration::max(); } else { duration = duration_ * -1; } } I say "may" because LLONG_MIN is -9223372036854775807 (-263+1) or less. LLONG_MAX is 9223372036854775807 (263-1) or greater. 3rdparty/libprocess/3rdparty/stout/include/stout/duration.hpp <https://reviews.apache.org/r/11331/#comment49742> s/The following branches first/First/ 3rdparty/libprocess/3rdparty/stout/include/stout/duration.hpp <https://reviews.apache.org/r/11331/#comment49743> s/whether a whole number can be outputted/ whether the duration can be represented as a whole number/ 3rdparty/libprocess/3rdparty/stout/include/stout/duration.hpp <https://reviews.apache.org/r/11331/#comment49744> s/Same in the branches below// 3rdparty/libprocess/3rdparty/stout/tests/duration_tests.cpp <https://reviews.apache.org/r/11331/#comment49737> s/b/B/ - Ben Mahler On Aug. 15, 2013, 8:39 p.m., Jiang Yan Xu wrote: > > ----------------------------------------------------------- > This is an automatically generated e-mail. To reply, visit: > https://reviews.apache.org/r/11331/ > ----------------------------------------------------------- > > (Updated Aug. 15, 2013, 8:39 p.m.) > > > Review request for mesos, Benjamin Hindman, Ben Mahler, and Vinod Kone. > > > Bugs: MESOS-477 > https://issues.apache.org/jira/browse/MESOS-477 > > > Repository: mesos > > > Description > ------- > > - Currently when the result isn't a whole number, we go one-level down in > terms of the unit of time and see if we can get a whole number there. If so, > use the lower unit; if not, use the higher unit. > > > Diffs > ----- > > 3rdparty/libprocess/3rdparty/stout/include/stout/duration.hpp > 47e85ff8bbb310475dea382bfca9389c4295cf77 > 3rdparty/libprocess/3rdparty/stout/tests/duration_tests.cpp > e0910d4c82c2289f8d08deadbf4a8ef0448d0f76 > > Diff: https://reviews.apache.org/r/11331/diff/ > > > Testing > ------- > > make check > > > Thanks, > > Jiang Yan Xu > >
