[Mesa-dev] [PATCH] util: fix list_is_singular()
Jason Ekstrand
jason at jlekstrand.net
Wed Jan 11 19:48:41 UTC 2017
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
Please CC stable.
On Tue, Jan 10, 2017 at 8:13 PM, Timothy Arceri <
timothy.arceri at collabora.com> wrote:
> Currently its dependant on the user calling and checking the result
> of list_empty() before using the result of list_is_singular().
> ---
> src/util/list.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/util/list.h b/src/util/list.h
> index e8a99ac..07eb9f3 100644
> --- a/src/util/list.h
> +++ b/src/util/list.h
> @@ -110,7 +110,7 @@ static inline bool list_empty(struct list_head *list)
> */
> static inline bool list_is_singular(const struct list_head *list)
> {
> - return list->next != NULL && list->next->next == list;
> + return list->next != NULL && list->next != list && list->next->next ==
> list;
> }
>
> static inline unsigned list_length(struct list_head *list)
> --
> 2.9.3
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170111/abdf21fc/attachment.html>
More information about the mesa-dev
mailing list