From 9692ead1978d022754f7da4376e0f225eb823fa8 Mon Sep 17 00:00:00 2001 From: Franck Bui Date: Mon, 6 Sep 2021 14:31:30 +0200 Subject: [PATCH] watchdog: minor simplification of watchdog_runtime_wait() No functional change. --- src/shared/watchdog.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/shared/watchdog.c b/src/shared/watchdog.c index 98532dbcb4..b0b377325c 100644 --- a/src/shared/watchdog.c +++ b/src/shared/watchdog.c @@ -120,20 +120,19 @@ int watchdog_set_timeout(usec_t timeout) { } usec_t watchdog_runtime_wait(void) { - usec_t rtwait, ntime; if (!timestamp_is_set(watchdog_timeout)) return USEC_INFINITY; /* Sleep half the watchdog timeout since the last successful ping at most */ if (timestamp_is_set(watchdog_last_ping)) { - ntime = now(clock_boottime_or_monotonic()); + usec_t ntime = now(clock_boottime_or_monotonic()); + assert(ntime >= watchdog_last_ping); - rtwait = usec_sub_unsigned(watchdog_last_ping + (watchdog_timeout / 2), ntime); - } else - rtwait = watchdog_timeout / 2; + return usec_sub_unsigned(watchdog_last_ping + (watchdog_timeout / 2), ntime); + } - return rtwait; + return watchdog_timeout / 2; } int watchdog_ping(void) { -- 2.25.1