All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] DO_UPCAST confusion
Date: Thu, 22 Oct 2015 14:00:18 +0200	[thread overview]
Message-ID: <87eggn6rl9.fsf@blackfin.pond.sub.org> (raw)
In-Reply-To: <CAFEAcA_qccTriuJd5PkysP5DA_JS7_Vv8nMg2kqaiPTxEbuv6g@mail.gmail.com> (Peter Maydell's message of "Thu, 22 Oct 2015 10:58:09 +0100")

Peter Maydell <peter.maydell@linaro.org> writes:

> On 21 October 2015 at 23:49, Eric Blake <eblake@redhat.com> wrote:
>> I much prefer the name container_of() (which is a bit more obvious that
>> it is finding the container or derived type that embeds the parent
>> type), but if we have to keep the ugly name, could we at least clean up
>> the comment to make sense, and fix the name to be DO_DOWNCAST to match
>> what it is actually doing?

DO_UPCAST() needs deletion, not renaming.

> You can't call this one container_of, because it's doing
> container_of plus extra checking.
>
> As Gerd says, most of these uses should probably go away, but
> ideally by conversion to the QOM cast macros rather than
> just dropping down to use of container_of.

Yes, any DO_UPCAST() of QOM objects should be converted to the proper
QOM casts.

DO_UPCAST() of something that should be a QOM object... well, ideally
the something should be converted to QOM, but that's hardly simple
cleanup.

Any DO_UPCAST() that have crept into other code could be simply replaced
by container_of().  If we want to keep the extra checking Peter
mentioned, we could have a container_of_checked() or something.  *Not* a
renamed DO_UPCAST(), because DO_UPCAST() pointlessly takes its arguments
in a different order than container_of().

  reply	other threads:[~2015-10-22 12:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-21 22:49 [Qemu-devel] DO_UPCAST confusion Eric Blake
2015-10-22  7:26 ` Gerd Hoffmann
2015-10-22  9:58 ` Peter Maydell
2015-10-22 12:00   ` Markus Armbruster [this message]
2015-10-22 13:55     ` Eric Blake
2015-10-22 14:00       ` Paolo Bonzini
2015-10-22 14:48       ` Markus Armbruster

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=87eggn6rl9.fsf@blackfin.pond.sub.org \
    --to=armbru@redhat.com \
    --cc=peter.maydell@linaro.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.