On 2/12/25 13:32, Philippe Mathieu-Daudé wrote:
Constify various TypeInfo structures.

When they are generated from an array, also constify the array.

Suggested-by: Richard Henderson <richard.hender...@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <phi...@linaro.org>
---
  hw/net/e1000.c             | 12 ++++++------
  hw/rtc/m48t59-isa.c        | 22 +++++++++++-----------
  hw/rtc/m48t59.c            | 22 +++++++++++-----------
  hw/scsi/megasas.c          | 16 ++++++++--------
  hw/usb/hcd-ehci-pci.c      | 20 ++++++++++----------
  hw/usb/hcd-uhci.c          | 20 ++++++++++----------
  hw/usb/vt82c686-uhci-pci.c |  6 +++---
  7 files changed, 59 insertions(+), 59 deletions(-)

diff --git a/hw/net/e1000.c b/hw/net/e1000.c
index cba4999e6d0..4436c2ce0cc 100644
--- a/hw/net/e1000.c
+++ b/hw/net/e1000.c
@@ -1766,12 +1766,12 @@ static void e1000_register_types(void)
      type_register_static(&e1000_base_info);
      for (i = 0; i < ARRAY_SIZE(e1000_devices); i++) {
          const E1000Info *info = &e1000_devices[i];
-        TypeInfo type_info = {};
-
-        type_info.name = info->name;
-        type_info.parent = TYPE_E1000_BASE;
-        type_info.class_data = info;
-        type_info.class_init = e1000_class_init;
+        const TypeInfo type_info = {
+            .name       = info->name,
+            .parent     = TYPE_E1000_BASE,
+            .class_data = info,
+            .class_init = e1000_class_init,
+        };
type_register_static(&type_info);
      }
diff --git a/hw/rtc/m48t59-isa.c b/hw/rtc/m48t59-isa.c
index 9e2f6563a0a..152208d931e 100644
--- a/hw/rtc/m48t59-isa.c
+++ b/hw/rtc/m48t59-isa.c
@@ -51,7 +51,7 @@ struct M48txxISADeviceClass {
      M48txxInfo info;
  };
-static M48txxInfo m48txx_isa_info[] = {
+static const M48txxInfo m48txx_isa_info[] = {

I wouldn't mix constifying TypeInfo with constifying class_data.


r~

Reply via email to