qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 09/10] machine: Ensure all TYPE_MACHINE subclass


From: Marcel Apfelbaum
Subject: Re: [Qemu-devel] [PATCH 09/10] machine: Ensure all TYPE_MACHINE subclasses have the right suffix
Date: Tue, 25 Aug 2015 11:53:37 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0

On 08/21/2015 12:54 AM, Eduardo Habkost wrote:
Now that all non-abstract TYPE_MACHINE subclasses have the -machine
suffix, add an assert to ensure this will be always true.

Signed-off-by: Eduardo Habkost <address@hidden>
---
  hw/core/machine.c | 9 +++++++++
  1 file changed, 9 insertions(+)

diff --git a/hw/core/machine.c b/hw/core/machine.c
index ac4654e..e50c4b7 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -302,6 +302,14 @@ static void machine_class_init(ObjectClass *oc, void *data)
      mc->default_ram_size = 128 * M_BYTE;
  }

+static void machine_class_base_init(ObjectClass *oc, void *data)
+{
+    if (!object_class_is_abstract(oc)) {
+        const char *cname = object_class_get_name(oc);
+        assert(g_str_has_suffix(cname, TYPE_MACHINE_SUFFIX));
+    }
+}
+
  static void machine_initfn(Object *obj)
  {
      MachineState *ms = MACHINE(obj);
@@ -472,6 +480,7 @@ static const TypeInfo machine_info = {
      .abstract = true,
      .class_size = sizeof(MachineClass),
      .class_init    = machine_class_init,
+    .class_base_init = machine_class_base_init,
      .instance_size = sizeof(MachineState),
      .instance_init = machine_initfn,
      .instance_finalize = machine_finalize,


Reviewed-by: Marcel Apfelbaum <address@hidden>

Thanks,
Marcel



reply via email to

[Prev in Thread] Current Thread [Next in Thread]