From: Franck Bui Date: Wed, 15 Sep 2021 09:20:17 +0000 (+0200) Subject: watchdog: use MIN() in update_timeout() X-Git-Tag: v250-rc1~670^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=10fd2b1180b7c298cfb593afd5c63ce26977a3cd;p=thirdparty%2Fsystemd.git 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. --- 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);