From: Richard Henderson <richard.henderson@linaro.org>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>, qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH v3 18/19] hw: Constify various TypeInfo and associated structures
Date: Wed, 12 Feb 2025 14:10:14 -0800 [thread overview]
Message-ID: <09a344ad-76b1-40ba-9231-6fb5d9236028@linaro.org> (raw)
In-Reply-To: <20250212213249.45574-19-philmd@linaro.org>
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.henderson@linaro.org>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@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~
next prev parent reply other threads:[~2025-02-12 22:10 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-12 21:32 [PATCH v3 00/19] qom: Constify class_data Philippe Mathieu-Daudé
2025-02-12 21:32 ` [PATCH v3 01/19] hw: Declare various const data as 'const' Philippe Mathieu-Daudé
2025-02-12 21:32 ` [PATCH v3 02/19] hw: Make class data 'const' Philippe Mathieu-Daudé
2025-02-12 21:32 ` [PATCH v3 03/19] target/i386: Constify X86CPUModel uses Philippe Mathieu-Daudé
2025-02-12 21:32 ` [PATCH v3 04/19] target/sparc: Constify SPARCCPUClass::cpu_def Philippe Mathieu-Daudé
2025-02-12 21:32 ` [PATCH v3 05/19] target/xtensa: Finalize config in xtensa_register_core() Philippe Mathieu-Daudé
2025-02-12 21:32 ` [PATCH v3 06/19] target/riscv: Declare RISCVCPUClass::misa_mxl_max as RISCVMXL Philippe Mathieu-Daudé
2025-02-17 5:08 ` Alistair Francis
2025-02-12 21:32 ` [PATCH v3 07/19] target/riscv: Convert misa_mxl_max using GLib macros Philippe Mathieu-Daudé
2025-02-17 5:13 ` Alistair Francis
2025-02-12 21:32 ` [PATCH v3 08/19] qom: Have class_base_init() take a const data argument Philippe Mathieu-Daudé
2025-02-12 21:32 ` [PATCH v3 09/19] qom: Have class_init() " Philippe Mathieu-Daudé
2025-02-12 21:32 ` [PATCH v3 10/19] qom: Constify TypeInfo::class_data Philippe Mathieu-Daudé
2025-02-12 21:32 ` [PATCH v3 11/19] qom: Constify InterfaceInfo[] interfaces Philippe Mathieu-Daudé
2025-02-12 21:32 ` [PATCH v3 12/19] hw/virtio/virtio-pci: Always allocate QOM type base_name Philippe Mathieu-Daudé
2025-02-12 22:06 ` Richard Henderson
2025-02-12 21:32 ` [PATCH v3 13/19] hw/virtio/virtio-pci: Assert before registering QOM types Philippe Mathieu-Daudé
2025-02-12 21:32 ` [PATCH v3 14/19] hw/virtio/virtio-pci: Do not access base_type_info.name directly Philippe Mathieu-Daudé
2025-02-12 21:32 ` [PATCH v3 15/19] hw/virtio/virtio-pci: Constify base_type_info Philippe Mathieu-Daudé
2025-02-12 21:32 ` [PATCH v3 16/19] hw/virtio/virtio-pci: Constify generic_type_info Philippe Mathieu-Daudé
2025-02-12 21:32 ` [PATCH v3 17/19] hw/virtio/virtio-pci: Reduce generic_type_info scope Philippe Mathieu-Daudé
2025-02-12 21:32 ` [PATCH v3 18/19] hw: Constify various TypeInfo and associated structures Philippe Mathieu-Daudé
2025-02-12 22:10 ` Richard Henderson [this message]
2025-02-12 21:32 ` [PATCH v3 19/19] qom: Require TypeInfo::class_data points to const data Philippe Mathieu-Daudé
2025-02-12 22:11 ` Richard Henderson
2025-02-18 16:51 ` 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=09a344ad-76b1-40ba-9231-6fb5d9236028@linaro.org \
--to=richard.henderson@linaro.org \
--cc=pbonzini@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@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 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).