diff mbox series

[4/4] hw/qdev-properties: Constify DeviceClass::props_ field

Message ID 20230203101224.25796-5-philmd@linaro.org
State New
Headers show
Series hw/qdev-properties: Constify Property* in DeviceClass | expand

Commit Message

Philippe Mathieu-Daudé Feb. 3, 2023, 10:12 a.m. UTC
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 mbox series

Patch

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;