[igt-dev] [PATCH i-g-t v33 02/39] lib/igt_list: Add igt_list_for_each_entry_safe_reverse

Zbigniew Kempczyński zbigniew.kempczynski at intel.com
Tue Apr 13 13:37:05 UTC 2021


On Tue, Apr 13, 2021 at 10:41:49AM +0200, Zbigniew Kempczyński wrote:
> From: Dominik Grzegorzek <dominik.grzegorzek at intel.com>
> 
> Added safe version of reversed iteration over igt_list.
> 
> Signed-off-by: Dominik Grzegorzek <dominik.grzegorzek at intel.com>
> Cc: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
> Cc: Chris Wilson <chris at chris-wilson.co.uk>

This patch is correct imo:

Reviewed-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>

--
Zbigniew

> ---
>  lib/igt_list.h | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/lib/igt_list.h b/lib/igt_list.h
> index cc93d7a0d..be63fd806 100644
> --- a/lib/igt_list.h
> +++ b/lib/igt_list.h
> @@ -108,6 +108,12 @@ bool igt_list_empty(const struct igt_list_head *head);
>  	     &pos->member != (head);					\
>  	     pos = igt_container_of((pos)->member.prev, pos, member))
>  
> +#define igt_list_for_each_entry_safe_reverse(pos, tmp, head, member)	\
> +	for (pos = igt_container_of((head)->prev, pos, member),		\
> +	     tmp = igt_container_of((pos)->member.prev, tmp, member);	\
> +	     &pos->member != (head);					\
> +	     pos = tmp,							\
> +	     tmp = igt_container_of((pos)->member.prev, tmp, member))
>  
>  /* IGT custom helpers */
>  
> -- 
> 2.26.0
> 
> _______________________________________________
> igt-dev mailing list
> igt-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/igt-dev


More information about the igt-dev mailing list