]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
watchdog: use MIN() in update_timeout() 20650/head
authorFranck Bui <fbui@suse.com>
Wed, 15 Sep 2021 09:20:17 +0000 (11:20 +0200)
committerFranck Bui <fbui@suse.com>
Wed, 15 Sep 2021 10:14:53 +0000 (12:14 +0200)
Also the previous expression was probably wrong as "(int) t >= INT_MAX" is
likely to always evaluate to false.

src/shared/watchdog.c

index 53c7189e243e2b2b1828eabba730d6b3fea0b3b7..be100931f76bcc5cee2fda744856c1f861c1fea4 100644 (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);