[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] qobject: Use qobject_to() instead of type cast
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH] qobject: Use qobject_to() instead of type cast |
Date: |
Thu, 26 Apr 2018 10:49:01 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 |
On 04/26/2018 10:28 AM, Markus Armbruster wrote:
> The proper way to convert from (abstract) QObject to a (concrete)
> subtype is qobject_to(). Look for offenders that type cast instead:
>
> $ 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. Fix the
> fourth.
>
> Signed-off-by: Markus Armbruster <address@hidden>
> ---
> tests/check-qdict.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Eric Blake <address@hidden>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature