Skip to content

Commit

Permalink
added self state subscription validation
Browse files Browse the repository at this point in the history
  • Loading branch information
camilo committed Nov 24, 2023
1 parent 4cfcd25 commit 677eaf1
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/fsm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,16 +184,20 @@ void sm::state::topSelf( const sm::stateCallback_t topFcn, sm::state *init ) noe
/*============================================================================*/
bool sm::state::subscribe( sm::state *s, const sm::stateCallback_t sFcn, sm::state *init ) noexcept
{
s->lastRunningChild = init;
s->initState = init;
s->sCallback = sFcn;
s->parent = this;
s->tTable = nullptr;
s->tEntries = 0U;
s->tdef = nullptr;
s->nTm = 0U;

return true;
int retValue = false;

if ( ( s != this ) && ( init != this ) ) {
s->lastRunningChild = init;
s->initState = init;
s->sCallback = sFcn;
s->parent = this;
s->tTable = nullptr;
s->tEntries = 0U;
s->tdef = nullptr;
s->nTm = 0U;
retValue = true;
}
return retValue;
}
/*============================================================================*/
bool sm::state::setTransitions( sm::transition_t *table, size_t n ) noexcept
Expand Down

0 comments on commit 677eaf1

Please sign in to comment.