On Sat, Jul 01, 2017 at 05:53:54PM -0400, Rob Pierce wrote: > never.never say always.always. > > Rename one of the "always" variables to "body" for improved readability. > > No functional change. > > >From ifstated.conf(5): > > "Each state consistes of an init block and a body. The init block is used > to initialize the state and is executed each time the state is entered. > The body of a state is only executed when that state is the current state > and an event occurs." > > Rob
I agree with this change. Could you make the same change for struct ifsd_config in a follow-up diff? > Index: ifstated.c > =================================================================== > RCS file: /cvs/src/usr.sbin/ifstated/ifstated.c,v > retrieving revision 1.45 > diff -u -p -r1.45 ifstated.c > --- ifstated.c 28 Jun 2017 11:10:08 -0000 1.45 > +++ ifstated.c 1 Jul 2017 21:49:47 -0000 > @@ -218,7 +218,7 @@ load_config(void) > conf->nextstate = conf->curstate; > conf->curstate = NULL; > while (state_change()) > - do_action(conf->curstate->always); > + do_action(conf->curstate->body); > } > return (0); > } > @@ -530,9 +530,9 @@ eval_state(struct ifsd_state *state) > struct ifsd_external *external = TAILQ_FIRST(&state->external_tests); > if (external == NULL || external->lastexec >= state->entered || > external->lastexec == 0) { > - do_action(state->always); > + do_action(state->body); > while (state_change()) > - do_action(conf->curstate->always); > + do_action(conf->curstate->body); > } > } > > @@ -639,12 +639,12 @@ clear_config(struct ifsd_config *oconf) > while ((state = TAILQ_FIRST(&oconf->states)) != NULL) { > TAILQ_REMOVE(&oconf->states, state, entries); > remove_action(state->init, state); > - remove_action(state->always, state); > + remove_action(state->body, state); > free(state->name); > free(state); > } > remove_action(oconf->always.init, &oconf->always); > - remove_action(oconf->always.always, &oconf->always); > + remove_action(oconf->always.body, &oconf->always); > free(oconf); > } > > Index: ifstated.h > =================================================================== > RCS file: /cvs/src/usr.sbin/ifstated/ifstated.h,v > retrieving revision 1.12 > diff -u -p -r1.12 ifstated.h > --- ifstated.h 28 Jun 2017 11:10:08 -0000 1.12 > +++ ifstated.h 1 Jul 2017 21:49:47 -0000 > @@ -110,7 +110,7 @@ struct ifsd_state { > struct ifsd_external_list external_tests; > TAILQ_ENTRY(ifsd_state) entries; > struct ifsd_action *init; > - struct ifsd_action *always; > + struct ifsd_action *body; > u_int32_t entered; > char *name; > }; > Index: parse.y > =================================================================== > RCS file: /cvs/src/usr.sbin/ifstated/parse.y,v > retrieving revision 1.41 > diff -u -p -r1.41 parse.y > --- parse.y 18 Jun 2017 12:03:47 -0000 1.41 > +++ parse.y 1 Jul 2017 21:49:47 -0000 > @@ -245,9 +245,9 @@ init : INIT { > curaction = conf->always.init; > } action_block { > if (curstate != NULL) > - curaction = curstate->always; > + curaction = curstate->body; > else > - curaction = conf->always.always; > + curaction = conf->always.body; > } > ; > > @@ -339,11 +339,11 @@ state : STATE string { > init_state(state); > state->name = $2; > curstate = state; > - curaction = state->always; > + curaction = state->body; > } optnl '{' optnl stateopts_l '}' { > TAILQ_INSERT_TAIL(&conf->states, curstate, entries); > curstate = NULL; > - curaction = conf->always.always; > + curaction = conf->always.body; > } > ; > > @@ -747,7 +747,7 @@ parse_config(char *filename, int opts) > TAILQ_INIT(&conf->states); > > init_state(&conf->always); > - curaction = conf->always.always; > + curaction = conf->always.body; > conf->opts = opts; > > yyparse(); > @@ -755,7 +755,7 @@ parse_config(char *filename, int opts) > /* Link states */ > TAILQ_FOREACH(state, &conf->states, entries) { > link_states(state->init); > - link_states(state->always); > + link_states(state->body); > } > > errors = file->errors; > @@ -928,10 +928,10 @@ init_state(struct ifsd_state *state) > state->init->type = IFSD_ACTION_CONDITION; > TAILQ_INIT(&state->init->act.c.actions); > > - if ((state->always = calloc(1, sizeof(*state->always))) == NULL) > + if ((state->body = calloc(1, sizeof(*state->body))) == NULL) > err(1, "init_state: calloc"); > - state->always->type = IFSD_ACTION_CONDITION; > - TAILQ_INIT(&state->always->act.c.actions); > + state->body->type = IFSD_ACTION_CONDITION; > + TAILQ_INIT(&state->body->act.c.actions); > } > > struct ifsd_ifstate * >