From: Schrober <franzschrober@yahoo.de>
To: linux-kernel@vger.kernel.org
Subject: container-of Implementation
Date: Mon, 14 Jan 2013 11:46:05 +0100 [thread overview]
Message-ID: <1635127.Ytukyo95FQ@bentobox> (raw)
Hi,
I wondered why the container_of implementation is so complicated.
#define container_of(ptr, type, member) ({ \
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
(type *)( (char *)__mptr - offsetof(type,member) );})
isn't the __mptr not unnecessary? Why not following version?
#define container_of(ptr, type, member) \
((type *)((char *)(ptr) - offsetof(type, member)))
--
Franz Schrober
next reply other threads:[~2013-01-14 10:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-14 10:46 Schrober [this message]
2013-01-14 12:22 ` Mikael Pettersson
2013-01-14 12:23 ` Geert Uytterhoeven
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=1635127.Ytukyo95FQ@bentobox \
--to=franzschrober@yahoo.de \
--cc=linux-kernel@vger.kernel.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
all inboxes | Powered by JetHome®