Use strmatch to load config file
PATCH 1/3 Use strmatch to load config file
We should really be using string match to load the config file. This avoids false positives when comparing two regexps.
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke [email protected] SuSE Linux Products GmbH S390 & zSeries Maxfeldstraße 5 +49 911 74053 688 90409 Nürnberg http://www.suse.de
[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 <[email protected]>
---
libmultipath/config.c | 21 ++++++++++++++++++++- 1 files changed, 20 insertions(+), 1 deletions(-)
libmultipath/config.c +20 -1
@@ -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 ()))
Signature · 1 line
1.3.1