Skip to content

Commit

Permalink
machine: Ensure all TYPE_MACHINE subclasses have the right suffix
Browse files Browse the repository at this point in the history
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 <ehabkost@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
  • Loading branch information
ehabkost authored and afaerber committed Sep 19, 2015
1 parent c0f3651 commit dcb3d60
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions hw/core/machine.c
Expand Up @@ -316,6 +316,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);
Expand Down Expand Up @@ -492,6 +500,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,
Expand Down

0 comments on commit dcb3d60

Please sign in to comment.