From 5b1614de0227b727d16443eec66c2f7900b7b1e3 Mon Sep 17 00:00:00 2001 From: Anthony Gutierrez Date: Mon, 27 Aug 2012 20:53:20 -0400 Subject: [PATCH] sim: fix overflow check in simulate because Tick is now unsigned --- src/sim/simulate.cc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/sim/simulate.cc b/src/sim/simulate.cc index 5e69f0ff4..238e68787 100644 --- a/src/sim/simulate.cc +++ b/src/sim/simulate.cc @@ -49,12 +49,10 @@ simulate(Tick num_cycles) { inform("Entering event queue @ %d. Starting simulation...\n", curTick()); - if (num_cycles < 0) - fatal("simulate: num_cycles must be >= 0 (was %d)\n", num_cycles); - else if (curTick() + num_cycles < 0) //Overflow - num_cycles = MaxTick; - else + if (num_cycles < MaxTick - curTick()) num_cycles = curTick() + num_cycles; + else // counter would roll over or be set to MaxTick anyhow + num_cycles = MaxTick; Event *limit_event = new SimLoopExitEvent("simulate() limit reached", 0); -- 2.30.2