From 10fd2b1180b7c298cfb593afd5c63ce26977a3cd Mon Sep 17 00:00:00 2001 From: Franck Bui Date: Wed, 15 Sep 2021 11:20:17 +0200 Subject: [PATCH] watchdog: use MIN() in update_timeout() Also the previous expression was probably wrong as "(int) t >= INT_MAX" is likely to always evaluate to false. --- src/shared/watchdog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shared/watchdog.c b/src/shared/watchdog.c index 53c7189e243..be100931f76 100644 --- a/src/shared/watchdog.c +++ b/src/shared/watchdog.c @@ -36,7 +36,7 @@ static int update_timeout(void) { usec_t t; t = DIV_ROUND_UP(watchdog_timeout, USEC_PER_SEC); - sec = (int) t >= INT_MAX ? INT_MAX : t; /* Saturate */ + sec = MIN(t, (usec_t) INT_MAX); /* Saturate */ if (ioctl(watchdog_fd, WDIOC_SETTIMEOUT, &sec) < 0) return log_warning_errno(errno, "Failed to set timeout to %is: %m", sec); -- 2.47.3