Re: [PATCH v3 28/35] maple_tree: Add mas_next_range() and mas_find_range() interfaces

From: Andrew Morton
Date: Fri May 12 2023 - 19:09:04 EST


On Fri, 12 May 2023 14:20:29 -0400 "Liam R. Howlett" <Liam.Howlett@xxxxxxxxxx> wrote:

> Some users of the maple tree may want to move to the next range in the
> tree, even if it stores a NULL. This family of function provides that
> functionality by advancing one slot at a time and returning the result,
> while mas_contiguous() will iterate over the range and stop on
> encountering the first NULL.
>
> ...
>
> +/**
> + * mas_contiguous() - Iterate over a contiguous range of the maple tree.
> + * @__mas: Maple Tree operation state (maple_state)
> + * @__entry: Entry retrieved from the tree
> + * @__max: maximum index to retrieve from the tree
> + *
> + * When returned, mas->index and mas->last will hold the entire range of the
> + * entry. The loop will terminate on the first NULL encountered.
> + *
> + * Note: may return the zero entry.
> + */
> +#define mas_contiguous(__mas, __entry, __max) \
> + while (((__entry) = mas_find_range((__mas), (__max))) != NULL)
>

I can's say I'm a fan of this. The name doesn't imply that this is a
looping construct. I can't say much more because mas_contiguous() has
no users..