DPDK patches and discussions
 help / color / mirror / Atom feed
From: Jan Blunck <jblunck@infradead.org>
To: dev <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH 1/2] Fix container_of() macro to work with const members
Date: Mon, 27 Feb 2017 15:28:14 +0100
Message-ID: <CALe+Z03mq8s72DXra2ANf4y7vk2gdunWAs1zrhogNwoc1Td1iA@mail.gmail.com> (raw)
In-Reply-To: <1487082966-21074-1-git-send-email-jblunck@infradead.org>

On Tue, Feb 14, 2017 at 3:36 PM, Jan Blunck <jblunck@infradead.org> wrote:
> This fixes the usage of structure members that are declared const to get
> a pointer to the embedding parent structure.

Ping. Is anyone willing to review this?

Thanks,
Jan

>
> Signed-off-by: Jan Blunck <jblunck@infradead.org>
> ---
>  lib/librte_eal/common/include/rte_common.h | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/common/include/rte_common.h
> index 8dda3e2..c421708 100644
> --- a/lib/librte_eal/common/include/rte_common.h
> +++ b/lib/librte_eal/common/include/rte_common.h
> @@ -347,8 +347,9 @@ rte_bsf32(uint32_t v)
>   */
>  #ifndef container_of
>  #define container_of(ptr, type, member)        __extension__ ({                \
> -                       typeof(((type *)0)->member) *_ptr = (ptr);      \
> -                       (type *)(((char *)_ptr) - offsetof(type, member)); })
> +                       const typeof(((type *)0)->member) *_ptr = (ptr); \
> +                       (type *)(((uintptr_t)_ptr) - offsetof(type, member)); \
> +               })
>  #endif
>
>  #define _RTE_STR(x) #x
> --
> 2.7.4
>

  parent reply	other threads:[~2017-02-27 14:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-14 14:36 Jan Blunck
2017-02-14 14:36 ` [dpdk-dev] [PATCH 2/2] Ensure constness of target pointer type Jan Blunck
2017-02-27 14:28 ` Jan Blunck [this message]
2017-02-27 15:14   ` [dpdk-dev] [PATCH 1/2] Fix container_of() macro to work with const members Bruce Richardson
2017-03-08 14:01     ` Thomas Monjalon

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=CALe+Z03mq8s72DXra2ANf4y7vk2gdunWAs1zrhogNwoc1Td1iA@mail.gmail.com \
    --to=jblunck@infradead.org \
    --cc=dev@dpdk.org \
    /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

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git