All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>,
	qemu-devel@nongnu.org, pbonzini@redhat.com
Subject: Re: [Qemu-devel] [PATCH v5 1/5] qobject: ensure base is at offset 0
Date: Wed, 18 Apr 2018 18:45:05 +0200	[thread overview]
Message-ID: <87po2wsbu6.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <ea5c5be8-2e0f-ed00-8ce1-aee6d6e117d4@redhat.com> (Eric Blake's message of "Tue, 17 Apr 2018 13:17:46 -0500")

Eric Blake <eblake@redhat.com> writes:

> On 04/17/2018 08:35 AM, Marc-André Lureau wrote:
>> All QObject types have the base QObject as first field. This allows to
>
> s/as/as their/
>
>> simplify qobject_to() and will allow further simplification in
>
> s/allows to simplify/allows the simplification of/
> s/in/in the/
>
>> following patch.
>
> Might also be worth mentioning that this explicitly guarantees that
> existing casts work correctly (even though we'd prefer to get rid of
> such casts in any location except the qobject.h macros); Markus pointed out:
>
>>> Uh, there's another reason: existing type casts from QObject * to
>>> subtypes.  I just spotted one in tests/check-qdict.c:
>>> 
>>>     dst = (QDict *)qdict_crumple(src, &error_abort);

As far as I'm concerned, that's the real reason.  The simplification
plus the check to make it safe seems like a wash.

The cast I spotted appears to be the only one, though:

    $ git-grep '(Q[A-Z][a-z]* \*)'
    hmp.c:    qmp_device_add((QDict *)qdict, NULL, &err);
    include/qapi/qmp/qobject.h:        return (QObject *)obj;
    qobject/qobject.c:static void (*qdestroy[QTYPE__MAX])(QObject *) = {
    tests/check-qdict.c:    dst = (QDict *)qdict_crumple(src, &error_abort);

The first two cast away const, the third isn't a type cast.  The fourth
one should use qobject_to() instead, regardless of this patch.

Do we want to force base to come first anyway?

Where does PATCH 2 exploit "base first"?

[...]

  reply	other threads:[~2018-04-18 16:45 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-17 13:35 [Qemu-devel] [PATCH v5 0/5] Simplify qobject refcount Marc-André Lureau
2018-04-17 13:35 ` [Qemu-devel] [PATCH v5 1/5] qobject: ensure base is at offset 0 Marc-André Lureau
2018-04-17 18:17   ` Eric Blake
2018-04-18 16:45     ` Markus Armbruster [this message]
2018-04-18 16:58       ` Marc-André Lureau
2018-04-18 17:04       ` Eric Blake
2018-04-19  6:07         ` Markus Armbruster
2018-04-17 13:35 ` [Qemu-devel] [PATCH v5 2/5] qobject: use a QObjectBase_ struct Marc-André Lureau
2018-04-17 18:33   ` Eric Blake
2018-04-19  6:11   ` Markus Armbruster
2018-04-17 13:36 ` [Qemu-devel] [PATCH v5 3/5] qobject: replace qobject_incref/QINCREF qobject_decref/QDECREF Marc-André Lureau
2018-04-17 18:46   ` Eric Blake
2018-04-19  6:16   ` Markus Armbruster
2018-04-19 14:27     ` Marc-André Lureau
2018-04-17 13:36 ` [Qemu-devel] [PATCH v5 4/5] qobject: modify qobject_ref() to return obj Marc-André Lureau
2018-04-17 18:50   ` Eric Blake
2018-04-19  6:25     ` Markus Armbruster
2018-04-17 13:36 ` [Qemu-devel] [PATCH v5 5/5] qobject: modify qobject_ref() to assert on NULL Marc-André Lureau
2018-04-17 18:51   ` Eric Blake
2018-04-19  6:18   ` Markus Armbruster
2018-04-19 13:37     ` Marc-André Lureau
2018-04-19  6:44 ` [Qemu-devel] [PATCH v5 0/5] Simplify qobject refcount Markus Armbruster
2018-04-19 10:09   ` Marc-André Lureau
2018-04-19 11:48     ` Marc-André Lureau
2018-04-19 13:13       ` 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=87po2wsbu6.fsf@dusky.pond.sub.org \
    --to=armbru@redhat.com \
    --cc=eblake@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=pbonzini@redhat.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 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.