Blame SOURCES/autofs-5.1.7-rename-tree-implementation-functions.patch

96dc52
autofs-5.1.7 - rename tree implementation functions
96dc52
96dc52
From: Ian Kent <raven@themaw.net>
96dc52
96dc52
Rename the tree struct and functions to make them consistent.
96dc52
96dc52
Signed-off-by: Ian Kent <raven@themaw.net>
96dc52
---
96dc52
 CHANGELOG    |    1 +
96dc52
 lib/mounts.c |   80 +++++++++++++++++++++++++++++-----------------------------
96dc52
 2 files changed, 41 insertions(+), 40 deletions(-)
96dc52
96dc52
diff --git a/CHANGELOG b/CHANGELOG
96dc52
index 2a07bd45..1bf20699 100644
96dc52
--- a/CHANGELOG
96dc52
+++ b/CHANGELOG
96dc52
@@ -27,6 +27,7 @@
96dc52
 - cleanup cache_delete() a little.
96dc52
 - rename path to m_offset in update_offset_entry().
96dc52
 - don't pass root to do_mount_autofs_offset().
96dc52
+- rename tree implementation functions.
96dc52
 
96dc52
 25/01/2021 autofs-5.1.7
96dc52
 - make bind mounts propagation slave by default.
96dc52
diff --git a/lib/mounts.c b/lib/mounts.c
96dc52
index 289500da..f5b905a6 100644
96dc52
--- a/lib/mounts.c
96dc52
+++ b/lib/mounts.c
96dc52
@@ -1225,30 +1225,30 @@ done:
96dc52
 	return has_mounted_mounts;
96dc52
 }
96dc52
 
96dc52
-struct node {
96dc52
+struct tree_node {
96dc52
 	struct mnt_list *mnt;
96dc52
-	struct node *left;
96dc52
-	struct node *right;
96dc52
+	struct tree_node *left;
96dc52
+	struct tree_node *right;
96dc52
 };
96dc52
 
96dc52
-static struct node *new(struct mnt_list *mnt)
96dc52
+static struct tree_node *tree_new(struct mnt_list *mnt)
96dc52
 {
96dc52
-	struct node *n;
96dc52
+	struct tree_node *n;
96dc52
 
96dc52
-	n = malloc(sizeof(struct node));
96dc52
+	n = malloc(sizeof(struct tree_node));
96dc52
 	if (!n)
96dc52
 		return NULL;
96dc52
-	memset(n, 0, sizeof(struct node));
96dc52
+	memset(n, 0, sizeof(struct tree_node));
96dc52
 	n->mnt = mnt;
96dc52
 
96dc52
 	return n;
96dc52
 }
96dc52
 
96dc52
-static struct node *tree_root(struct mnt_list *mnt)
96dc52
+static struct tree_node *tree_root(struct mnt_list *mnt)
96dc52
 {
96dc52
-	struct node *n;
96dc52
+	struct tree_node *n;
96dc52
 
96dc52
-	n = new(mnt);
96dc52
+	n = tree_new(mnt);
96dc52
 	if (!n) {
96dc52
 		error(LOGOPT_ANY, "failed to allcate tree root");
96dc52
 		return NULL;
96dc52
@@ -1257,37 +1257,37 @@ static struct node *tree_root(struct mnt_list *mnt)
96dc52
 	return n;
96dc52
 }
96dc52
 
96dc52
-static struct node *add_left(struct node *this, struct mnt_list *mnt)
96dc52
+static struct tree_node *tree_add_left(struct tree_node *n, struct mnt_list *mnt)
96dc52
 {
96dc52
-	struct node *n;
96dc52
+	struct tree_node *new;
96dc52
 
96dc52
-	n = new(mnt);
96dc52
-	if (!n) {
96dc52
+	new = tree_new(mnt);
96dc52
+	if (!new) {
96dc52
 		error(LOGOPT_ANY, "failed to allcate tree node");
96dc52
 		return NULL;
96dc52
 	}
96dc52
-	this->left = n;
96dc52
+	n->left = new;
96dc52
 
96dc52
 	return n;
96dc52
 }
96dc52
 
96dc52
-static struct node *add_right(struct node *this, struct mnt_list *mnt)
96dc52
+static struct tree_node *tree_add_right(struct tree_node *n, struct mnt_list *mnt)
96dc52
 {
96dc52
-	struct node *n;
96dc52
+	struct tree_node *new;
96dc52
 
96dc52
-	n = new(mnt);
96dc52
-	if (!n) {
96dc52
+	new = tree_new(mnt);
96dc52
+	if (!new) {
96dc52
 		error(LOGOPT_ANY, "failed to allcate tree node");
96dc52
 		return NULL;
96dc52
 	}
96dc52
-	this->right = n;
96dc52
+	n->right = new;
96dc52
 
96dc52
 	return n;
96dc52
 }
96dc52
 
96dc52
-static struct node *add_node(struct node *root, struct mnt_list *mnt)
96dc52
+static struct tree_node *tree_add_node(struct tree_node *root, struct mnt_list *mnt)
96dc52
 {
96dc52
-	struct node *p, *q;
96dc52
+	struct tree_node *p, *q;
96dc52
 	unsigned int mp_len;
96dc52
 
96dc52
 	mp_len = strlen(mnt->mp);
96dc52
@@ -1307,43 +1307,43 @@ static struct node *add_node(struct node *root, struct mnt_list *mnt)
96dc52
 		error(LOGOPT_ANY, "duplicate entry in mounts list");
96dc52
 	else {
96dc52
 		if (mp_len < strlen(p->mnt->mp))
96dc52
-			return add_left(p, mnt);
96dc52
+			return tree_add_left(p, mnt);
96dc52
 		else
96dc52
-			return add_right(p, mnt);
96dc52
+			return tree_add_right(p, mnt);
96dc52
 	}
96dc52
 
96dc52
 	return NULL;
96dc52
 }
96dc52
 
96dc52
-static void tree_free(struct node *tree)
96dc52
+static void tree_free(struct tree_node *root)
96dc52
 {
96dc52
-	if (tree->right)
96dc52
-		tree_free(tree->right);
96dc52
-	if (tree->left)
96dc52
-		tree_free(tree->left);
96dc52
-	free(tree);
96dc52
+	if (root->right)
96dc52
+		tree_free(root->right);
96dc52
+	if (root->left)
96dc52
+		tree_free(root->left);
96dc52
+	free(root);
96dc52
 }
96dc52
 
96dc52
-static void traverse(struct node *node, struct list_head *mnts)
96dc52
+static void tree_traverse(struct tree_node *n, struct list_head *mnts)
96dc52
 {
96dc52
-	if (node->right)
96dc52
-		traverse(node->right, mnts);
96dc52
-	list_add_tail(&node->mnt->expire, mnts);
96dc52
-	if (node->left)
96dc52
-		traverse(node->left, mnts);
96dc52
+	if (n->right)
96dc52
+		tree_traverse(n->right, mnts);
96dc52
+	list_add_tail(&n->mnt->expire, mnts);
96dc52
+	if (n->left)
96dc52
+		tree_traverse(n->left, mnts);
96dc52
 }
96dc52
 
96dc52
 void mnts_get_expire_list(struct list_head *mnts, struct autofs_point *ap)
96dc52
 {
96dc52
 	struct mnt_list *mnt;
96dc52
-	struct node *tree = NULL;
96dc52
+	struct tree_node *tree = NULL;
96dc52
 
96dc52
 	mnts_hash_mutex_lock();
96dc52
 	if (list_empty(&ap->mounts))
96dc52
 		goto done;
96dc52
 
96dc52
 	list_for_each_entry(mnt, &ap->mounts, mount) {
96dc52
-		struct node *n;
96dc52
+		struct tree_node *n;
96dc52
 
96dc52
 		if (!(mnt->flags & MNTS_MOUNTED))
96dc52
 			continue;
96dc52
@@ -1359,7 +1359,7 @@ void mnts_get_expire_list(struct list_head *mnts, struct autofs_point *ap)
96dc52
 			continue;
96dc52
 		}
96dc52
 
96dc52
-		n = add_node(tree, mnt);
96dc52
+		n = tree_add_node(tree, mnt);
96dc52
 		if (!n) {
96dc52
 			error(LOGOPT_ANY, "failed to add expire tree node");
96dc52
 			tree_free(tree);
96dc52
@@ -1367,7 +1367,7 @@ void mnts_get_expire_list(struct list_head *mnts, struct autofs_point *ap)
96dc52
 		}
96dc52
 	}
96dc52
 
96dc52
-	traverse(tree, mnts);
96dc52
+	tree_traverse(tree, mnts);
96dc52
 	tree_free(tree);
96dc52
 done:
96dc52
 	mnts_hash_mutex_unlock();