|
|
357786 |
From 94cd049b8c81e2b58113db7cc289218f8925d27d Mon Sep 17 00:00:00 2001
|
|
|
357786 |
From: Markus Armbruster <armbru@redhat.com>
|
|
|
357786 |
Date: Mon, 18 Jun 2018 08:43:09 +0200
|
|
|
357786 |
Subject: [PATCH 02/54] qobject: Ensure base is at offset 0
|
|
|
357786 |
MIME-Version: 1.0
|
|
|
357786 |
Content-Type: text/plain; charset=UTF-8
|
|
|
357786 |
Content-Transfer-Encoding: 8bit
|
|
|
357786 |
|
|
|
357786 |
RH-Author: Markus Armbruster <armbru@redhat.com>
|
|
|
357786 |
Message-id: <20180618084330.30009-3-armbru@redhat.com>
|
|
|
357786 |
Patchwork-id: 80724
|
|
|
357786 |
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH 02/23] qobject: Ensure base is at offset 0
|
|
|
357786 |
Bugzilla: 1557995
|
|
|
357786 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
357786 |
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
|
|
|
357786 |
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
357786 |
|
|
|
357786 |
From: Marc-André Lureau <marcandre.lureau@redhat.com>
|
|
|
357786 |
|
|
|
357786 |
All QObject types have the base QObject as their first field. This
|
|
|
357786 |
allows the simplification of qobject_to().
|
|
|
357786 |
|
|
|
357786 |
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
|
|
|
357786 |
Reviewed-by: Eric Blake <eblake@redhat.com>
|
|
|
357786 |
Message-Id: <20180419150145.24795-2-marcandre.lureau@redhat.com>
|
|
|
357786 |
Reviewed-by: Markus Armbruster <armbru@redhat.com>
|
|
|
357786 |
[Commit message paragraph on type casts dropped, to avoid giving the
|
|
|
357786 |
impression type casting would be okay]
|
|
|
357786 |
Signed-off-by: Markus Armbruster <armbru@redhat.com>
|
|
|
357786 |
(cherry picked from commit 7ee9edfdb117da47c86c9764d90f0be11a648666)
|
|
|
357786 |
|
|
|
357786 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
357786 |
---
|
|
|
357786 |
include/qapi/qmp/qobject.h | 5 ++---
|
|
|
357786 |
qobject/qobject.c | 9 +++++++++
|
|
|
357786 |
2 files changed, 11 insertions(+), 3 deletions(-)
|
|
|
357786 |
|
|
|
357786 |
diff --git a/include/qapi/qmp/qobject.h b/include/qapi/qmp/qobject.h
|
|
|
357786 |
index e022707..5206ff9 100644
|
|
|
357786 |
--- a/include/qapi/qmp/qobject.h
|
|
|
357786 |
+++ b/include/qapi/qmp/qobject.h
|
|
|
357786 |
@@ -61,9 +61,8 @@ struct QObject {
|
|
|
357786 |
QEMU_BUILD_BUG_MSG(QTYPE__MAX != 7,
|
|
|
357786 |
"The QTYPE_CAST_TO_* list needs to be extended");
|
|
|
357786 |
|
|
|
357786 |
-#define qobject_to(type, obj) ({ \
|
|
|
357786 |
- QObject *_tmp = qobject_check_type(obj, glue(QTYPE_CAST_TO_, type)); \
|
|
|
357786 |
- _tmp ? container_of(_tmp, type, base) : (type *)NULL; })
|
|
|
357786 |
+#define qobject_to(type, obj) \
|
|
|
357786 |
+ ((type *)qobject_check_type(obj, glue(QTYPE_CAST_TO_, type)))
|
|
|
357786 |
|
|
|
357786 |
/* Initialize an object to default values */
|
|
|
357786 |
static inline void qobject_init(QObject *obj, QType type)
|
|
|
357786 |
diff --git a/qobject/qobject.c b/qobject/qobject.c
|
|
|
357786 |
index 23600aa..87649c5 100644
|
|
|
357786 |
--- a/qobject/qobject.c
|
|
|
357786 |
+++ b/qobject/qobject.c
|
|
|
357786 |
@@ -16,6 +16,15 @@
|
|
|
357786 |
#include "qapi/qmp/qlist.h"
|
|
|
357786 |
#include "qapi/qmp/qstring.h"
|
|
|
357786 |
|
|
|
357786 |
+QEMU_BUILD_BUG_MSG(
|
|
|
357786 |
+ offsetof(QNull, base) != 0 ||
|
|
|
357786 |
+ offsetof(QNum, base) != 0 ||
|
|
|
357786 |
+ offsetof(QString, base) != 0 ||
|
|
|
357786 |
+ offsetof(QDict, base) != 0 ||
|
|
|
357786 |
+ offsetof(QList, base) != 0 ||
|
|
|
357786 |
+ offsetof(QBool, base) != 0,
|
|
|
357786 |
+ "base qobject must be at offset 0");
|
|
|
357786 |
+
|
|
|
357786 |
static void (*qdestroy[QTYPE__MAX])(QObject *) = {
|
|
|
357786 |
[QTYPE_NONE] = NULL, /* No such object exists */
|
|
|
357786 |
[QTYPE_QNULL] = NULL, /* qnull_ is indestructible */
|
|
|
357786 |
--
|
|
|
357786 |
1.8.3.1
|
|
|
357786 |
|