|
|
1bdc94 |
From 5dcc5026b76ccfe45ed4a4ed56c8c949ead76e98 Mon Sep 17 00:00:00 2001
|
|
|
1bdc94 |
From: Markus Armbruster <armbru@redhat.com>
|
|
|
1bdc94 |
Date: Mon, 18 Jun 2018 08:43:08 +0200
|
|
|
1bdc94 |
Subject: [PATCH 01/54] qobject: Use qobject_to() instead of type cast
|
|
|
1bdc94 |
MIME-Version: 1.0
|
|
|
1bdc94 |
Content-Type: text/plain; charset=UTF-8
|
|
|
1bdc94 |
Content-Transfer-Encoding: 8bit
|
|
|
1bdc94 |
|
|
|
1bdc94 |
RH-Author: Markus Armbruster <armbru@redhat.com>
|
|
|
1bdc94 |
Message-id: <20180618084330.30009-2-armbru@redhat.com>
|
|
|
1bdc94 |
Patchwork-id: 80732
|
|
|
1bdc94 |
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH 01/23] qobject: Use qobject_to() instead of type cast
|
|
|
1bdc94 |
Bugzilla: 1557995
|
|
|
1bdc94 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
1bdc94 |
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
|
|
|
1bdc94 |
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
1bdc94 |
|
|
|
1bdc94 |
The proper way to convert from (abstract) QObject to a (concrete)
|
|
|
1bdc94 |
subtype is qobject_to(). Look for offenders that type cast instead:
|
|
|
1bdc94 |
|
|
|
1bdc94 |
$ git-grep '(Q[A-Z][a-z]* \*)'
|
|
|
1bdc94 |
hmp.c: qmp_device_add((QDict *)qdict, NULL, &err;;
|
|
|
1bdc94 |
include/qapi/qmp/qobject.h: return (QObject *)obj;
|
|
|
1bdc94 |
qobject/qobject.c:static void (*qdestroy[QTYPE__MAX])(QObject *) = {
|
|
|
1bdc94 |
tests/check-qdict.c: dst = (QDict *)qdict_crumple(src, &error_abort);
|
|
|
1bdc94 |
|
|
|
1bdc94 |
The first two cast away const, the third isn't a type cast. Fix the
|
|
|
1bdc94 |
fourth.
|
|
|
1bdc94 |
|
|
|
1bdc94 |
Signed-off-by: Markus Armbruster <armbru@redhat.com>
|
|
|
1bdc94 |
Message-Id: <20180426152805.8469-1-armbru@redhat.com>
|
|
|
1bdc94 |
Reviewed-by: Eric Blake <eblake@redhat.com>
|
|
|
1bdc94 |
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
|
|
|
1bdc94 |
(cherry picked from commit 46cfbf13b06d551072ed17fbfca67c103edf814f)
|
|
|
1bdc94 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
1bdc94 |
---
|
|
|
1bdc94 |
tests/check-qdict.c | 2 +-
|
|
|
1bdc94 |
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
1bdc94 |
|
|
|
1bdc94 |
diff --git a/tests/check-qdict.c b/tests/check-qdict.c
|
|
|
1bdc94 |
index 2e73c2f..08d4303 100644
|
|
|
1bdc94 |
--- a/tests/check-qdict.c
|
|
|
1bdc94 |
+++ b/tests/check-qdict.c
|
|
|
1bdc94 |
@@ -657,7 +657,7 @@ static void qdict_crumple_test_empty(void)
|
|
|
1bdc94 |
|
|
|
1bdc94 |
src = qdict_new();
|
|
|
1bdc94 |
|
|
|
1bdc94 |
- dst = (QDict *)qdict_crumple(src, &error_abort);
|
|
|
1bdc94 |
+ dst = qobject_to(QDict, qdict_crumple(src, &error_abort));
|
|
|
1bdc94 |
|
|
|
1bdc94 |
g_assert_cmpint(qdict_size(dst), ==, 0);
|
|
|
1bdc94 |
|
|
|
1bdc94 |
--
|
|
|
1bdc94 |
1.8.3.1
|
|
|
1bdc94 |
|