Re: Query: why do the ptr_list subtypes have a different structure?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Aug 11, 2017 at 10:17:34AM +0100, Dibyendu Majumdar wrote:
> One thing that has puzzled me from the start is why the subtypes of
> ptr_list have a different structure. Is there a reason for that?

You're asking why struct ptr_list begin with :
	int nr;
	.. next;
	.. prev;
and then only:
	void *list[NR];

while the real lists are declared via DECLARE_PTR_LIST() as:
	struct ... *list[1];

right?

Only Linus can really answer to this but it seems that it is done
so simply so that directly dereferencing those lists will give
garbage as best, crashes most of the time to discourage.
The goal being to force the use of the macros/discourage to
directly access them, and so enforce the type checking.

-- Luc
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux