From 5f930f07fb9fa11e081af4154ec40106305fbdd7 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Fri, 17 Jul 2009 14:21:28 +0000 Subject: 2009-07-17 Joel Sherrill * score/src/watchdogadjusttochain.c: Correct bug in recent rework. Coverage not impacted. --- cpukit/score/src/watchdogadjusttochain.c | 63 +++++++++++++++++--------------- 1 file changed, 34 insertions(+), 29 deletions(-) (limited to 'cpukit/score/src/watchdogadjusttochain.c') diff --git a/cpukit/score/src/watchdogadjusttochain.c b/cpukit/score/src/watchdogadjusttochain.c index 6fedb9d0e1..0578276429 100644 --- a/cpukit/score/src/watchdogadjusttochain.c +++ b/cpukit/score/src/watchdogadjusttochain.c @@ -33,46 +33,51 @@ void _Watchdog_Adjust_to_chain( ISR_Level level; Watchdog_Control *first; - if ( !units ) + if ( units <= 0 ) { return; + } _ISR_Disable( level ); - if ( !_Chain_Is_empty( header ) ) { - while ( units ) { - first = _Watchdog_First( header ); + while ( 1 ) { + if ( units <= 0 ) { + break; + } + if ( _Chain_Is_empty( header ) ) { + break; + } + first = _Watchdog_First( header ); - /* - * If it is longer than "units" until the first element on the chain - * fires, then bump it and quit. - */ - if ( units < first->delta_interval ) { - first->delta_interval -= units; - break; - } + /* + * If it is longer than "units" until the first element on the chain + * fires, then bump it and quit. + */ + if ( units < first->delta_interval ) { + first->delta_interval -= units; + break; + } - /* - * The first set happens in less than units, so take all of them - * off the chain and adjust units to reflect this. - */ - units -= first->delta_interval; - first->delta_interval = 0; + /* + * The first set happens in less than units, so take all of them + * off the chain and adjust units to reflect this. + */ + units -= first->delta_interval; + first->delta_interval = 0; - while (1) { - _Chain_Extract_unprotected( &first->Node ); - _Chain_Append_unprotected( to_fire, &first->Node ); + while ( 1 ) { + _Chain_Extract_unprotected( &first->Node ); + _Chain_Append_unprotected( to_fire, &first->Node ); _ISR_Flash( level ); - - if ( _Chain_Is_empty( header ) ) - break; - - first = _Watchdog_First( header ); - if ( first->delta_interval != 0 ) - break; - } + + if ( _Chain_Is_empty( header ) ) + break; + first = _Watchdog_First( header ); + if ( first->delta_interval != 0 ) + break; } } + _ISR_Enable( level ); } -- cgit v1.2.3