]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
service: explicitly cast float to usec_t
authorLennart Poettering <lennart@poettering.net>
Thu, 6 Jul 2023 09:21:32 +0000 (11:21 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 6 Jul 2023 09:21:35 +0000 (11:21 +0200)
Let's cast these floats explicitly to usec_t, since implicit
float-to-integer casts are dangerous business, and we should underline
that there's a cast happening here.

src/core/service.c

index efe6c23f0ce7c8207be1922c0dd9e6a090b250c6..a90b4de536ed3fd44b56956df006a836a51a2426 100644 (file)
@@ -311,8 +311,8 @@ usec_t service_restart_usec_next(Service *s) {
                  *   r_n : maximum restart usec (s->restart_max_delay_usec),
                  *   i : index of the next step (n_restarts_next - 1)
                  *   n : num maximum steps (s->restart_steps) */
-                value = s->restart_usec * powl((long double) s->restart_max_delay_usec / s->restart_usec,
-                                               (long double) (n_restarts_next - 1) / s->restart_steps);
+                value = (usec_t) (s->restart_usec * powl((long double) s->restart_max_delay_usec / s->restart_usec,
+                                                         (long double) (n_restarts_next - 1) / s->restart_steps));
         }
 
         log_unit_debug(UNIT(s), "Next restart interval calculated as: %s", FORMAT_TIMESPAN(value, 0));