Skip to content

Commit

Permalink
lib: smf: fix ctx->executing in smf_execute_all_entry_actions
Browse files Browse the repository at this point in the history
Fix ctx->executing is not updated in smf_execute_all_entry_actions()

Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
  • Loading branch information
ccli8 authored and nashif committed Jun 12, 2024
1 parent eae0900 commit 55a988e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/smf/smf.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ static bool smf_execute_all_entry_actions(struct smf_ctx *const ctx,
for (const struct smf_state *to_execute = get_child_of(new_state, topmost);
to_execute != NULL && to_execute != new_state;
to_execute = get_child_of(new_state, to_execute)) {
/* Keep track of the executing entry action in case it calls
* smf_set_state()
*/
ctx->executing = to_execute;
/* Execute every entry action EXCEPT that of the topmost state */
if (to_execute->entry) {
/* Keep track of the executing entry action in case it calls
* smf_set_State()
*/
ctx->executing = to_execute;
to_execute->entry(ctx);

/* No need to continue if terminate was set */
Expand All @@ -114,6 +114,7 @@ static bool smf_execute_all_entry_actions(struct smf_ctx *const ctx,
}

/* and execute the new state entry action */
ctx->executing = new_state;
if (new_state->entry) {
new_state->entry(ctx);

Expand Down

0 comments on commit 55a988e

Please sign in to comment.