Skip to content

Commit

Permalink
mod_sonic: add extra checks on state-change
Browse files Browse the repository at this point in the history
  • Loading branch information
sflow committed Jun 7, 2024
1 parent 546a696 commit 1111f1f
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/Linux/mod_sonic.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ extern "C" {
HSP_SONIC_STATE_DISCOVER,
HSP_SONIC_STATE_DISCOVER_MAPPING,
HSP_SONIC_STATE_DISCOVER_LAGS,
HSP_SONIC_STATE_RUN } EnumSonicState;
HSP_SONIC_STATE_RUN
} EnumSonicState;

static const char *SonicStateNames[] = {
"INIT",
Expand Down Expand Up @@ -266,9 +267,13 @@ extern "C" {

static void setSonicState(EVMod *mod, EnumSonicState st) {
HSP_mod_SONIC *mdata = (HSP_mod_SONIC *)mod->data;
EVDebug(mod, 1, "state %s -> %s",
SonicStateNames[mdata->state],
SonicStateNames[st]);
assert(mdata->state >= HSP_SONIC_STATE_INIT
&& mdata->state <= HSP_SONIC_STATE_RUN);
assert(st >= HSP_SONIC_STATE_INIT
&& st <= HSP_SONIC_STATE_RUN);
char *from = (char *)SonicStateNames[mdata->state];
char *to = (char *)SonicStateNames[st];
EVDebug(mod, 1, "state %s -> %s", from, to);
mdata->state = st;
}

Expand Down

0 comments on commit 1111f1f

Please sign in to comment.