Skip to content

Commit

Permalink
multipath-tools: use signed loop variable in vector_foreach_slot
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
mwilck committed Jul 18, 2024
1 parent 4763d08 commit 1024dc2
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions multipathd/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -1970,7 +1970,7 @@ static void
mpvec_garbage_collector (struct vectors * vecs)
{
struct multipath * mpp;
unsigned int i;
int i;

if (!vecs->mpvec)
return;
Expand Down Expand Up @@ -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) {
Expand All @@ -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)
Expand Down

0 comments on commit 1024dc2

Please sign in to comment.