aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/radix-tree/test.c
diff options
context:
space:
mode:
authorMatthew Wilcox <willy@infradead.org>2018-08-20 15:48:46 -0400
committerMatthew Wilcox <willy@infradead.org>2018-10-21 10:46:45 -0400
commit47e0fab2b15155e33fdff777c791bebfd5855bbc (patch)
treebd7fe2e5398798257746b56e7d9c3306a05ebf19 /tools/testing/radix-tree/test.c
parentradix tree test suite: Convert tag_tagged_items to XArray (diff)
downloadlinux-dev-47e0fab2b15155e33fdff777c791bebfd5855bbc.tar.xz
linux-dev-47e0fab2b15155e33fdff777c791bebfd5855bbc.zip
radix tree test suite: Convert iteration test to XArray
With no code left in the kernel using the multiorder radix tree, convert the iteration test from the radix tree to the XArray. It's unlikely to suffer the same bug as the radix tree, but this test will prevent that bug from ever creeping into the XArray implementation. Signed-off-by: Matthew Wilcox <willy@infradead.org>
Diffstat (limited to 'tools/testing/radix-tree/test.c')
-rw-r--r--tools/testing/radix-tree/test.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/tools/testing/radix-tree/test.c b/tools/testing/radix-tree/test.c
index d70adcd03d35..32973dd51ec5 100644
--- a/tools/testing/radix-tree/test.c
+++ b/tools/testing/radix-tree/test.c
@@ -63,16 +63,21 @@ void item_sanity(struct item *item, unsigned long index)
assert((item->index | mask) == (index | mask));
}
+void item_free(struct item *item, unsigned long index)
+{
+ item_sanity(item, index);
+ free(item);
+}
+
int item_delete(struct radix_tree_root *root, unsigned long index)
{
struct item *item = radix_tree_delete(root, index);
- if (item) {
- item_sanity(item, index);
- free(item);
- return 1;
- }
- return 0;
+ if (!item)
+ return 0;
+
+ item_free(item, index);
+ return 1;
}
static void item_free_rcu(struct rcu_head *head)