All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/8] net ipset: use rbtree postorder iteration instead of opencoding
@ 2013-11-01 22:38 Cody P Schafer
  2013-11-01 22:38 ` [PATCH 2/8] trace/trace_stat: use rbtree postorder iteration helper " Cody P Schafer
                   ` (6 more replies)
  0 siblings, 7 replies; 26+ messages in thread
From: Cody P Schafer @ 2013-11-01 22:38 UTC (permalink / raw)
  To: David S. Miller, Florian Westphal, Jozsef Kadlecsik,
	Pablo Neira Ayuso, YOSHIFUJI Hideaki
  Cc: Cody P Schafer, coreteam, linux-kernel, netdev, netfilter-devel,
	netfilter, Patrick McHardy

Use rbtree_postorder_for_each_entry_safe() to destroy the rbtree instead
of opencoding an alternate postorder iteration that modifies the tree

Signed-off-by: Cody P Schafer <cody@linux.vnet.ibm.com>
---
 net/netfilter/ipset/ip_set_hash_netiface.c | 27 ++++-----------------------
 1 file changed, 4 insertions(+), 23 deletions(-)

diff --git a/net/netfilter/ipset/ip_set_hash_netiface.c b/net/netfilter/ipset/ip_set_hash_netiface.c
index 7d798d5..99dba4c 100644
--- a/net/netfilter/ipset/ip_set_hash_netiface.c
+++ b/net/netfilter/ipset/ip_set_hash_netiface.c
@@ -45,31 +45,12 @@ struct iface_node {
 static void
 rbtree_destroy(struct rb_root *root)
 {
-	struct rb_node *p, *n = root->rb_node;
-	struct iface_node *node;
-
-	/* Non-recursive destroy, like in ext3 */
-	while (n) {
-		if (n->rb_left) {
-			n = n->rb_left;
-			continue;
-		}
-		if (n->rb_right) {
-			n = n->rb_right;
-			continue;
-		}
-		p = rb_parent(n);
-		node = rb_entry(n, struct iface_node, node);
-		if (!p)
-			*root = RB_ROOT;
-		else if (p->rb_left == n)
-			p->rb_left = NULL;
-		else if (p->rb_right == n)
-			p->rb_right = NULL;
+	struct iface_node *node, *next;
 
+	rbtree_postorder_for_each_entry_safe(node, next, root, node)
 		kfree(node);
-		n = p;
-	}
+
+	*root = RB_ROOT;
 }
 
 static int
-- 
1.8.4.2


^ permalink raw reply related	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2013-11-06 23:16 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-01 22:38 [PATCH 1/8] net ipset: use rbtree postorder iteration instead of opencoding Cody P Schafer
2013-11-01 22:38 ` [PATCH 2/8] trace/trace_stat: use rbtree postorder iteration helper " Cody P Schafer
2013-11-02  2:45   ` Steven Rostedt
2013-11-04  8:49     ` Cody P Schafer
2013-11-04 14:22       ` Steven Rostedt
2013-11-01 22:38 ` [PATCH 3/8] fs/ubifs: " Cody P Schafer
2013-11-01 22:38   ` Cody P Schafer
2013-11-01 22:38 ` [PATCH 4/8] fs/ext4: " Cody P Schafer
2013-11-01 22:38 ` [PATCH 5/8] fs/jffs2: " Cody P Schafer
2013-11-01 22:38   ` Cody P Schafer
2013-11-01 22:38 ` [PATCH 6/8] fs/ext3: " Cody P Schafer
2013-11-04 14:26   ` Jan Kara
2013-11-05  0:45     ` Jan Kara
2013-11-05  1:33       ` Cody P Schafer
2013-11-05  1:40         ` [PATCH 1/2] rbtree: fix postorder iteration when the rb_node is not the first element in an entry Cody P Schafer
2013-11-05  1:40           ` [PATCH 2/2] rbtree/test: move rb_node to the middle of the test struct Cody P Schafer
2013-11-05 10:05           ` [PATCH 1/2] rbtree: fix postorder iteration when the rb_node is not the first element in an entry Cody P Schafer
2013-11-05 21:57             ` Jan Kara
2013-11-05 22:56               ` Jan Kara
2013-11-06 20:18                 ` Cody P Schafer
2013-11-06 21:37                   ` [PATCH] rbtree/test: test rbtree_postorder_for_each_entry_safe() Cody P Schafer
2013-11-06 23:16                     ` Andrew Morton
2013-11-01 22:38 ` [PATCH 7/8] mtd/ubi: use rbtree postorder iteration helper instead of opencoding Cody P Schafer
2013-11-01 22:38   ` Cody P Schafer
2013-11-01 22:38 ` [PATCH 8/8] sh/dwarf: use rbtree postorder iteration helper instead of solution using repeated rb_er Cody P Schafer
2013-11-01 22:38   ` [PATCH 8/8] sh/dwarf: use rbtree postorder iteration helper instead of solution using repeated rb_erase() Cody P Schafer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.