net/netfilter/ipset/ip_set_hash_netiface.c: use rbtree postorder iteration instead...
authorCody P Schafer <[email protected]>
Thu, 23 Jan 2014 23:56:07 +0000 (15:56 -0800)
committerLinus Torvalds <[email protected]>
Fri, 24 Jan 2014 00:37:03 +0000 (16:37 -0800)
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 <[email protected]>
Cc: Michel Lespinasse <[email protected]>
Cc: Jan Kara <[email protected]>
Cc: Pablo Neira Ayuso <[email protected]>
Cc: Patrick McHardy <[email protected]>
Cc: Jozsef Kadlecsik <[email protected]>
Cc: "David S. Miller" <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
net/netfilter/ipset/ip_set_hash_netiface.c

index 3f64a66bf5d9b78bfa551124cbc7bd3d7d8a8857..b827a0f1f3510bc0fa4e6b0a498738806ac62e81 100644 (file)
@@ -46,31 +46,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