hw/qdev-properties: Constify Property* in DeviceClass
cover hw/qdev-properties: Constify Property* in DeviceClass
Qualify some Property pointers as 'const' when the structure is accessed read-only.
Philippe Mathieu-Daudé (4):
hw/qdev-properties: Constify Property* in object_field_prop_ptr() hw/qdev-properties: Constify Property* in PropertyInfo::print()
handler
hw/qdev-properties: Constify Property* in PropertyInfo::create()
handler
hw/qdev-properties: Constify DeviceClass::props_ field
hw/core/qdev-properties-system.c | 2 +- hw/core/qdev-properties.c | 14 +++++++------- include/hw/qdev-core.h | 2 +- include/hw/qdev-properties.h | 6 +++--- softmmu/qdev-monitor.c | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-)
Signature · 1 line
2.38.1
PATCH 1/4 hw/qdev-properties: Constify Property* in object_field_prop_ptr()
The pointed Property structure is accessed read-only.
--- hw/core/qdev-properties.c | 2 +- include/hw/qdev-properties.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
hw/core/qdev-properties.c +1 -1
@@ -50,7 +50,7 @@ void qdev_prop_allow_set_link_before_realize(const Object *obj, } } -void *object_field_prop_ptr (Object *obj,Property *prop) +void *object_field_prop_ptr (Object *obj,const Property *prop) {void *ptr = obj; ptr += prop->offset;
include/hw/qdev-properties.h +1 -1
@@ -206,7 +206,7 @@ void qdev_prop_set_macaddr(DeviceState *dev, const char *name, const uint8_t *value);void qdev_prop_set_enum (DeviceState *dev,const char *name,int value); -void *object_field_prop_ptr (Object *obj,Property *prop); +void *object_field_prop_ptr (Object *obj,const Property *prop);void qdev_prop_register_global (GlobalProperty *prop); const GlobalProperty *qdev_find_global_prop(Object *obj,
Signature · 1 line
2.38.1
PATCH 2/4 hw/qdev-properties: Constify Property* in PropertyInfo::print() handler
In reply to Philippe Mathieu-DaudéThe pointed Property structure is accessed read-only.
--- hw/core/qdev-properties-system.c | 2 +- include/hw/qdev-properties.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
hw/core/qdev-properties-system.c +1 -1
@@ -799,7 +799,7 @@ invalid:g_free (str); } -static int print_pci_devfn (Object *obj,Property *prop,char *dest, +static int print_pci_devfn (Object *obj,const Property *prop,char *dest,size_t len) {int32_t *ptr =object_field_prop_ptr (obj, prop);
include/hw/qdev-properties.h +1 -1
@@ -34,7 +34,7 @@ struct PropertyInfo {const char *description;const QEnumLookup *enum_table;bool realized_set_allowed;/* allow setting property on realized device */ -int (*print)(Object *obj,Property *prop,char *dest,size_t len); +int (*print)(Object *obj,const Property *prop,char *dest,size_t len);void (*set_default_value)(ObjectProperty *op,const Property *prop);ObjectProperty *(*create)(ObjectClass *oc,const char *name,Property *prop);
Signature · 1 line
2.38.1
PATCH 3/4 hw/qdev-properties: Constify Property* in PropertyInfo::create() handler
In reply to Philippe Mathieu-DaudéThe pointed Property structure is accessed read-only.
--- hw/core/qdev-properties.c | 2 +- include/hw/qdev-properties.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
hw/core/qdev-properties.c +1 -1
@@ -840,7 +840,7 @@ const PropertyInfo qdev_prop_size = {/* --- object link property --- */ static ObjectProperty *create_link_property (ObjectClass *oc,const char *name, -Property *prop) +const Property *prop) { return object_class_property_add_link(oc, name, prop->link_type, prop->offset,
include/hw/qdev-properties.h +1 -1
@@ -37,7 +37,7 @@ struct PropertyInfo {int (*print)(Object *obj,const Property *prop,char *dest,size_t len);void (*set_default_value)(ObjectProperty *op,const Property *prop);ObjectProperty *(*create)(ObjectClass *oc,const char *name, -Property *prop); +const Property *prop);ObjectPropertyAccessor *get;ObjectPropertyAccessor *set;ObjectPropertyRelease *release;
Signature · 1 line
2.38.1
PATCH 4/4 hw/qdev-properties: Constify DeviceClass::props_ field
In reply to Philippe Mathieu-DaudéThe pointed Property structure is accessed read-only.
--- hw/core/qdev-properties.c | 10 +++++----- include/hw/qdev-core.h | 2 +- softmmu/qdev-monitor.c | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-)
hw/core/qdev-properties.c +5 -5
@@ -640,7 +640,7 @@ const PropertyInfo qdev_prop_arraylen = {/* --- public helpers --- */ -static Property *qdev_prop_walk (Property *props,const char *name) +static const Property *qdev_prop_walk (const Property *props,const char *name) {if (!props) {return NULL ;
@@ -654,10 +654,10 @@ static Property *qdev_prop_walk(Property *props, const char *name)return NULL ; } -static Property *qdev_prop_find (DeviceState *dev,const char *name) +static const Property *qdev_prop_find (DeviceState *dev,const char *name) {ObjectClass *class; -Property *prop; +const Property *prop;/* device properties */ class =object_get_class (OBJECT (dev));
@@ -731,7 +731,7 @@ void qdev_prop_set_string(DeviceState *dev, const char *name, const char *value)void qdev_prop_set_enum (DeviceState *dev,const char *name,int value) { -Property *prop; +const Property *prop; prop =qdev_prop_find (dev, name); object_property_set_str(OBJECT(dev), name,
@@ -959,7 +959,7 @@ void device_class_set_props(DeviceClass *dc, Property *props)void qdev_alias_all_properties (DeviceState *target,Object *source) {ObjectClass *class; -Property *prop; +const Property *prop; class =object_get_class (OBJECT (target)); do {
include/hw/qdev-core.h +1 -1
@@ -108,7 +108,7 @@ struct DeviceClass {* 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_; +const Property *props_;/* * Can this device be instantiated with -device / device_add?
softmmu/qdev-monitor.c +2 -2
@@ -741,8 +741,8 @@ DeviceState *qdev_device_add(QemuOpts *opts, Error **errp)#define qdev_printf (fmt, ...) monitor_printf(mon, "%*s" fmt, indent, "", ## __VA_ARGS__)static void qbus_print (Monitor *mon,BusState *bus,int indent); -static void qdev_print_props (Monitor *mon,DeviceState *dev,Property *props, -int indent) +static void qdev_print_props (Monitor *mon,DeviceState *dev, +const Property *props,int indent) {if (!props)return ;
Signature · 1 line
2.38.1
Quoted 10 lines · Philippe Mathieu-Daudé
Qualify some Property pointers as 'const' when the structure is accessed read-only.
Philippe Mathieu-Daudé (4):
hw/qdev-properties: Constify Property* inobject_field_prop_ptr()hw/qdev-properties: Constify Property* inPropertyInfo::print()
handler
hw/qdev-properties: Constify Property* inPropertyInfo::create()
handler
hw/qdev-properties: ConstifyDeviceClass::props_field
Ping (trivial).