From: Tobias Stoeckmann Date: Sun, 29 Jun 2025 11:40:46 +0000 (+0200) Subject: util: Use local variable in get_backoff_delta_msec X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9c1a363e3eca30646351962e7d3a172c862afb69;p=thirdparty%2Fkmod.git util: Use local variable in get_backoff_delta_msec This might make the code easier to read. Signed-off-by: Tobias Stoeckmann Link: https://github.com/kmod-project/kmod/pull/377 Signed-off-by: Lucas De Marchi --- diff --git a/shared/util.c b/shared/util.c index 58672a9f..b4ce172a 100644 --- a/shared/util.c +++ b/shared/util.c @@ -536,32 +536,34 @@ int sleep_until_msec(unsigned long long msec) unsigned long long get_backoff_delta_msec(unsigned long long tend, unsigned long long *delta) { - unsigned long long t; + unsigned long long d, t; + d = *delta; t = now_msec(); if (tend <= t) { /* Timeout already reached */ - *delta = 0; + d = 0; } else { const unsigned long long limit = tend - t; /* Double the amount of requested delta, if possible */ - if (!*delta) - *delta = 1; - else if (umulll_overflow(*delta, 2, delta)) - *delta = ULLONG_MAX; + if (!d) + d = 1; + else if (umulll_overflow(d, 2, &d)) + d = ULLONG_MAX; /* Search for a fitting backoff delta */ - while (*delta > limit) - *delta >>= 1; + while (d > limit) + d >>= 1; /* If none found, use maximum wait time */ - if (!*delta) - *delta = limit; + if (!d) + d = limit; } - return t + *delta; + *delta = d; + return t + d; } unsigned long long now_usec(void)