Delay with IDLE sleep mode, please check

Please check my code.
I think that the rollover is fixed if the delay is not 0, 1 or 2 or so.
Can someone confirm the sleep mode and the rollover will be okay ?

I have a ATmega8L running at 3.3V at 8MHz with a few sensors.
My goal is to reduce some current in a simple way.
The IDLE mode stops the cpu clock but everything else keeps on running, inclusive the TIMER0 for millis().

At 3.3V : 7.7mA with delay(), 3.9mA with delaySleep().
At 5V : 13.8mA with delay(), 7.4mA with delaySleep().
I’m very happy with these numbers.

// -------------------------------------
// delaySleep
// ------------
//   A function to replace the delay() function
//   to reduce the power.
//
//   To fix the rollover of millis(), see the second part of:
//   http://playground.arduino.cc/Code/TimingRollover
//
//   The delay is not accurate, and a small delay will go wrong.
//   Use a value of 10 or more.
//
void delaySleep( unsigned long t)
{
  unsigned long ul_startMillis = millis();
  unsigned long ul_currentMillis;

  set_sleep_mode (SLEEP_MODE_IDLE);  
  
  do
  { 
    sleep_mode();
    ul_currentMillis = millis();
  } while( ul_currentMillis - ul_startMillis < t);
}

CORRECTION: the ‘while’ was on a new line, that was confusing.

If I am reading this right

  while( ul_currentMillis - ul_startMillis < t);

nothing in this loop is updating any of the variables used in the comparison. Will the while loop ever end ?

I am quite prepared to accept that I have missed something, but what ?

UKHeliBob:
If I am reading this right

  while( ul_currentMillis - ul_startMillis < t);

nothing in this loop is updating any of the variables used in the comparison. Will the while loop ever end ?

I am quite prepared to accept that I have missed something, but what ?

You missed the body of the loop:

do
  { 
    sleep_mode();
    ul_currentMillis = millis();
  }
  while( ul_currentMillis - ul_startMillis < t);

It is confusing that the ‘while’ part of a do-while loop looks like an empty while loop.

Sorry, I accidenlty wrote the 'while' on a new line. I have corrected it now.

Thanks John. I can see why I was confused.