dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Nicolai Hähnle" <nhaehnle@gmail.com>
To: "Michel Dänzer" <michel@daenzer.net>, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH libdrm] Make sure the second argument to container_of() is initialized
Date: Tue, 2 Aug 2016 19:49:02 +0200	[thread overview]
Message-ID: <0f801ab3-1ffa-63dc-988a-676e92b45929@gmail.com> (raw)
In-Reply-To: <1470132535-3006-1-git-send-email-michel@daenzer.net>

On 02.08.2016 12:08, Michel Dänzer wrote:
> From: Michel Dänzer <michel.daenzer@amd.com>
>
> Fixes warnings and miscompilation resulting in crashes with clang.

How annoying. Seems like this would affect most (current and future) 
uses of container_of, and so it would be better to switch to the Linux 
kernel version of container_of, where the second parameter is the type...

Cheers,
Nicolai

>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94249
> Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
> ---
>  amdgpu/amdgpu_vamgr.c |  2 +-
>  util_double_list.h    | 10 +++++-----
>  2 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/amdgpu/amdgpu_vamgr.c b/amdgpu/amdgpu_vamgr.c
> index 8a707cb..3eaef70 100644
> --- a/amdgpu/amdgpu_vamgr.c
> +++ b/amdgpu/amdgpu_vamgr.c
> @@ -157,7 +157,7 @@ amdgpu_vamgr_find_va(struct amdgpu_bo_va_mgr *mgr, uint64_t size,
>  drm_private void
>  amdgpu_vamgr_free_va(struct amdgpu_bo_va_mgr *mgr, uint64_t va, uint64_t size)
>  {
> -	struct amdgpu_bo_va_hole *hole;
> +	struct amdgpu_bo_va_hole *hole = NULL;
>
>  	if (va == AMDGPU_INVALID_VA_ADDRESS)
>  		return;
> diff --git a/util_double_list.h b/util_double_list.h
> index 5d01f52..fc32da5 100644
> --- a/util_double_list.h
> +++ b/util_double_list.h
> @@ -114,29 +114,29 @@ static inline void list_delinit(struct list_head *item)
>  #endif
>
>  #define LIST_FOR_EACH_ENTRY(pos, head, member)				\
> -   for (pos = container_of((head)->next, pos, member);			\
> +   for (pos = NULL, pos = container_of((head)->next, pos, member);	\
>  	&pos->member != (head);						\
>  	pos = container_of(pos->member.next, pos, member))
>
>  #define LIST_FOR_EACH_ENTRY_SAFE(pos, storage, head, member)	\
> -   for (pos = container_of((head)->next, pos, member),			\
> +   for (pos = NULL, pos = container_of((head)->next, pos, member),	\
>  	storage = container_of(pos->member.next, pos, member);	\
>  	&pos->member != (head);						\
>  	pos = storage, storage = container_of(storage->member.next, storage, member))
>
>  #define LIST_FOR_EACH_ENTRY_SAFE_REV(pos, storage, head, member)	\
> -   for (pos = container_of((head)->prev, pos, member),			\
> +   for (pos = NULL, pos = container_of((head)->prev, pos, member),	\
>  	storage = container_of(pos->member.prev, pos, member);		\
>  	&pos->member != (head);						\
>  	pos = storage, storage = container_of(storage->member.prev, storage, member))
>
>  #define LIST_FOR_EACH_ENTRY_FROM(pos, start, head, member)		\
> -   for (pos = container_of((start), pos, member);			\
> +   for (pos = NULL, pos = container_of((start), pos, member);		\
>  	&pos->member != (head);						\
>  	pos = container_of(pos->member.next, pos, member))
>
>  #define LIST_FOR_EACH_ENTRY_FROM_REV(pos, start, head, member)		\
> -   for (pos = container_of((start), pos, member);			\
> +   for (pos = NULL, pos = container_of((start), pos, member);		\
>  	&pos->member != (head);						\
>  	pos = container_of(pos->member.prev, pos, member))
>
>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2016-08-02 17:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-02 10:08 [PATCH libdrm] Make sure the second argument to container_of() is initialized Michel Dänzer
2016-08-02 14:29 ` Alex Deucher
2016-08-02 17:49 ` Nicolai Hähnle [this message]
2016-08-03  8:56   ` Michel Dänzer
2016-08-03 11:20     ` Rob Clark

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0f801ab3-1ffa-63dc-988a-676e92b45929@gmail.com \
    --to=nhaehnle@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=michel@daenzer.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox