All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@suse.de>
To: christophe varoqui <christophe.varoqui@free.fr>
Cc: device-mapper development <dm-devel@redhat.com>
Subject: [PATCH 1/3] Use strmatch to load config file
Date: Thu, 09 Nov 2006 11:29:52 +0100	[thread overview]
Message-ID: <45530320.8020003@suse.de> (raw)

[-- Attachment #1: Type: text/plain, Size: 302 bytes --]

We should really be using string match to load the config file.
This avoids false positives when comparing two regexps.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke			hare@suse.de
SuSE Linux Products GmbH		S390 & zSeries
Maxfeldstraße 5				+49 911 74053 688
90409 Nürnberg				http://www.suse.de

[-- Attachment #2: 0001-libmultipath-Use-strmatch-to-load-config-file.txt --]
[-- Type: text/plain, Size: 1480 bytes --]

[libmultipath] Use strmatch to load config file

Currently we're using regexec to load the initial hardware table.
Unfortunately the hardware table has regex as defaults, so it's quite
possible for two different regular expressions do match.
But that's quite undesired as we just want a clean 1:1 copy here.
So we're better using a string match for comparison.

Signed-off-by: Hannes Reinecke <hare@suse.de>

---

 libmultipath/config.c |   21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/libmultipath/config.c b/libmultipath/config.c
index a87e97e..2f07792 100644
--- a/libmultipath/config.c
+++ b/libmultipath/config.c
@@ -20,6 +20,25 @@ #include "config.h"
 #include "blacklist.h"
 #include "defaults.h"
 
+static struct hwentry *
+find_hwe_strmatch (vector hwtable, char * vendor, char * product)
+{
+	int i;
+	struct hwentry *hwe, *ret = NULL;
+
+	vector_foreach_slot (hwtable, hwe, i) {
+		if (hwe->vendor && vendor && strcmp(hwe->vendor, vendor))
+			continue;
+
+		if (hwe->product && product && strcmp(hwe->product, product))
+			continue;
+
+		ret = hwe;
+		break;
+	}
+	return ret;
+}
+
 struct hwentry *
 find_hwe (vector hwtable, char * vendor, char * product)
 {
@@ -222,7 +241,7 @@ store_hwe (vector hwtable, struct hwentr
 {
 	struct hwentry * hwe;
 
-	if (dup_hwe(hwtable, dhwe->vendor, dhwe->product))
+	if (find_hwe_strmatch(hwtable, dhwe->vendor, dhwe->product))
 		return 0;
 	
 	if (!(hwe = alloc_hwe()))
-- 
1.3.1


[-- Attachment #3: Type: text/plain, Size: 0 bytes --]



                 reply	other threads:[~2006-11-09 10:29 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=45530320.8020003@suse.de \
    --to=hare@suse.de \
    --cc=christophe.varoqui@free.fr \
    --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.