Don't trt yo be smart with the comma operator
This commit is contained in:
+8
-4
@@ -6,8 +6,10 @@ uc_tvadd(struct timeval *dst, const struct timeval *a, const struct timeval *b)
|
||||
dst->tv_sec = a->tv_sec + b->tv_sec;
|
||||
dst->tv_usec = a->tv_usec + b->tv_usec;
|
||||
|
||||
if (dst->tv_usec >= 1000000)
|
||||
dst->tv_sec++, dst->tv_usec -= 1000000;
|
||||
if (dst->tv_usec >= 1000000) {
|
||||
dst->tv_sec++;
|
||||
dst->tv_usec -= 1000000;
|
||||
}
|
||||
|
||||
return dst;
|
||||
}
|
||||
@@ -18,8 +20,10 @@ uc_tvsub(struct timeval *dst, const struct timeval *a, const struct timeval *b)
|
||||
dst->tv_sec = a->tv_sec - b->tv_sec;
|
||||
dst->tv_usec = a->tv_usec - b->tv_usec;
|
||||
|
||||
if (dst->tv_usec < 0)
|
||||
dst->tv_sec--, dst->tv_usec += 1000000;
|
||||
if (dst->tv_usec < 0) {
|
||||
dst->tv_sec--;
|
||||
dst->tv_usec += 1000000;
|
||||
}
|
||||
|
||||
return dst;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user