diff mbox series

[2/4] multipath-tools: use signed loop variable in vector_foreach_slot

Message ID 20240718191421.110487-3-mwilck@suse.com (mailing list archive)
State Not Applicable, archived
Delegated to: christophe varoqui
Headers show
Series multipath-tools: coverity fixes | expand

Commit Message

Martin Wilck July 18, 2024, 7:14 p.m. UTC
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 <mwilck@suse.com>
---
 multipathd/main.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/multipathd/main.c b/multipathd/main.c
index 13ed6d0..be35038 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)