Skip to content

Commit 46cfbf1

Browse files
author
Markus Armbruster
committed
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: Markus Armbruster <[email protected]> Message-Id: <[email protected]> Reviewed-by: Eric Blake <[email protected]> Reviewed-by: Marc-André Lureau <[email protected]>
1 parent 5925588 commit 46cfbf1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tests/check-qdict.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ static void qdict_crumple_test_empty(void)
657657

658658
src = qdict_new();
659659

660-
dst = (QDict *)qdict_crumple(src, &error_abort);
660+
dst = qobject_to(QDict, qdict_crumple(src, &error_abort));
661661

662662
g_assert_cmpint(qdict_size(dst), ==, 0);
663663

0 commit comments

Comments
 (0)