[Mesa-dev] [PATCH] glsl/list: make nodes safe for double removal, etc.

Kenneth Graunke kenneth at whitecape.org
Tue Apr 5 07:52:22 UTC 2016


On Saturday, April 2, 2016 5:09:27 PM PDT Rob Clark wrote:
> From: Rob Clark <robclark at freedesktop.org>
> 
> It's no extra overhead to do a _self_link() and it eliminates a class of
> potential problems.
> 
> Signed-off-by: Rob Clark <robclark at freedesktop.org>
> Dared-by: Jason Ekstrand <jason at jlekstrand.net>
> ---
>  src/compiler/glsl/list.h | 15 +++++++--------
>  1 file changed, 7 insertions(+), 8 deletions(-)
> 
> diff --git a/src/compiler/glsl/list.h b/src/compiler/glsl/list.h
> index a1c4d82..77e1f67 100644
> --- a/src/compiler/glsl/list.h
> +++ b/src/compiler/glsl/list.h
> @@ -165,19 +165,18 @@ exec_node_get_prev(struct exec_node *n)
>  }
>  
>  static inline void
> -exec_node_remove(struct exec_node *n)
> +exec_node_self_link(struct exec_node *n)
>  {
> -   n->next->prev = n->prev;
> -   n->prev->next = n->next;
> -   n->next = NULL;
> -   n->prev = NULL;
> +   n->next = n;
> +   n->prev = n;
>  }
>  
>  static inline void
> -exec_node_self_link(struct exec_node *n)
> +exec_node_remove(struct exec_node *n)
>  {
> -   n->next = n;
> -   n->prev = n;
> +   n->next->prev = n->prev;
> +   n->prev->next = n->next;
> +   exec_node_self_link(n);
>  }
>  
>  static inline void
> 

I don't get it.

The existing behavior of having unlinked nodes have NULL prev/next
pointers seems perfectly reasonable to me.

Removing a node multiple times seems like a mistake in the caller.

--Ken
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160405/9ac1796d/attachment.sig>


More information about the mesa-dev mailing list