changeset 4074:58874e1ba2ef

6547185 libzfs should make use of uu_{list,avl}_teardown
author eschrock
date Thu, 19 Apr 2007 17:36:51 -0700
parents 245d7a4f5220
children c5a5424beca2
files usr/src/lib/libzfs/common/libzfs_changelist.c usr/src/lib/libzfs/common/libzfs_config.c
diffstat 2 files changed, 11 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/lib/libzfs/common/libzfs_changelist.c	Thu Apr 19 17:27:52 2007 -0700
+++ b/usr/src/lib/libzfs/common/libzfs_changelist.c	Thu Apr 19 17:36:51 2007 -0700
@@ -339,22 +339,15 @@
 changelist_free(prop_changelist_t *clp)
 {
 	prop_changenode_t *cn;
-	uu_list_walk_t *walk;
+	void *cookie;
 
 	if (clp->cl_list) {
-		verify((walk = uu_list_walk_start(clp->cl_list,
-		    UU_WALK_ROBUST)) != NULL);
-
-		while ((cn = uu_list_walk_next(walk)) != NULL) {
-
-			uu_list_remove(clp->cl_list, cn);
-
+		cookie = NULL;
+		while ((cn = uu_list_teardown(clp->cl_list, &cookie)) != NULL) {
 			zfs_close(cn->cn_handle);
 			free(cn);
 		}
 
-		uu_list_walk_end(walk);
-
 		uu_list_destroy(clp->cl_list);
 	}
 	if (clp->cl_pool)
@@ -418,7 +411,7 @@
 		} else {
 			ASSERT(!clp->cl_alldependents);
 			verify(uu_list_insert_before(clp->cl_list,
-				uu_list_first(clp->cl_list), cn) == 0);
+			    uu_list_first(clp->cl_list), cn) == 0);
 		}
 
 		if (!clp->cl_alldependents)
--- a/usr/src/lib/libzfs/common/libzfs_config.c	Thu Apr 19 17:27:52 2007 -0700
+++ b/usr/src/lib/libzfs/common/libzfs_config.c	Thu Apr 19 17:36:51 2007 -0700
@@ -74,22 +74,16 @@
 namespace_clear(libzfs_handle_t *hdl)
 {
 	if (hdl->libzfs_ns_avl) {
-		uu_avl_walk_t *walk;
 		config_node_t *cn;
+		void *cookie = NULL;
 
-		if ((walk = uu_avl_walk_start(hdl->libzfs_ns_avl,
-		    UU_WALK_ROBUST)) == NULL)
-			return;
-
-		while ((cn = uu_avl_walk_next(walk)) != NULL) {
-			uu_avl_remove(hdl->libzfs_ns_avl, cn);
+		while ((cn = uu_avl_teardown(hdl->libzfs_ns_avl,
+		    &cookie)) != NULL) {
 			nvlist_free(cn->cn_config);
 			free(cn->cn_name);
 			free(cn);
 		}
 
-		uu_avl_walk_end(walk);
-
 		uu_avl_destroy(hdl->libzfs_ns_avl);
 		hdl->libzfs_ns_avl = NULL;
 	}
@@ -110,7 +104,7 @@
 	config_node_t *cn;
 	nvpair_t *elem;
 	zfs_cmd_t zc = { 0 };
-	uu_avl_walk_t *walk;
+	void *cookie;
 
 	if (hdl->libzfs_ns_gen == 0) {
 		/*
@@ -172,21 +166,13 @@
 	/*
 	 * Clear out any existing configuration information.
 	 */
-	if ((walk = uu_avl_walk_start(hdl->libzfs_ns_avl,
-	    UU_WALK_ROBUST)) == NULL) {
-		nvlist_free(config);
-		return (no_memory(hdl));
-	}
-
-	while ((cn = uu_avl_walk_next(walk)) != NULL) {
-		uu_avl_remove(hdl->libzfs_ns_avl, cn);
+	cookie = NULL;
+	while ((cn = uu_avl_teardown(hdl->libzfs_ns_avl, &cookie)) != NULL) {
 		nvlist_free(cn->cn_config);
 		free(cn->cn_name);
 		free(cn);
 	}
 
-	uu_avl_walk_end(walk);
-
 	elem = NULL;
 	while ((elem = nvlist_next_nvpair(config, elem)) != NULL) {
 		nvlist_t *child;
@@ -222,7 +208,7 @@
 }
 
 /*
- * Retrive the configuration for the given pool.  The configuration is a nvlist
+ * Retrieve the configuration for the given pool.  The configuration is a nvlist
  * describing the vdevs, as well as the statistics associated with each one.
  */
 nvlist_t *