qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paul Brook <paul@codesourcery.com>
To: qemu-devel@nongnu.org
Cc: Blue Swirl <blauwirbel@gmail.com>, Markus Armbruster <armbru@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2 2/7] ioapic: convert to qdev
Date: Tue, 15 Jun 2010 01:25:22 +0100	[thread overview]
Message-ID: <201006150125.22743.paul@codesourcery.com> (raw)
In-Reply-To: <AANLkTimPE6HXwmtr923DjPJAOYENSfbxlbVPGpdJK-hr@mail.gmail.com>

> >> -static void ioapic_reset(void *opaque)
> >> +static void ioapic_reset(DeviceState *d)
> >>  {
> >> -    IOAPICState *s = opaque;
> >> +    IOAPICState *s = container_of(d, IOAPICState, busdev.qdev);
> > 
> > DO_UPCAST()?  I hate it, but it's what the other devices do...
> 
> Both are used:
> grep container_of hw/*.[ch]|wc -l
> 81
> grep DO_UPCAST hw/*.[ch]|wc -l
> 246

Which is appropriate depends on the context.

DO_UPCAST is appropriate when we're dealing with polymorphic types. In this 
case IOAPICState is derived from DeviceState (via SysBusDevice). There is an 
implicit assumption that these are all the same object, so DO_UPCAST is 
approprate.

container_of is approriate when we're embedding one object in annother, but 
without any inheritance relationship between the two.

Paul

      reply	other threads:[~2010-06-15  0:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-12 21:14 [Qemu-devel] [PATCH v2 2/7] ioapic: convert to qdev Blue Swirl
2010-06-14  9:33 ` Markus Armbruster
2010-06-14 17:41   ` Blue Swirl
2010-06-15  0:25     ` Paul Brook [this message]

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=201006150125.22743.paul@codesourcery.com \
    --to=paul@codesourcery.com \
    --cc=armbru@redhat.com \
    --cc=blauwirbel@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /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;
as well as URLs for NNTP newsgroup(s).