http://codereview.chromium.org/115918/diff/1/2
File test/cctest/test-log.cc (right):

http://codereview.chromium.org/115918/diff/1/2#newcode173
Line 173: while ((delta = i::OS::Ticks() - started_us) < 200 * 1000) {
On 2009/05/29 12:19:49, William Hesse wrote:
> The condition should really be
> (ended_us = ticks()) < started_us + 200 * 1000)
> delta_us = ended_us - started_us;
> in order to correctly compare unsigneds, because the difference of two
unsigneds
> cannot be negative.



Actually, we don't really understand what is going on.  I think
converting to unsigned is the wrong idea, though.  OS::Ticks should not
be anywhere near the negative range, and tv_secs and tv_usecs (used in
GetTimeOfDay, used by OS::Ticks) should also be safe.

I think the best practice is to put two times you want to compare on
opposite sides of the comparison operator, rather than subtracting them.
  It should be fine to leave them as ints, too.

if (end_time < start_time + desired delta)
is valid as long as end_time and start_time + desired delta
are in the valid range of the type.

But I don't see how the change to uint is supposed to help.

http://codereview.chromium.org/115918

--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
v8-dev@googlegroups.com
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to