On Wed, 24 Jul 2019 19:05:16 -0500, Scott Cheloha wrote: > We can simplify the itimerdecr() code with the sys/time.h macros. > I think this is a lot easier to decipher. > > With the macros we don't need special logic to correctly handle the > reload if the decrement exceeds the time remaining in the itimer. > > With the loop we now correctly handle decrements larger than our > interval. Maybe someone can make use of that. Using the loop instead > of just an if-clause doesn't complicate our code so I figure we might > as well do the right thing in that case.
This looks correct and is much shorter. I do find mixing explicit checks of tv_sec with timerisset a little confusing, but maybe that is just me. For example, instead of this: if (itp->it_value.tv_sec >= 0 && timerisset(&itp->it_value)) I find the following easier to read: if (itp->it_value.tv_sec >= 0 && itp->it_value.tv_usec > 0) (yes, I know the tv_usec could just be != 0). OK millert@ either way, - todd