[PATCH xserver v2] Fix uninitialized variable warnings reported by clang

Thomas Klausner wiz at NetBSD.org
Tue Jan 5 22:00:31 PST 2016


Hello Adam!

> If it's not too much trouble, please use git-send-email --in-reply-to
> for followup patches like this.

Thanks, I didn't know about this. I'll use it in the future. And
thanks for the macro fix, it looks good to me.
 Thomas

On Tue, Jan 05, 2016 at 12:51:41PM -0500, Adam Jackson wrote:
> From: Thomas Klausner <wiz at NetBSD.org>
> 
> v2: Move initializing pos into the first clause of the for statement. We
> have to keep this macro equivalent to a plain for statement from the
> user's perspective, otherwise callers need to {} things to keep control
> flow correct. [ajax]
> 
> Signed-off-by: Thomas Klausner <wiz at NetBSD.org>
> Acked-by: Michel Dänzer <michel.daenzer at amd.com>
> ---
>  include/list.h | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/include/list.h b/include/list.h
> index 39f1985..3f0574d 100644
> --- a/include/list.h
> +++ b/include/list.h
> @@ -304,8 +304,9 @@ xorg_list_is_empty(struct xorg_list *head)
>   * @param member Member name of the struct xorg_list in the list elements.
>   *
>   */
> -#define xorg_list_for_each_entry(pos, head, member)				\
> -    for (pos = __container_of((head)->next, pos, member);		\
> +#define xorg_list_for_each_entry(pos, head, member)			\
> +    for (pos = NULL,                                                    \
> +         pos = __container_of((head)->next, pos, member);		\
>  	 &pos->member != (head);					\
>  	 pos = __container_of(pos->member.next, pos, member))
>  
> @@ -317,7 +318,8 @@ xorg_list_is_empty(struct xorg_list *head)
>   * See xorg_list_for_each_entry for more details.
>   */
>  #define xorg_list_for_each_entry_safe(pos, tmp, head, member)		\
> -    for (pos = __container_of((head)->next, pos, member),		\
> +    for (pos = NULL,                                                    \
> +         pos = __container_of((head)->next, pos, member),		\
>  	 tmp = __container_of(pos->member.next, pos, member);		\
>  	 &pos->member != (head);					\
>  	 pos = tmp, tmp = __container_of(pos->member.next, tmp, member))
> -- 
> 2.5.0
> 


More information about the xorg-devel mailing list