From: Eduardo Habkost <ehabkost@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [RFC v2 6/9] Explicitly cast the *_GET_CLASS() value when we break the rules
Date: Wed, 29 Mar 2017 16:41:45 -0300 [thread overview]
Message-ID: <20170329194148.19015-7-ehabkost@redhat.com> (raw)
In-Reply-To: <20170329194148.19015-1-ehabkost@redhat.com>
object_get_class() and *_GET_CLASS() macros are going to be
changed to return const pointers because the class structs are
supposed to be initialized at class_init and not be changed
later.
However, there are a few places the code still break the
(proposed) rules, and change class data outside class_init. On
those cases, add an explicit cast to the *_GET_CLASS() return
value.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
hw/core/bus.c | 2 +-
hw/mips/mips_jazz.c | 2 +-
hw/xen/xen_backend.c | 2 +-
target/s390x/cpu.c | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/hw/core/bus.c b/hw/core/bus.c
index 4651f24486..9233f8723b 100644
--- a/hw/core/bus.c
+++ b/hw/core/bus.c
@@ -90,7 +90,7 @@ static void qbus_realize(BusState *bus, DeviceState *parent, const char *name)
bus->name = g_strdup_printf("%s.%d", bus->parent->id, bus_id);
} else {
/* no id -> use lowercase bus type plus global bus-id for bus name */
- bc = BUS_GET_CLASS(bus);
+ bc = (BusClass *)BUS_GET_CLASS(bus);
bus_id = bc->automatic_ids++;
bus->name = g_strdup_printf("%s.%d", typename, bus_id);
for (i = 0; bus->name[i]; i++) {
diff --git a/hw/mips/mips_jazz.c b/hw/mips/mips_jazz.c
index 1cef581878..0407d998f1 100644
--- a/hw/mips/mips_jazz.c
+++ b/hw/mips/mips_jazz.c
@@ -166,7 +166,7 @@ static void mips_jazz_init(MachineState *machine,
* CPU, which raise an exception.
* Handle that case by hijacking the do_unassigned_access method on
* the CPU, and do not raise exceptions for data access. */
- cc = CPU_GET_CLASS(cpu);
+ cc = (CPUClass *)CPU_GET_CLASS(cpu);
real_do_unassigned_access = cc->do_unassigned_access;
cc->do_unassigned_access = mips_jazz_do_unassigned_access;
diff --git a/hw/xen/xen_backend.c b/hw/xen/xen_backend.c
index 6e530681f4..541ebb226c 100644
--- a/hw/xen/xen_backend.c
+++ b/hw/xen/xen_backend.c
@@ -553,7 +553,7 @@ err:
static void xen_set_dynamic_sysbus(void)
{
Object *machine = qdev_get_machine();
- MachineClass *mc = MACHINE_GET_CLASS(machine);
+ MachineClass *mc = (MachineClass *)MACHINE_GET_CLASS(machine);
mc->has_dynamic_sysbus = true;
}
diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c
index 066dcd17df..07eb8b745f 100644
--- a/target/s390x/cpu.c
+++ b/target/s390x/cpu.c
@@ -174,7 +174,7 @@ static void s390_cpu_disas_set_info(CPUState *cpu, disassemble_info *info)
static void s390_cpu_realizefn(DeviceState *dev, Error **errp)
{
CPUState *cs = CPU(dev);
- S390CPUClass *scc = S390_CPU_GET_CLASS(dev);
+ S390CPUClass *scc = (S390CPUClass *)S390_CPU_GET_CLASS(dev);
S390CPU *cpu = S390_CPU(dev);
CPUS390XState *env = &cpu->env;
Error *err = NULL;
--
2.11.0.259.g40922b1
next prev parent reply other threads:[~2017-03-29 19:43 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-29 19:41 [Qemu-devel] [RFC v2 0/9] qom: Make object_get_class()/*_GET_CLASS return const pointers Eduardo Habkost
2017-03-29 19:41 ` [Qemu-devel] [RFC v2 1/9] configure: test if _Generic works as expected Eduardo Habkost
2017-03-29 19:41 ` [Qemu-devel] [RFC v2 2/9] Simplify code using *MACHINE_GET_CLASS Eduardo Habkost
2017-03-29 19:41 ` [Qemu-devel] [RFC v2 3/9] qom: QUALIFIED_CAST helper macro Eduardo Habkost
2017-03-29 19:41 ` [Qemu-devel] [RFC v2 4/9] qom: Make object_class_get_parent() const-aware Eduardo Habkost
2017-03-29 19:41 ` [Qemu-devel] [RFC v2 5/9] Make class parameter const at some functions Eduardo Habkost
2017-03-29 19:41 ` Eduardo Habkost [this message]
2017-03-29 19:41 ` [Qemu-devel] [RFC v2 7/9] Use const variables for *_GET_CLASS values Eduardo Habkost
2017-03-29 19:41 ` [Qemu-devel] [RFC v2 8/9] qom: Make class cast macros/functions const-aware Eduardo Habkost
2017-03-29 19:41 ` [Qemu-devel] [RFC v2 9/9] qom: Make object_get_class() return const pointer Eduardo Habkost
2017-03-29 19:56 ` [Qemu-devel] [RFC v2 0/9] qom: Make object_get_class()/*_GET_CLASS return const pointers Laszlo Ersek
2017-03-29 20:11 ` Eduardo Habkost
2017-03-29 20:16 ` Eduardo Habkost
2017-03-30 8:59 ` Paolo Bonzini
2017-03-30 13:32 ` Eduardo Habkost
2017-04-02 13:31 ` Eduardo Habkost
2017-04-03 9:44 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170329194148.19015-7-ehabkost@redhat.com \
--to=ehabkost@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).