All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
	"Eduardo Habkost" <eduardo@habkost.net>,
	qemu-trivial@nongnu.org,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [PATCH 4/4] hw/qdev-properties: Constify DeviceClass::props_ field
Date: Fri,  3 Feb 2023 11:12:24 +0100	[thread overview]
Message-ID: <20230203101224.25796-5-philmd@linaro.org> (raw)
In-Reply-To: <20230203101224.25796-1-philmd@linaro.org>

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



  parent reply	other threads:[~2023-02-03 10:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Philippe Mathieu-Daudé [this message]
2023-02-23 13:00 ` [PATCH 0/4] hw/qdev-properties: Constify Property* in DeviceClass Philippe Mathieu-Daudé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230203101224.25796-5-philmd@linaro.org \
    --to=philmd@linaro.org \
    --cc=berrange@redhat.com \
    --cc=eduardo@habkost.net \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.