> > 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.