@ -139,19 +139,14 @@ static bool smf_execute_ancestor_run_actions(struct smf_ctx *ctx)
struct internal_ctx * const internal = ( void * ) & ctx - > internal ;
struct internal_ctx * const internal = ( void * ) & ctx - > internal ;
/* Execute all run actions in reverse order */
/* Execute all run actions in reverse order */
/* Return if the current state switched states */
if ( internal - > new_state ) {
internal - > new_state = false ;
return false ;
}
/* Return if the current state terminated */
/* Return if the current state terminated */
if ( internal - > terminate ) {
if ( internal - > terminate ) {
return true ;
return true ;
}
}
if ( internal - > handled ) {
/* The child state either transitioned or handled it. Either way, stop propagating. */
/* Event was handled by this state. Stop propagating */
if ( internal - > new_state | | internal - > handled ) {
internal - > new_state = false ;
internal - > handled = false ;
internal - > handled = false ;
return false ;
return false ;
}
}
@ -169,19 +164,16 @@ static bool smf_execute_ancestor_run_actions(struct smf_ctx *ctx)
return true ;
return true ;
}
}
if ( internal - > new_state ) {
/* This state dealt with it. Stop propagating. */
break ;
if ( internal - > new_state | | internal - > handled ) {
}
if ( internal - > handled ) {
/* Event was handled by this state. Stop propagating */
internal - > handled = false ;
break ;
break ;
}
}
}
}
}
}
internal - > new_state = false ;
internal - > new_state = false ;
internal - > handled = false ;
/* All done executing the run actions */
/* All done executing the run actions */
return false ;
return false ;
@ -231,6 +223,8 @@ void smf_set_initial(struct smf_ctx *ctx, const struct smf_state *init_state)
internal - > is_exit = false ;
internal - > is_exit = false ;
internal - > terminate = false ;
internal - > terminate = false ;
internal - > handled = false ;
internal - > new_state = false ;
ctx - > current = init_state ;
ctx - > current = init_state ;
ctx - > previous = NULL ;
ctx - > previous = NULL ;
ctx - > terminate_val = 0 ;
ctx - > terminate_val = 0 ;