- if (last_tv_valid) {
- if (tp->tv_sec < last_tv.tv_sec)
- tp->tv_sec = last_tv.tv_sec;
- else if (last_tv.tv_sec == tp->tv_sec &&
- tp->tv_usec < last_tv.tv_usec)
- tp->tv_usec = last_tv.tv_usec;
+ if (tv) {
+ if (tv->last_tv_valid) {
+ if (tp->tv_sec < tv->last_tv.tv_sec)
+ tp->tv_sec = tv->last_tv.tv_sec;
+ else if (tv->last_tv.tv_sec == tp->tv_sec &&
+ tp->tv_usec < tv->last_tv.tv_usec)
+ tp->tv_usec = tv->last_tv.tv_usec;
+ }
+ tv->last_tv_valid = 1;
+ memcpy(&tv->last_tv, tp, sizeof(*tp));