Skip to content

Commit

Permalink
qdev: rename DeviceClass.props
Browse files Browse the repository at this point in the history
Ensure that conflicts in the future will cause a syntax error.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
bonzini committed Jan 24, 2020
1 parent 4f67d30 commit 385d8f2
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion hw/core/qdev-properties.c
Expand Up @@ -1071,7 +1071,7 @@ static Property *qdev_prop_find(DeviceState *dev, const char *name)
/* device properties */
class = object_get_class(OBJECT(dev));
do {
prop = qdev_prop_walk(DEVICE_CLASS(class)->props, name);
prop = qdev_prop_walk(DEVICE_CLASS(class)->props_, name);
if (prop) {
return prop;
}
Expand Down
8 changes: 4 additions & 4 deletions hw/core/qdev.c
Expand Up @@ -751,7 +751,7 @@ void qdev_alias_all_properties(DeviceState *target, Object *source)
do {
DeviceClass *dc = DEVICE_CLASS(class);

for (prop = dc->props; prop && prop->name; prop++) {
for (prop = dc->props_; prop && prop->name; prop++) {
object_property_add_alias(source, prop->name,
OBJECT(target), prop->name,
&error_abort);
Expand Down Expand Up @@ -954,7 +954,7 @@ static void device_initfn(Object *obj)

class = object_get_class(OBJECT(dev));
do {
for (prop = DEVICE_CLASS(class)->props; prop && prop->name; prop++) {
for (prop = DEVICE_CLASS(class)->props_; prop && prop->name; prop++) {
qdev_property_add_legacy(dev, prop, &error_abort);
qdev_property_add_static(dev, prop);
}
Expand Down Expand Up @@ -1013,7 +1013,7 @@ static void device_class_base_init(ObjectClass *class, void *data)
/* We explicitly look up properties in the superclasses,
* so do not propagate them to the subclasses.
*/
klass->props = NULL;
klass->props_ = NULL;
}

static void device_unparent(Object *obj)
Expand Down Expand Up @@ -1063,7 +1063,7 @@ static void device_class_init(ObjectClass *class, void *data)

void device_class_set_props(DeviceClass *dc, Property *props)
{
dc->props = props;
dc->props_ = props;
}

void device_class_set_parent_reset(DeviceClass *dc,
Expand Down
7 changes: 6 additions & 1 deletion include/hw/qdev-core.h
Expand Up @@ -100,7 +100,12 @@ typedef struct DeviceClass {
DECLARE_BITMAP(categories, DEVICE_CATEGORY_MAX);
const char *fw_name;
const char *desc;
Property *props;

/*
* The underscore at the end ensures a compile-time error if someone
* assigns to dc->props instead of using device_class_set_props.
*/
Property *props_;

/*
* Can this device be instantiated with -device / device_add?
Expand Down
2 changes: 1 addition & 1 deletion qdev-monitor.c
Expand Up @@ -748,7 +748,7 @@ static void qdev_print(Monitor *mon, DeviceState *dev, int indent)
}
class = object_get_class(OBJECT(dev));
do {
qdev_print_props(mon, dev, DEVICE_CLASS(class)->props, indent);
qdev_print_props(mon, dev, DEVICE_CLASS(class)->props_, indent);
class = object_class_get_parent(class);
} while (class != object_class_by_name(TYPE_DEVICE));
bus_print_dev(dev->parent_bus, mon, dev, indent);
Expand Down
2 changes: 1 addition & 1 deletion qom/qom-qmp-cmds.c
Expand Up @@ -137,7 +137,7 @@ static ObjectPropertyInfo *make_device_property_info(ObjectClass *klass,
Property *prop;

do {
for (prop = DEVICE_CLASS(klass)->props; prop && prop->name; prop++) {
for (prop = DEVICE_CLASS(klass)->props_; prop && prop->name; prop++) {
if (strcmp(name, prop->name) != 0) {
continue;
}
Expand Down

0 comments on commit 385d8f2

Please sign in to comment.