Skip to contentSkip to conversation

Only return the requested path checker

PATCH New Benjamin Marzinski 1 participant 1 message May 8, 2008 Device mapper

lore
Share & tools
lore

Benjamin Marzinski

author maintainer
#0 lore raw

PATCH 1/1 Only return the requested path checker

checker_lookup() silently returns the default checker if the requested one can't be loaded. Even worse, it the default checker can't be loaded, it gets stuck in an infinite loop.

It seems to me that if the requested checker can't be loaded, we should just throw an error. That's what this patch does.

-Ben

libmultipath/checkers.c +3 -4
Index: multipath-tools-temp/libmultipath/checkers.c
===================================================================
@@ -47,10 +47,7 @@ struct checker * checker_lookup (char * 
 		if (!strncmp(name, c->name, CHECKER_NAME_LEN))
 			return c;
 	}
-	c = add_checker(name);
-	if (c)
-		return c;
-	return checker_default();
+	return add_checker(name);
 }
 
 struct checker * add_checker (char * name)
@@ -179,6 +176,8 @@ struct checker * checker_default (void)
 
 void checker_get (struct checker * dst, struct checker * src)
 {
+	if (!src)
+		dst->check == NULL;
 	dst->fd = src->fd;
 	dst->sync = src->sync;
 	strncpy(dst->name, src->name, CHECKER_NAME_LEN);
libmultipath/config.c +2 -0
Index: multipath-tools-temp/libmultipath/config.c
===================================================================
@@ -457,6 +457,8 @@ load_config (char * file)
 
 	if (!conf->checker)
 		conf->checker = checker_lookup(DEFAULT_CHECKER);
+	if (!conf->checker)
+		goto out;
 
 	return 0;
 out:
libmultipath/dict.c +4 -0
Index: multipath-tools-temp/libmultipath/dict.c
===================================================================
@@ -129,6 +129,8 @@ def_path_checker_handler(vector strvec)
 	
 	conf->checker = checker_lookup(buff);
 	FREE(buff);
+	if (!conf->checker)
+		return 1;
 
 	return 0;
 }
@@ -562,6 +564,8 @@ hw_path_checker_handler(vector strvec)
 	
 	hwe->checker = checker_lookup(buff);
 	FREE(buff);
+	if (!hwe->checker)
+		return 1;
 
 	return 0;
 }
libmultipath/hwtable.c +2 -0
Index: multipath-tools-temp/libmultipath/hwtable.c
===================================================================
@@ -733,6 +733,8 @@ setup_default_hwtable (vector hw)
 
 	while (hwe->vendor) {
 		hwe->checker = checker_lookup(hwe->checker_name);
+		if (!hwe->checker)
+			r++;
 		hwe->prio = prio_lookup(hwe->prio_name);
 		r += store_hwe(hw, hwe);
 		hwe++;