All of lore.kernel.org
 help / color / mirror / Atom feed
From: zhang.kai16@zte.com.cn
To: christophe varoqui <christophe.varoqui@free.fr>
Cc: "zhang.kai" <zhang.kai16@zte.com.cn>,
	dm-devel@redhat.com, tang.junhui@zte.com.cn
Subject: [PATCH] libmultipath:fix loop traversed partly
Date: Thu, 14 Jul 2016 20:09:33 +0800	[thread overview]
Message-ID: <1468498173-8328-1-git-send-email-zhang.kai16@zte.com.cn> (raw)

From: "zhang.kai" <zhang.kai16@zte.com.cn>

Problem:
With each iteration of the vector_foreach_slot() loop statement,
some slots couldn't be traversed when a slot is deleted from vector.

Reasons:
Currently,loop's index 'i' is not decremented correspondingly when a slot is
deleted from vector.Meanwhile, in the vector_foreach_slot() loop, mpp is assigned
from vector newmp directly, so find_slot() could be omitted.

Signed-off-by: zhang.kai <zhang.kai16@zte.com.cn>
---
 libmultipath/configure.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/libmultipath/configure.c b/libmultipath/configure.c
index a9b9cf0..c06a3df 100644
--- a/libmultipath/configure.c
+++ b/libmultipath/configure.c
@@ -924,16 +924,14 @@ coalesce_paths (struct vectors * vecs, vector newmp, char * refwwid, int force_r
 	if (newmp) {
 		vector_foreach_slot (newmp, mpp, i) {
 			char alias[WWID_SIZE];
-			int j;
 
 			if (!deadmap(mpp))
 				continue;
 
 			strncpy(alias, mpp->alias, WWID_SIZE - 1);
 
-			if ((j = find_slot(newmp, (void *)mpp)) != -1)
-				vector_del_slot(newmp, j);
-
+			vector_del_slot(newmp, i);
+			i--;
 			remove_map(mpp, vecs, 0);
 
 			if (dm_flush_map(alias))
-- 
2.8.1.windows.1

--------------------------------------------------------
ZTE Information Security Notice: The information contained in this mail (and any attachment transmitted herewith) is privileged and confidential and is intended for the exclusive use of the addressee(s).  If you are not an intended recipient, any disclosure, reproduction, distribution or other dissemination or use of the information contained is strictly prohibited.  If you have received this mail in error, please delete it and notify us immediately.

             reply	other threads:[~2016-07-14 12:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-14 12:09 zhang.kai16 [this message]
2016-07-22  9:44 ` [PATCH] libmultipath:fix loop traversed partly Christophe Varoqui
2016-07-14 20:58 Xose Vazquez Perez
2016-07-15  5:44 ` Hannes Reinecke

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1468498173-8328-1-git-send-email-zhang.kai16@zte.com.cn \
    --to=zhang.kai16@zte.com.cn \
    --cc=christophe.varoqui@free.fr \
    --cc=dm-devel@redhat.com \
    --cc=tang.junhui@zte.com.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.