return a value (and rename) testTurtleTime instead of passing in a flag to set

This commit is contained in:
Mitchell Livingston 2012-09-18 03:44:59 +00:00
parent ddabdcb1c7
commit 40e75b20ed
1 changed files with 7 additions and 11 deletions

View File

@ -1321,12 +1321,11 @@ useAltSpeed( tr_session * s, struct tr_turtle_info * t,
} }
/** /**
* @param enabled whether turtle should be on/off according to the scheduler * return whether turtle should be on/off according to the scheduler
*/ */
static void static bool
testTurtleTime( const struct tr_turtle_info * t, bool * enabled ) getInTurtleTime( const struct tr_turtle_info * t )
{ {
bool e;
struct tm tm; struct tm tm;
size_t minute_of_the_week; size_t minute_of_the_week;
const time_t now = tr_time( ); const time_t now = tr_time( );
@ -1339,9 +1338,7 @@ testTurtleTime( const struct tr_turtle_info * t, bool * enabled )
if( minute_of_the_week >= MINUTES_PER_WEEK ) /* leap minutes? */ if( minute_of_the_week >= MINUTES_PER_WEEK ) /* leap minutes? */
minute_of_the_week = MINUTES_PER_WEEK - 1; minute_of_the_week = MINUTES_PER_WEEK - 1;
e = tr_bitfieldHas( &t->minutes, minute_of_the_week ); return tr_bitfieldHas( &t->minutes, minute_of_the_week );
if( enabled != NULL )
*enabled = e;
} }
static inline tr_auto_switch_state_t static inline tr_auto_switch_state_t
@ -1359,7 +1356,7 @@ turtleCheckClock( tr_session * s, struct tr_turtle_info * t )
assert( t->isClockEnabled ); assert( t->isClockEnabled );
testTurtleTime( t, &enabled ); enabled = getInTurtleTime( t );
newAutoTurtleState = autoSwitchState( enabled ); newAutoTurtleState = autoSwitchState( enabled );
alreadySwitched = ( t->autoTurtleState == newAutoTurtleState ); alreadySwitched = ( t->autoTurtleState == newAutoTurtleState );
@ -1386,7 +1383,7 @@ turtleBootstrap( tr_session * session, struct tr_turtle_info * turtle )
if( turtle->isClockEnabled ) if( turtle->isClockEnabled )
{ {
testTurtleTime( turtle, &turtle->isEnabled ); turtle->isEnabled = getInTurtleTime( turtle );
turtle->autoTurtleState = autoSwitchState( turtle->isEnabled ); turtle->autoTurtleState = autoSwitchState( turtle->isEnabled );
} }
@ -1495,8 +1492,7 @@ userPokedTheClock( tr_session * s, struct tr_turtle_info * t )
if( t->isClockEnabled ) if( t->isClockEnabled )
{ {
bool enabled; const bool enabled = getInTurtleTime( t );
testTurtleTime( t, &enabled );
useAltSpeed( s, t, enabled, true ); useAltSpeed( s, t, enabled, true );
t->autoTurtleState = autoSwitchState( enabled ); t->autoTurtleState = autoSwitchState( enabled );
} }