Also, from the archives: <a href="http://www.mail-archive.com/kernelnewbies@nl.linux.org/msg12320.html">http://www.mail-archive.com/kernelnewbies@nl.linux.org/msg12320.html</a><br><br><div class="gmail_quote">On Fri, Mar 9, 2012 at 7:21 PM, Vijay Chauhan <span dir="ltr"><<a href="mailto:kernel.vijay@gmail.com">kernel.vijay@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I'm checking the container_of and offsetof macro<br>
<br>
#define container_of(ptr, type, member) ({ \<br>
const typeof( ((type *)0)->member ) *__mptr = (ptr);<br>
(type *)( (char *)__mptr - offsetof(type,member) );})<br>
<br>
#define offsetof(TYPE, MEMBER) \<br>
((size_t) &((TYPE *)0)->MEMBER)<br>
<br>
<br>
I did not understand the first line of both macro. Will it not create<br>
the NULL pointer dereference problem? I know it works and read some<br>
article but it did not explain this part, so can anyone explain why<br>
the NULL pointer error is not coming. Am I missing something?<br>
Any C language specification of such example.<br>
<br>
_______________________________________________<br>
Kernelnewbies mailing list<br>
<a href="mailto:Kernelnewbies@kernelnewbies.org">Kernelnewbies@kernelnewbies.org</a><br>
<a href="http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" target="_blank">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>/manohar<br>