From: Eric Blake <eblake@redhat.com>
To: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Cc: qemu-devel <qemu-devel@nongnu.org>,
"P. Berrange, Daniel" <berrange@redhat.com>,
"Armbruster, Markus" <armbru@redhat.com>,
"Bonzini, Paolo" <pbonzini@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2 2/3] qobject: introduce QObjectCommon
Date: Wed, 28 Mar 2018 08:55:51 -0500 [thread overview]
Message-ID: <ac132600-ac94-c9b7-b280-f2ff2ebebf74@redhat.com> (raw)
In-Reply-To: <CAMxuvayFZiYwf99mbMVFVwFZR2Bnqfv4rYS1O2SpDT1mhFtAEg@mail.gmail.com>
On 03/28/2018 08:48 AM, Marc-André Lureau wrote:
>>> +#define QOBJECT(x) \
>>> + container_of(&(x)->base, QObject, base)
>>
>>
>> If I understand correctly, this still causes clang complaints when called as
>> QOBJECT(NULL). As long as we are touching this, should we improve this
>> macro to be friendly to NULL conversion?
>
> I don't see much need for allowing NULL (literally) to be passed to
> QOBJECT(). If it's a null pointer, as long as it has the right type,
> it should be fine, shouldn't it?
Not with clang ubsan (okay, the failure is at runtime, not compile time):
https://lists.gnu.org/archive/html/qemu-devel/2018-03/msg05143.html
https://lists.gnu.org/archive/html/qemu-devel/2018-03/msg05148.html
Even when the offset is 0, the mere fact that you are computing an
offset relative to a NULL pointer is undefined behavior.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
next prev parent reply other threads:[~2018-03-28 13:56 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-28 13:07 [Qemu-devel] [PATCH v2 0/3] RFC: simplify qobject refcount Marc-André Lureau
2018-03-28 13:07 ` [Qemu-devel] [PATCH v2 1/3] qobject: ensure base is at offset 0 Marc-André Lureau
2018-03-28 13:07 ` [Qemu-devel] [PATCH v2 2/3] qobject: introduce QObjectCommon Marc-André Lureau
2018-03-28 13:45 ` Eric Blake
2018-03-28 13:48 ` Marc-André Lureau
2018-03-28 13:55 ` Eric Blake [this message]
2018-03-28 14:11 ` Paolo Bonzini
2018-03-28 14:19 ` Marc-André Lureau
2018-03-28 13:07 ` [Qemu-devel] [PATCH v2 3/3] qobject: replace qobject_incref/QINCREF qobject_decref/QDECREF Marc-André Lureau
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=ac132600-ac94-c9b7-b280-f2ff2ebebf74@redhat.com \
--to=eblake@redhat.com \
--cc=armbru@redhat.com \
--cc=berrange@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.