* [PATCH 0/4] hw/qdev-properties: Constify Property* in DeviceClass
@ 2023-02-03 10:12 Philippe Mathieu-Daudé
2023-02-03 10:12 ` [PATCH 1/4] hw/qdev-properties: Constify Property* in object_field_prop_ptr() Philippe Mathieu-Daudé
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-02-03 10:12 UTC (permalink / raw)
To: qemu-devel
Cc: Paolo Bonzini, Eduardo Habkost, qemu-trivial,
Daniel P. Berrangé, 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* 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(-)
--
2.38.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/4] hw/qdev-properties: Constify Property* in object_field_prop_ptr()
2023-02-03 10:12 [PATCH 0/4] hw/qdev-properties: Constify Property* in DeviceClass Philippe Mathieu-Daudé
@ 2023-02-03 10:12 ` Philippe Mathieu-Daudé
2023-02-03 10:12 ` [PATCH 2/4] hw/qdev-properties: Constify Property* in PropertyInfo::print() handler Philippe Mathieu-Daudé
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-02-03 10:12 UTC (permalink / raw)
To: qemu-devel
Cc: Paolo Bonzini, Eduardo Habkost, qemu-trivial,
Daniel P. Berrangé, Philippe Mathieu-Daudé
The pointed Property structure is accessed read-only.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/core/qdev-properties.c | 2 +-
include/hw/qdev-properties.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index 357b8761b5..858c33830c 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -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;
diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h
index e1df08876c..b5a0ab34f3 100644
--- a/include/hw/qdev-properties.h
+++ b/include/hw/qdev-properties.h
@@ -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,
--
2.38.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/4] hw/qdev-properties: Constify Property* in PropertyInfo::print() handler
2023-02-03 10:12 [PATCH 0/4] hw/qdev-properties: Constify Property* in DeviceClass Philippe Mathieu-Daudé
2023-02-03 10:12 ` [PATCH 1/4] hw/qdev-properties: Constify Property* in object_field_prop_ptr() Philippe Mathieu-Daudé
@ 2023-02-03 10:12 ` Philippe Mathieu-Daudé
2023-02-03 10:12 ` [PATCH 3/4] hw/qdev-properties: Constify Property* in PropertyInfo::create() handler Philippe Mathieu-Daudé
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-02-03 10:12 UTC (permalink / raw)
To: qemu-devel
Cc: Paolo Bonzini, Eduardo Habkost, qemu-trivial,
Daniel P. Berrangé, Philippe Mathieu-Daudé
The pointed Property structure is accessed read-only.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/core/qdev-properties-system.c | 2 +-
include/hw/qdev-properties.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
index d42493f630..a982de1354 100644
--- a/hw/core/qdev-properties-system.c
+++ b/hw/core/qdev-properties-system.c
@@ -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);
diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h
index b5a0ab34f3..39959c3432 100644
--- a/include/hw/qdev-properties.h
+++ b/include/hw/qdev-properties.h
@@ -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);
--
2.38.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/4] hw/qdev-properties: Constify Property* in PropertyInfo::create() handler
2023-02-03 10:12 [PATCH 0/4] hw/qdev-properties: Constify Property* in DeviceClass Philippe Mathieu-Daudé
2023-02-03 10:12 ` [PATCH 1/4] hw/qdev-properties: Constify Property* in object_field_prop_ptr() Philippe Mathieu-Daudé
2023-02-03 10:12 ` [PATCH 2/4] hw/qdev-properties: Constify Property* in PropertyInfo::print() handler Philippe Mathieu-Daudé
@ 2023-02-03 10:12 ` Philippe Mathieu-Daudé
2023-02-03 10:12 ` [PATCH 4/4] hw/qdev-properties: Constify DeviceClass::props_ field Philippe Mathieu-Daudé
2023-02-23 13:00 ` [PATCH 0/4] hw/qdev-properties: Constify Property* in DeviceClass Philippe Mathieu-Daudé
4 siblings, 0 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-02-03 10:12 UTC (permalink / raw)
To: qemu-devel
Cc: Paolo Bonzini, Eduardo Habkost, qemu-trivial,
Daniel P. Berrangé, Philippe Mathieu-Daudé
The pointed Property structure is accessed read-only.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/core/qdev-properties.c | 2 +-
include/hw/qdev-properties.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index 858c33830c..baf9a91b29 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -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,
diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h
index 39959c3432..21f399e9a3 100644
--- a/include/hw/qdev-properties.h
+++ b/include/hw/qdev-properties.h
@@ -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;
--
2.38.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 4/4] hw/qdev-properties: Constify DeviceClass::props_ field
2023-02-03 10:12 [PATCH 0/4] hw/qdev-properties: Constify Property* in DeviceClass Philippe Mathieu-Daudé
` (2 preceding siblings ...)
2023-02-03 10:12 ` [PATCH 3/4] hw/qdev-properties: Constify Property* in PropertyInfo::create() handler Philippe Mathieu-Daudé
@ 2023-02-03 10:12 ` Philippe Mathieu-Daudé
2023-02-23 13:00 ` [PATCH 0/4] hw/qdev-properties: Constify Property* in DeviceClass Philippe Mathieu-Daudé
4 siblings, 0 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-02-03 10:12 UTC (permalink / raw)
To: qemu-devel
Cc: Paolo Bonzini, Eduardo Habkost, qemu-trivial,
Daniel P. Berrangé, Philippe Mathieu-Daudé
The pointed Property structure is accessed read-only.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/core/qdev-properties.c | 10 +++++-----
include/hw/qdev-core.h | 2 +-
softmmu/qdev-monitor.c | 4 ++--
3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index baf9a91b29..9789a2f5de 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -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 {
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index 35fddb19a6..fd11e9a82f 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -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?
diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c
index 4b0ef65780..f47de51f95 100644
--- a/softmmu/qdev-monitor.c
+++ b/softmmu/qdev-monitor.c
@@ -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;
--
2.38.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 0/4] hw/qdev-properties: Constify Property* in DeviceClass
2023-02-03 10:12 [PATCH 0/4] hw/qdev-properties: Constify Property* in DeviceClass Philippe Mathieu-Daudé
` (3 preceding siblings ...)
2023-02-03 10:12 ` [PATCH 4/4] hw/qdev-properties: Constify DeviceClass::props_ field Philippe Mathieu-Daudé
@ 2023-02-23 13:00 ` Philippe Mathieu-Daudé
4 siblings, 0 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-02-23 13:00 UTC (permalink / raw)
To: qemu-devel
Cc: Paolo Bonzini, Eduardo Habkost, qemu-trivial,
Daniel P. Berrangé
On 3/2/23 11:12, Philippe Mathieu-Daudé wrote:
> 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
Ping (trivial).
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-02-23 13:02 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-03 10:12 [PATCH 0/4] hw/qdev-properties: Constify Property* in DeviceClass Philippe Mathieu-Daudé
2023-02-03 10:12 ` [PATCH 1/4] hw/qdev-properties: Constify Property* in object_field_prop_ptr() Philippe Mathieu-Daudé
2023-02-03 10:12 ` [PATCH 2/4] hw/qdev-properties: Constify Property* in PropertyInfo::print() handler Philippe Mathieu-Daudé
2023-02-03 10:12 ` [PATCH 3/4] hw/qdev-properties: Constify Property* in PropertyInfo::create() handler Philippe Mathieu-Daudé
2023-02-03 10:12 ` [PATCH 4/4] hw/qdev-properties: Constify DeviceClass::props_ field Philippe Mathieu-Daudé
2023-02-23 13:00 ` [PATCH 0/4] hw/qdev-properties: Constify Property* in DeviceClass Philippe Mathieu-Daudé
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).