From: Jan Blunck <jblunck@infradead.org>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 2/2] Ensure constness of target pointer type
Date: Tue, 14 Feb 2017 15:36:06 +0100 [thread overview]
Message-ID: <1487082966-21074-2-git-send-email-jblunck@infradead.org> (raw)
In-Reply-To: <1487082966-21074-1-git-send-email-jblunck@infradead.org>
This adds a check to ensure that the container_of() macro is not used to
cast away (remove) constness.
Signed-off-by: Jan Blunck <jblunck@infradead.org>
---
lib/librte_eal/common/include/rte_common.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/common/include/rte_common.h
index c421708..e057f6e 100644
--- a/lib/librte_eal/common/include/rte_common.h
+++ b/lib/librte_eal/common/include/rte_common.h
@@ -348,6 +348,8 @@ rte_bsf32(uint32_t v)
#ifndef container_of
#define container_of(ptr, type, member) __extension__ ({ \
const typeof(((type *)0)->member) *_ptr = (ptr); \
+ __attribute__((unused)) type *_target_ptr = \
+ (type *)(ptr); \
(type *)(((uintptr_t)_ptr) - offsetof(type, member)); \
})
#endif
--
2.7.4
next prev parent reply other threads:[~2017-02-14 14:36 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-14 14:36 [dpdk-dev] [PATCH 1/2] Fix container_of() macro to work with const members Jan Blunck
2017-02-14 14:36 ` Jan Blunck [this message]
2017-02-27 14:28 ` Jan Blunck
2017-02-27 15:14 ` 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=1487082966-21074-2-git-send-email-jblunck@infradead.org \
--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
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;
as well as URLs for NNTP newsgroup(s).