On Wed, Dec 27 2017, "Theo de Raadt" <dera...@openbsd.org> wrote:
>> > Since timespecs also use tv_* prefixes, a hint about the other sub-second
>> > field is being lost, also, sometimes the clearing of the sub-second field
>> > isn't in the same place it is missing.
>> 
>> What do you have in mind when you say "sub-second initialization"?  The
>> idea is to use time(3) when all you need is *seconds*.
>
> These pieces of code use struct timeval or struct timespec.
>
> Both fields should be initialized.  Otherwise someone may use
> unintialized data in future revamp of the code.
>
> Using gettimeofday() avoids that problem.  Using time() to manually set
> the tv_sec field without the other field is a red flag.  It makes me
> hunt for the place where the sub-second field is set to 0.
>
> Using time() isn't solving a problem without introducing a new one.
> gettimeofday() is the right function for managing struct timeval and
> ensuring the structure is fully managed.  I don't understand why you
> don't realize time.c properly initialized a struct timeval, then the
> proper initialization is thrown away, requiring a manual initialization?
>
> WHY.

Look at the three diffs (two have been committed) that replaced
gettimeofday(2) with time(3), all of them also removed the struct
timeval involved, because only a time_t is useful.  So there is no
tv_usec field left to initialize, and less things to care about.

-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE

Reply via email to