tree 0f941a1743003469a69c51ea28f982d2b9fb9cca
parent 9ac652e1aed2fdcaf4408a5b817ba69829b141ae
author Hannes Reinecke <hare@suse.de> 1174654416 +0100
committer Hannes Reinecke <hare@suse.de> 1174654416 +0100

[libmultipath] Fix missing initialisation for internal tables

Dumping the internal hardware table only works if a config file
is specified. Otherwise is won't print anything as the internal
structures are not initialised.

Signed-off-by: Hannes Reinecke <hare@suse.de>
9cb63f8de530d42356df9330c4b7f4f64035a8ac
 libmultipath/config.c |    5 ++++-
 libmultipath/dict.c   |    1 -
 libmultipath/parser.c |   15 +++++++++++----
 libmultipath/parser.h |    1 +
 4 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/libmultipath/config.c b/libmultipath/config.c
index a39af8a..1dfc18c 100644
--- a/libmultipath/config.c
+++ b/libmultipath/config.c
@@ -366,12 +366,15 @@ load_config (char * file)
 	/*
 	 * read the config file
 	 */
+	set_current_keywords(&conf->keywords);
+	alloc_keywords();
 	if (filepresent(file)) {
-		set_current_keywords(&conf->keywords);
 		if (init_data(file, init_keywords)) {
 			condlog(0, "error parsing config file");
 			goto out;
 		}
+	} else {
+	    init_keywords();
 	}
 	
 	/*
diff --git a/libmultipath/dict.c b/libmultipath/dict.c
index 119cd23..69f61e8 100644
--- a/libmultipath/dict.c
+++ b/libmultipath/dict.c
@@ -331,7 +331,6 @@ static int
 ble_except_vendor_handler(vector strvec)
 {
 	char * buff;
-	int r;
 
 	buff = set_value(strvec);
 
diff --git a/libmultipath/parser.c b/libmultipath/parser.c
index f9c555e..5302970 100644
--- a/libmultipath/parser.c
+++ b/libmultipath/parser.c
@@ -455,16 +455,23 @@ process_stream(vector keywords)
 	return r;
 }
 
+int alloc_keywords(void)
+{
+	if (!keywords)
+		keywords = vector_alloc();
+
+	if (!keywords)
+		return 1;
+
+	return 0;
+}
+
 /* Data initialization */
 int
 init_data(char *conf_file, void (*init_keywords) (void))
 {
 	int r;
 
-	if (!keywords)
-		keywords = vector_alloc();
-	if (!keywords)
-		return 1;
 	stream = fopen(conf_file, "r");
 	if (!stream) {
 		syslog(LOG_WARNING, "Configuration file open problem");
diff --git a/libmultipath/parser.h b/libmultipath/parser.h
index 95d4e6f..8496684 100644
--- a/libmultipath/parser.h
+++ b/libmultipath/parser.h
@@ -74,6 +74,7 @@ extern vector read_value_block(void);
 extern int alloc_value_block(vector strvec, void (*alloc_func) (vector));
 extern void *set_value(vector strvec);
 extern int process_stream(vector keywords);
+extern int alloc_keywords(void);
 extern int init_data(char *conf_file, void (*init_keywords) (void));
 extern struct keyword * find_keyword(vector v, char * name);
 void set_current_keywords (vector *k);
