mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* container-of Implementation
@ 2013-01-14 10:46 Schrober
  2013-01-14 12:22 ` Mikael Pettersson
  2013-01-14 12:23 ` Geert Uytterhoeven
  0 siblings, 2 replies; 3+ messages in thread
From: Schrober @ 2013-01-14 10:46 UTC (permalink / raw)
  To: linux-kernel

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-01-14 12:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-14 10:46 container-of Implementation Schrober
2013-01-14 12:22 ` Mikael Pettersson
2013-01-14 12:23 ` Geert Uytterhoeven

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®