From 1024dc24aea2f7a54d3c51b26b0a61822395a153 Mon Sep 17 00:00:00 2001 From: Martin Wilck Date: Thu, 18 Jul 2024 20:18:39 +0200 Subject: [PATCH] multipath-tools: use signed loop variable in vector_foreach_slot If we delete entries in the vector_foreach_slot loop, the loop index may underflow. It's not a big issue because we re-increment it in the next iteration and use a cast to int in the loop end condition, but it's cleaner to use an int here. Found by coverity. Signed-off-by: Martin Wilck --- multipathd/main.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/multipathd/main.c b/multipathd/main.c index 13ed6d058..be3503824 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -762,7 +762,7 @@ coalesce_maps(struct vectors *vecs, vector nmpv) { struct multipath * ompp; vector ompv = vecs->mpvec; - unsigned int i, reassign_maps; + int i, reassign_maps; struct config *conf; conf = get_multipath_config(); @@ -1748,7 +1748,7 @@ static int map_discovery (struct vectors * vecs) { struct multipath * mpp; - unsigned int i; + int i; if (dm_get_maps(vecs->mpvec)) return 1; @@ -1970,7 +1970,7 @@ static void mpvec_garbage_collector (struct vectors * vecs) { struct multipath * mpp; - unsigned int i; + int i; if (!vecs->mpvec) return; @@ -2014,7 +2014,7 @@ static void missing_uev_wait_tick(struct vectors *vecs) { struct multipath * mpp; - unsigned int i; + int i; int timed_out = 0; vector_foreach_slot (vecs->mpvec, mpp, i) { @@ -2039,7 +2039,7 @@ static void ghost_delay_tick(struct vectors *vecs) { struct multipath * mpp; - unsigned int i; + int i; vector_foreach_slot (vecs->mpvec, mpp, i) { if (mpp->ghost_delay_tick <= 0)