yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

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

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