* [PATCH 1/3] Use strmatch to load config file
@ 2006-11-09 10:29 Hannes Reinecke
0 siblings, 0 replies; only message in thread
From: Hannes Reinecke @ 2006-11-09 10:29 UTC (permalink / raw)
To: christophe varoqui; +Cc: device-mapper development
[-- 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 --]
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2006-11-09 10:29 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-09 10:29 [PATCH 1/3] Use strmatch to load config file Hannes Reinecke
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.