On 11.12.2025 19:43, Mykola Kvach wrote:
> --- a/xen/include/xen/list.h
> +++ b/xen/include/xen/list.h
> @@ -535,6 +535,20 @@ static inline void list_splice_init(struct list_head 
> *list,
>           &(pos)->member != (head);                                        \
>           (pos) = list_entry((pos)->member.next, typeof(*(pos)), member))
>  
> +/**
> + * list_for_each_entry_continue_reverse - iterate backwards from the given 
> point
> + * @pos:    the type * to use as a loop cursor.
> + * @head:   the head for your list.
> + * @member: the name of the list_head within the struct.
> + *
> + * Start to iterate over list of given type backwards, continuing after
> + * the current position.
> + */
> +#define list_for_each_entry_continue_reverse(pos, head, member)           \
> +    for ((pos) = list_entry((pos)->member.prev, typeof(*(pos)), member);  \
> +         &(pos)->member != (head);                                        \
> +         (pos) = list_entry((pos)->member.prev, typeof(*(pos)), member))
> +
>  /**
>   * list_for_each_entry_from - iterate over list of given type from the
>   *                            current point

While not said so anywhere, I understand this is taken from Linux. Maybe we
should indeed take it verbatim (as far as possible, i.e. without the use of
list_entry_is_head() which we don't have yet), but I'd like to point out
that in the comment "continuing after the current position" is ambiguous.
In list order, what is meant is "before the current position"; "after" is
correct only when considering iteration direction. Personally I would much
prefer if this was disambiguated.

Jan

Reply via email to