Explorar o código

s-s-d: Cleanup timespec_mul()

Guillem Jover %!s(int64=11) %!d(string=hai) anos
pai
achega
349f9c3569
Modificáronse 1 ficheiros con 4 adicións e 3 borrados
  1. 4 3
      utils/start-stop-daemon.c

+ 4 - 3
utils/start-stop-daemon.c

@@ -344,10 +344,11 @@ timespec_sub(struct timespec *a, struct timespec *b, struct timespec *res)
 static void
 timespec_mul(struct timespec *a, int b)
 {
+	long nsec = a->tv_nsec * b;
+
 	a->tv_sec *= b;
-	a->tv_nsec *= b;
-	a->tv_sec = a->tv_sec + a->tv_nsec / NANOSEC_IN_SEC;
-	a->tv_nsec %= NANOSEC_IN_SEC;
+	a->tv_sec += nsec / NANOSEC_IN_SEC;
+	a->tv_nsec = nsec % NANOSEC_IN_SEC;
 }
 
 static char *