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

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