| 99 | } |
| 100 | |
| 101 | static inline void cs_fsm_state_set (struct cs_fsm* fsm, int32_t next_state, void* data, cs_fsm_cb cb) |
| 102 | { |
| 103 | int i; |
| 104 | struct cs_fsm_entry *entry = &fsm->table[fsm->curr_entry]; |
| 105 | |
| 106 | if (fsm->curr_state == next_state) { |
| 107 | return; |
| 108 | } |
| 109 | /* |
| 110 | * confirm that "next_state" is in the current entry's next list |
| 111 | */ |
| 112 | for (i = 0; i < CS_FSM_NEXT_STATE_SIZE; i++) { |
| 113 | if (entry->next_states[i] < 0) { |
| 114 | break; |
| 115 | } |
| 116 | if (entry->next_states[i] == next_state) { |
| 117 | if (cb != NULL) { |
| 118 | cb(fsm, CS_FSM_CB_EVENT_STATE_SET, fsm->curr_state, next_state, entry->event, data); |
| 119 | } |
| 120 | fsm->curr_state = next_state; |
| 121 | return; |
| 122 | } |
| 123 | } |
| 124 | if (cb != NULL) { |
| 125 | cb(fsm, CS_FSM_CB_EVENT_STATE_SET_NF, fsm->curr_state, next_state, entry->event, data); |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | #endif /* FSM_H_DEFINED */ |
| 130 |
no outgoing calls
no test coverage detected