Blame SOURCES/0113-RHBZ-1194917-cleanup.patch

4728c8
---
4728c8
 libmultipath/parser.c |  103 +++-----------------------------------------------
4728c8
 libmultipath/parser.h |    6 --
4728c8
 2 files changed, 8 insertions(+), 101 deletions(-)
4728c8
4728c8
Index: multipath-tools-130222/libmultipath/parser.c
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/libmultipath/parser.c
4728c8
+++ multipath-tools-130222/libmultipath/parser.c
4728c8
@@ -280,8 +280,8 @@ out:
4728c8
 	return NULL;
4728c8
 }
4728c8
 
4728c8
-int
4728c8
-read_line(char *buf, int size)
4728c8
+static int
4728c8
+read_line(FILE *stream, char *buf, int size)
4728c8
 {
4728c8
 	int ch;
4728c8
 	int count = 0;
4728c8
@@ -297,95 +297,6 @@ read_line(char *buf, int size)
4728c8
 	return (ch == EOF) ? 0 : 1;
4728c8
 }
4728c8
 
4728c8
-vector
4728c8
-read_value_block(void)
4728c8
-{
4728c8
-	char *buf;
4728c8
-	int i;
4728c8
-	char *str = NULL;
4728c8
-	char *dup;
4728c8
-	vector vec = NULL;
4728c8
-	vector elements = vector_alloc();
4728c8
-
4728c8
-	if (!elements)
4728c8
-		return NULL;
4728c8
-
4728c8
-	buf = (char *) MALLOC(MAXBUF);
4728c8
-
4728c8
-	if (!buf) {
4728c8
-		vector_free(elements);
4728c8
-		return NULL;
4728c8
-	}
4728c8
-
4728c8
-	while (read_line(buf, MAXBUF)) {
4728c8
-		vec = alloc_strvec(buf);
4728c8
-		if (vec) {
4728c8
-			str = VECTOR_SLOT(vec, 0);
4728c8
-			if (!strcmp(str, EOB)) {
4728c8
-				free_strvec(vec);
4728c8
-				break;
4728c8
-			}
4728c8
-
4728c8
-			for (i = 0; i < VECTOR_SIZE(vec); i++) {
4728c8
-				str = VECTOR_SLOT(vec, i);
4728c8
-				dup = (char *) MALLOC(strlen(str) + 1);
4728c8
-				if (!dup)
4728c8
-					goto out;
4728c8
-				memcpy(dup, str, strlen(str));
4728c8
-
4728c8
-				if (!vector_alloc_slot(elements)) {
4728c8
-					free_strvec(vec);
4728c8
-					goto out1;
4728c8
-				}
4728c8
-
4728c8
-				vector_set_slot(elements, dup);
4728c8
-			}
4728c8
-			free_strvec(vec);
4728c8
-		}
4728c8
-		memset(buf, 0, MAXBUF);
4728c8
-	}
4728c8
-	FREE(buf);
4728c8
-	return elements;
4728c8
-out1:
4728c8
-	FREE(dup);
4728c8
-out:
4728c8
-	FREE(buf);
4728c8
-	vector_free(elements);
4728c8
-	return NULL;
4728c8
-}
4728c8
-
4728c8
-int
4728c8
-alloc_value_block(vector strvec, void (*alloc_func) (vector))
4728c8
-{
4728c8
-	char *buf;
4728c8
-	char *str = NULL;
4728c8
-	vector vec = NULL;
4728c8
-
4728c8
-	buf = (char *) MALLOC(MAXBUF);
4728c8
-
4728c8
-	if (!buf)
4728c8
-		return 1;
4728c8
-
4728c8
-	while (read_line(buf, MAXBUF)) {
4728c8
-		vec = alloc_strvec(buf);
4728c8
-		if (vec) {
4728c8
-			str = VECTOR_SLOT(vec, 0);
4728c8
-			if (!strcmp(str, EOB)) {
4728c8
-				free_strvec(vec);
4728c8
-				break;
4728c8
-			}
4728c8
-
4728c8
-			if (VECTOR_SIZE(vec))
4728c8
-				(*alloc_func) (vec);
4728c8
-
4728c8
-			free_strvec(vec);
4728c8
-		}
4728c8
-		memset(buf, 0, MAXBUF);
4728c8
-	}
4728c8
-	FREE(buf);
4728c8
-	return 0;
4728c8
-}
4728c8
-
4728c8
 void *
4728c8
 set_value(vector strvec)
4728c8
 {
4728c8
@@ -561,7 +472,7 @@ validate_config_strvec(vector strvec, ch
4728c8
 }
4728c8
 
4728c8
 static int
4728c8
-process_stream(vector keywords, char *file)
4728c8
+process_stream(FILE *stream, vector keywords, char *file)
4728c8
 {
4728c8
 	int i;
4728c8
 	int r = 0;
4728c8
@@ -582,7 +493,7 @@ process_stream(vector keywords, char *fi
4728c8
 		return 1;
4728c8
 	}
4728c8
 
4728c8
-	while (read_line(buf, MAXBUF)) {
4728c8
+	while (read_line(stream, buf, MAXBUF)) {
4728c8
 		line_nr++;
4728c8
 		strvec = alloc_strvec(buf);
4728c8
 		memset(buf,0, MAXBUF);
4728c8
@@ -621,7 +532,8 @@ process_stream(vector keywords, char *fi
4728c8
 
4728c8
 				if (keyword->sub) {
4728c8
 					kw_level++;
4728c8
-					r += process_stream(keyword->sub, file);
4728c8
+					r += process_stream(stream,
4728c8
+							    keyword->sub, file);
4728c8
 					kw_level--;
4728c8
 				}
4728c8
 				break;
4728c8
@@ -656,6 +568,7 @@ int
4728c8
 process_file(char *file)
4728c8
 {
4728c8
 	int r;
4728c8
+	FILE *stream;
4728c8
 
4728c8
 	if (!keywords) {
4728c8
 		condlog(0, "No keywords alocated");
4728c8
@@ -670,7 +583,7 @@ process_file(char *file)
4728c8
 
4728c8
 	/* Stream handling */
4728c8
 	line_nr = 0;
4728c8
-	r = process_stream(keywords, file);
4728c8
+	r = process_stream(stream, keywords, file);
4728c8
 	fclose(stream);
4728c8
 	//free_keywords(keywords);
4728c8
 
4728c8
Index: multipath-tools-130222/libmultipath/parser.h
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/libmultipath/parser.h
4728c8
+++ multipath-tools-130222/libmultipath/parser.h
4728c8
@@ -47,9 +47,6 @@ struct keyword {
4728c8
 	int unique;
4728c8
 };
4728c8
 
4728c8
-/* global var exported */
4728c8
-FILE *stream;
4728c8
-
4728c8
 /* Reloading helpers */
4728c8
 #define SET_RELOAD      (reload = 1)
4728c8
 #define UNSET_RELOAD    (reload = 0)
4728c8
@@ -72,9 +69,6 @@ extern int _install_keyword(char *string
4728c8
 extern void dump_keywords(vector keydump, int level);
4728c8
 extern void free_keywords(vector keywords);
4728c8
 extern vector alloc_strvec(char *string);
4728c8
-extern int read_line(char *buf, int size);
4728c8
-extern vector read_value_block(void);
4728c8
-extern int alloc_value_block(vector strvec, void (*alloc_func) (vector));
4728c8
 extern void *set_value(vector strvec);
4728c8
 extern int alloc_keywords(void);
4728c8
 extern int process_file(char *conf_file);