提交 46cfbf13 编写于 作者: M Markus Armbruster

qobject: Use qobject_to() instead of type cast

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: NMarkus Armbruster <armbru@redhat.com>
Message-Id: <20180426152805.8469-1-armbru@redhat.com>
Reviewed-by: NEric Blake <eblake@redhat.com>
Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
上级 59255887
......@@ -657,7 +657,7 @@ static void qdict_crumple_test_empty(void)
src = qdict_new();
dst = (QDict *)qdict_crumple(src, &error_abort);
dst = qobject_to(QDict, qdict_crumple(src, &error_abort));
g_assert_cmpint(qdict_size(dst), ==, 0);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册