lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 31 Aug 2011 09:14:59 +1000
From:	Ryan Mallon <rmallon@...il.com>
To:	peter <lifulong2c2i2c@...il.com>
CC:	linux-kernel@...r.kernel.org
Subject: Re: Question with "container_of(ptr, type, member)"

On 30/08/11 20:44, peter wrote:
> I have a question about the macro " container_of(ptr, type, member) "
> I can write it as this,
>   #define container_of(ptr, type, member) ({ \
> 	(type *) ((char *) ptr - offset_of(type, member)); \
> 	})
> It can act the same as
> #define container_of(ptr, type, member) ({            \
> 	 const typeof( ((type *)0)->member ) *__mptr = (ptr);    \
> 	 (type *)( (char *)__mptr - offsetof(type,member) );})
> So why we don't use the first one ?
> Thanks for your answer.
> (I am a kernel newbie ,and sorry for my poor english~)

The version used by the Linux kernel does type checking.

~Ryan

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ