mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Ian Abbott <abbotti@mev.co.uk>
Cc: Michal Nazarewicz <mina86@mina86.com>,
	linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	Hidehiro Kawai <hidehiro.kawai.ez@hitachi.com>,
	Borislav Petkov <bp@suse.de>,
	Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	Johannes Berg <johannes.berg@intel.com>,
	Alexander Potapenko <glider@google.com>
Subject: Re: [PATCH v2] kernel.h: handle pointers to arrays better in container_of()
Date: Tue, 23 May 2017 13:24:15 +0200	[thread overview]
Message-ID: <20170523112415.nmbazvqmlhy343f2@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <139f0546-9b0a-d119-6b96-a9b35559be4b@mev.co.uk>

On Tue, May 23, 2017 at 11:32:02AM +0100, Ian Abbott wrote:

> > #define container_of(ptr, type, member) (				\
> > 	_Static_assert(__builtin_types_compatible_p(			\
> >             typeof(*ptr), typeof( ((type *)0)->member )), "WUT"),	\
> > 	((type *)((char *)(ptr) - offsetof(type, member)));		\
> > )
> 
> It's a fine suggestion (if more parentheses are added), but _Static_assert
> is a C11 feature, and I thought the kernel was using gnu89 (unless it's been
> updated since).

We have BUILD_BUG_ON() that should be similar in functionality.

  reply	other threads:[~2017-05-23 11:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-22 15:03 Ian Abbott
2017-05-22 17:58 ` Michal Nazarewicz
2017-05-23 10:32   ` Ian Abbott
2017-05-23 11:24     ` Peter Zijlstra [this message]
2017-05-23 12:02       ` Ian Abbott
2017-05-23 13:23         ` Ian Abbott
2017-05-23 14:14           ` Ian Abbott

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=20170523112415.nmbazvqmlhy343f2@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=abbotti@mev.co.uk \
    --cc=akpm@linux-foundation.org \
    --cc=bp@suse.de \
    --cc=glider@google.com \
    --cc=hidehiro.kawai.ez@hitachi.com \
    --cc=johannes.berg@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=mina86@mina86.com \
    /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®