The current code doesn't work correctly if negative values are used.
The code could of course be changed to handle them, but maybe assert is
better to catch bugs.
static inline void
timeval_add_usecs(struct timeval *tv, long long usecs)
{
+ i_assert(usecs >= 0);
tv->tv_sec += usecs / 1000000;
tv->tv_usec += (usecs % 1000000);
if (tv->tv_usec >= 1000000) {
static inline void
timeval_sub_usecs(struct timeval *tv, long long usecs)
{
+ i_assert(usecs >= 0);
tv->tv_sec -= usecs / 1000000;
tv->tv_usec -= (usecs % 1000000);
if (tv->tv_usec < 0) {