Re: itimerdecr(): simplify code

2019-07-25 Thread Todd C . Miller
On Thu, 25 Jul 2019 11:00:03 -0500, Scott Cheloha wrote: > > However, if the "itp->it_value.tv_sec >= 0" is true, that means > > that "itp->it_value.tv_sec" must also be true. > > which is not correct, as itp->it_value.tv_sec could be zero. Sigh, still too early I guess. > What we really want to

Re: itimerdecr(): simplify code

2019-07-25 Thread Scott Cheloha
On Thu, Jul 25, 2019 at 09:37:20AM -0600, Todd C. Miller wrote: > On Thu, 25 Jul 2019 09:53:42 -0500, Scott Cheloha wrote: > > > Woohoo, slow morning, nearly missed that bug. Your conditional > > is incorrect because it rejects timevals of whole seconds, e.g. > > tv_sec == 1 and tv_usec == 0. >

Re: itimerdecr(): simplify code

2019-07-25 Thread Todd C . Miller
On Thu, 25 Jul 2019 09:53:42 -0500, Scott Cheloha wrote: > Woohoo, slow morning, nearly missed that bug. Your conditional > is incorrect because it rejects timevals of whole seconds, e.g. > tv_sec == 1 and tv_usec == 0. Whoops, too early for me I guess. However, as I think about this further, c

Re: itimerdecr(): simplify code

2019-07-25 Thread Todd C . Miller
On Thu, 25 Jul 2019 09:47:53 -0500, Scott Cheloha wrote: > I've been thinking for a while about adding another macro to sys/time.h > to handle this very common case, "timerisexpired": > > #define timerisexpired(tv) ((tv)->tv_sec < 0 || !timerisset((tv))) > > for chipping away at relative timeouts.

Re: itimerdecr(): simplify code

2019-07-25 Thread Scott Cheloha
On Thu, Jul 25, 2019 at 09:47:53AM -0500, Scott Cheloha wrote: > On Thu, Jul 25, 2019 at 08:33:25AM -0600, Todd C. Miller wrote: > > 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 easi

Re: itimerdecr(): simplify code

2019-07-25 Thread Scott Cheloha
On Thu, Jul 25, 2019 at 08:33:25AM -0600, Todd C. Miller wrote: > 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 co

Re: itimerdecr(): simplify code

2019-07-25 Thread Todd C . Miller
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 t

itimerdecr(): simplify code

2019-07-24 Thread Scott Cheloha
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