mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Brian Gerst <bgerst@quark.didntduck.org>
To: Neil Brown <neilb@cse.unsw.edu.au>
Cc: Linus Torvalds <torvalds@transmeta.com>, linux-kernel@vger.kernel.org
Subject: Re: PATCH: type safe(r) list_entry repacement: generic_out_cast
Date: Tue, 23 Jul 2002 08:42:00 -0400	[thread overview]
Message-ID: <3D3D4F18.2030803@quark.didntduck.org> (raw)
In-Reply-To: <15677.15834.295020.89244@notabene.cse.unsw.edu.au>

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


  parent reply	other threads:[~2002-07-23 12:44 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-07-23 11:28 Neil Brown
2002-07-23 11:47 ` Jakob Oestergaard
2002-07-23 22:07   ` type safe lists (was Re: PATCH: type safe(r) list_entry repacement: generic_out_cast) Joshua MacDonald
2002-07-24  7:39     ` Martin Brulisauer
2002-07-24  8:24       ` Anton Altaparmakov
2002-07-24  9:56       ` Joshua MacDonald
2002-07-24 10:50         ` Martin Brulisauer
2002-07-24 11:58           ` Jakob Oestergaard
2002-07-24 16:49             ` John Alvord
2002-07-25  5:29       ` Greg KH
2002-07-25  6:20         ` Roland Dreier
2002-09-04 13:48         ` Alexander Kellett
2002-09-04 14:27           ` DervishD
2002-07-24 12:22     ` Jakob Oestergaard
2002-07-24 12:40       ` Joshua MacDonald
2002-07-24 15:15         ` Hans Reiser
2002-07-23 12:42 ` Brian Gerst [this message]
2002-07-23 16:29 ` PATCH: type safe(r) list_entry repacement: generic_out_cast Linus Torvalds
2002-07-24  5:25   ` Thunder from the hill
2002-07-23 16:36 ` Christoph Hellwig
2002-07-23 22:58 ` Kevin O'Connor
2002-07-24 12:38 ` PATCH - mark 2: type safe(r) list_entry repacement: container_of Neil Brown
2002-07-24  0:51 PATCH: type safe(r) list_entry repacement: generic_out_cast Mikael Pettersson
2002-07-24  1:04 ` Linus Torvalds

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3D3D4F18.2030803@quark.didntduck.org \
    --to=bgerst@quark.didntduck.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=neilb@cse.unsw.edu.au \
    --cc=torvalds@transmeta.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome