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 331461a5a2
This commit is contained in:
Luca Boccassi
2026-04-08 00:15:18 +01:00
parent e60937b585
commit 0aaf7e697f

View File

@@ -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) {