Le Mon, Oct 17, 2022 at 11:49:31AM +0200, Claudio Jeker a écrit : > On Wed, Oct 12, 2022 at 12:12:25PM +0200, Theo Buehler wrote: > > On Fri, Oct 07, 2022 at 12:37:10PM +0200, Claudio Jeker wrote: > > > > +void > > > +ometric_set_state(struct ometric *om, const char *state, struct olabels > > > *ol) > > > +{ > > > + struct olabels *extra; > > > + size_t i; > > > + int val; > > > + > > > + if (om->type != OMT_STATESET) > > > + errx(1, "%s incorrect ometric type", __func__); > > > + > > > + for (i = 0; i < om->setsize; i++) { > > > + if (strcasecmp(state, om->stateset[i]) == 0) > > > + val = 1; > > > + else > > > + val = 0; > > > > could simplify this to > > > > val = strcasecmp(state, om->stateset[i]) == 0; > > > > but I'm not sure if this is more readable > > Not sure either. I prefer the explicit version. So I left the code as is. >
I agree, let the code be easy to read. The compiler will optimise accordingly. BTW, thank you for working on this Claudio.