Blame SOURCES/kvm-qobject-Use-qobject_to-instead-of-type-cast.patch

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