mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 04:33:26 +02:00
XArray: Change xa_for_each iterator
There were three problems with this API: 1. It took too many arguments; almost all users wanted to iterate over every element in the array rather than a subset. 2. It required that 'index' be initialised before use, and there's no realistic way to make GCC catch that. 3. 'index' and 'entry' were the opposite way round from every other member of the XArray APIs. So split it into three different APIs: xa_for_each(xa, index, entry) xa_for_each_start(xa, index, entry, start) xa_for_each_marked(xa, index, entry, filter) Signed-off-by: Matthew Wilcox <willy@infradead.org>
This commit is contained in:
@@ -357,7 +357,7 @@ static noinline void check_cmpxchg(struct xarray *xa)
|
||||
static noinline void check_reserve(struct xarray *xa)
|
||||
{
|
||||
void *entry;
|
||||
unsigned long index = 0;
|
||||
unsigned long index;
|
||||
|
||||
/* An array with a reserved entry is not empty */
|
||||
XA_BUG_ON(xa, !xa_empty(xa));
|
||||
@@ -393,7 +393,7 @@ static noinline void check_reserve(struct xarray *xa)
|
||||
xa_reserve(xa, 6, GFP_KERNEL);
|
||||
xa_store_index(xa, 7, GFP_KERNEL);
|
||||
|
||||
xa_for_each(xa, entry, index, ULONG_MAX, XA_PRESENT) {
|
||||
xa_for_each(xa, index, entry) {
|
||||
XA_BUG_ON(xa, index != 5 && index != 7);
|
||||
}
|
||||
xa_destroy(xa);
|
||||
@@ -812,17 +812,16 @@ static noinline void check_find_1(struct xarray *xa)
|
||||
static noinline void check_find_2(struct xarray *xa)
|
||||
{
|
||||
void *entry;
|
||||
unsigned long i, j, index = 0;
|
||||
unsigned long i, j, index;
|
||||
|
||||
xa_for_each(xa, entry, index, ULONG_MAX, XA_PRESENT) {
|
||||
xa_for_each(xa, index, entry) {
|
||||
XA_BUG_ON(xa, true);
|
||||
}
|
||||
|
||||
for (i = 0; i < 1024; i++) {
|
||||
xa_store_index(xa, index, GFP_KERNEL);
|
||||
j = 0;
|
||||
index = 0;
|
||||
xa_for_each(xa, entry, index, ULONG_MAX, XA_PRESENT) {
|
||||
xa_for_each(xa, index, entry) {
|
||||
XA_BUG_ON(xa, xa_mk_index(index) != entry);
|
||||
XA_BUG_ON(xa, index != j++);
|
||||
}
|
||||
|
Reference in New Issue
Block a user