From 0aaf7e697f068b2699b7c964a34711010cbb7fd8 Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Wed, 8 Apr 2026 00:15:18 +0100 Subject: [PATCH] test-path: use usec_add() for timeout calculation Coverity flags now() + 30 * USEC_PER_SEC as overflowing because now() can return USEC_INFINITY. Use usec_add() which saturates on overflow instead of wrapping. CID#1548025 Follow-up for 331461a5a2ffe323190c4ca6b7bcd35944e36f92 --- src/test/test-path.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/test/test-path.c b/src/test/test-path.c index 82b1f27ed75..8b02f5d0fff 100644 --- a/src/test/test-path.c +++ b/src/test/test-path.c @@ -78,9 +78,7 @@ static int _check_states(unsigned line, assert_se(m); assert_se(service); - /* Silence static analyzers */ - assert_cc(30 * USEC_PER_SEC <= USEC_INFINITY); - usec_t end = now(CLOCK_MONOTONIC) + 30 * USEC_PER_SEC; + usec_t end = usec_add(now(CLOCK_MONOTONIC), 30 * USEC_PER_SEC); while (path->state != path_state || service->state != service_state || path->result != PATH_SUCCESS || service->result != SERVICE_SUCCESS) {