All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@suse.de>
To: Christophe Varoqui <christophe.varoqui@gmail.com>
Cc: dm-devel@redhat.com
Subject: [PATCH 06/11] Break out loop in factorize_hwtable()
Date: Thu, 17 Jan 2013 15:59:28 +0100	[thread overview]
Message-ID: <1358434773-2002-7-git-send-email-hare@suse.de> (raw)
In-Reply-To: <1358434773-2002-1-git-send-email-hare@suse.de>

We need to break out of the loop in factorize_hwtable() as
soon as we have removed a duplicate. Otherwise we might run
onto an deleted element in the outer loop.
Also we should declare factorize_hwtable() as 'void'
as it doesn't return anything.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 libmultipath/config.c |   16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/libmultipath/config.c b/libmultipath/config.c
index 2d88226..25d3e3d 100644
--- a/libmultipath/config.c
+++ b/libmultipath/config.c
@@ -418,12 +418,13 @@ out:
 	return 1;
 }
 
-static int
+static void
 factorize_hwtable (vector hw, int n)
 {
 	struct hwentry *hwe1, *hwe2;
 	int i, j;
 
+restart:
 	vector_foreach_slot(hw, hwe1, i) {
 		if (i == n)
 			break;
@@ -435,14 +436,17 @@ factorize_hwtable (vector hw, int n)
 			merge_hwe(hwe2, hwe1);
 			if (hwe_strmatch(hwe2, hwe1) == 0) {
 				vector_del_slot(hw, i);
-				free_hwe(hwe1);
-				n -= 1;
-				i -= 1;
-				break;
+				/*
+				 * Play safe here; we have modified
+				 * the original vector so the outer
+				 * vector_foreach_slot() might
+				 * become confused.
+				 */
+				goto restart;
 			}
 		}
 	}
-	return 0;
+	return;
 }
 
 struct config *
-- 
1.7.10.4

  parent reply	other threads:[~2013-01-17 14:59 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-17 14:59 [PATCH 00/11] Final round of SLES resync patches Hannes Reinecke
2013-01-17 14:59 ` [PATCH 01/11] Cleanup whitespaces Hannes Reinecke
2013-01-17 14:59 ` [PATCH 02/11] Provide correct persistent symlinks for user_friendly_names Hannes Reinecke
2013-01-17 14:59 ` [PATCH 03/11] kpartx_id: Generate persistent symlinks for 'wwn' Hannes Reinecke
2013-01-17 14:59 ` [PATCH 04/11] Fix inconsistent entries after merging hwtable with user's config Hannes Reinecke
2013-01-17 14:59 ` [PATCH 05/11] kpartx: Fix DASD name in kpartx_id Hannes Reinecke
2013-01-17 14:59 ` Hannes Reinecke [this message]
2013-01-17 14:59 ` [PATCH 07/11] multipathd: switch to abstract sockets for CLI commands Hannes Reinecke
2013-01-17 14:59 ` [PATCH 08/11] multipathd: log message when check interval has changed Hannes Reinecke
2013-01-17 14:59 ` [PATCH 09/11] multipathd: call 'reconfigure' during startup Hannes Reinecke
2013-01-17 14:59 ` [PATCH 10/11] multipath: do not install rules file Hannes Reinecke
2013-01-17 14:59 ` [PATCH 11/11] kpartx: Deinstall kpartx_id Hannes Reinecke
2013-01-18 16:58 ` [PATCH 00/11] Final round of SLES resync patches Xose Vazquez Perez
2013-01-21  7:15   ` Hannes Reinecke
2013-01-21 18:48     ` Christophe Varoqui
2013-01-18 19:20 ` Christophe Varoqui

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=1358434773-2002-7-git-send-email-hare@suse.de \
    --to=hare@suse.de \
    --cc=christophe.varoqui@gmail.com \
    --cc=dm-devel@redhat.com \
    /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.