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, can't this be simplified even more?

Given:

if (itp->it_value.tv_sec >= 0 && timerisset(&itp->it_value))

that expands to:

if (itp->it_value.tv_sec >= 0 &&
    (itp->it_value.tv_sec || itp->it_value.tv_usec))

However, if the "itp->it_value.tv_sec >= 0" is true, that means
that "itp->it_value.tv_sec" must also be true.  So logically it
is the equivalent:

if (itp->it_value.tv_sec >= 0 && (1 || itp->it_value.tv_usec))

Which is can be simplied to just:

if (itp->it_value.tv_sec >= 0)

So the timerisset() call appears to be superfluous.  I see no case
where "itp->it_value.tv_sec >= 0" is true that timerisset(&itp->it_value)
is not also true.

Am I missing something?

 - todd

Reply via email to