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.
This commit is contained in:
Franck Bui
2021-09-15 12:14:53 +02:00
parent 484752e26a
commit 10fd2b1180
+1 -1
View File
@@ -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);