remove-irqlock-2.5.27-F3Neil Brown wrote:
> list.h has this nifty macro called list_entry that takes a pointer to a "struct
> list_head" and "casts" that to a pointer to some structure that
> contains the "struct list_head".
>
> However it doesn't do any type checking on the pointer, and you can
> give it a pointer to something else... just as I did in line 850 of
> md/md.c :-(
>
> So I thought I would add some type checking to list_entry so that
> you have to pass it a "struct list_head *", but I then discovered that
> lots of places are using list_entry to do creative casting on
> all sorts of other things like inodes embedded in bigger structures
> and so on.
>
> So... I have created "generic_out_cast" which is like the old
> list_entry but with an extra type arguement. I have then
> changed uses of list_entry that did not actually apply to lists to use
> generic_out_cast, often indirectly.
>
> Why "out_cast"???
>
> Well OO people would probably call it a "down cast" as you are
> effectively casting from a more-general type to a less-general (more
> specific) type that is there-fore lower on the type latice.
> So maybe it should be "generic_down_cast".
> But seeing that one is casting from an embeded internal structure to a
> containing external structure, "out_cast" seemed a little easier to
> intuitively understand.
>
> If anyone wants to suggest better names of any of the names I have
> chosen, feel free to submit suggestions or patches.
How about member_to_struct() or unembed()?
-- Brian Gerst- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
This archive was generated by hypermail 2b29 : Tue Jul 23 2002 - 22:00:42 EST