qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Paolo Bonzini <pbonzini@redhat.com>, qemu-devel@nongnu.org
Cc: Richard Henderson <richard.henderson@linaro.org>
Subject: Re: [PATCH 00/10] qom: Constify class_data
Date: Mon, 10 Feb 2025 14:29:07 +0100	[thread overview]
Message-ID: <f82d5a10-6cf3-4d46-8699-e3bb8f552e6e@linaro.org> (raw)
In-Reply-To: <ef7d98d4-c0e7-4bb3-bf8c-e36c5cfe2e05@redhat.com>

On 10/2/25 13:30, Paolo Bonzini wrote:
> On 2/10/25 11:25, Philippe Mathieu-Daudé wrote:
>> Following Richard's suggestion [*], make QOM class data *const*.
>>
>> Note, rust code not modified...
> 
> Untested but it should be something like
> 
> diff --git a/rust/qemu-api/src/qom.rs b/rust/qemu-api/src/qom.rs
> index f36be2831eb..8603f7cc657 100644
> --- a/rust/qemu-api/src/qom.rs
> +++ b/rust/qemu-api/src/qom.rs
> @@ -180,7 +180,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> 
> Result<(), fmt::Error> {
> 
>   unsafe extern "C" fn rust_class_init<T: ObjectType + 
> ClassInitImpl<T::Class>>(
>       klass: *mut ObjectClass,
> -    _data: *mut c_void,
> +    _data: *const c_void,
>   ) {
>       let mut klass = NonNull::new(klass)
>           .unwrap()
> @@ -523,7 +523,7 @@ pub trait ObjectImpl: ObjectType + 
> ClassInitImpl<Self::Class> {
>       /// the effects of copying the contents of the parent's class struct
>       /// to the descendants.
>       const CLASS_BASE_INIT: Option<
> -        unsafe extern "C" fn(klass: *mut ObjectClass, data: *mut c_void),
> +        unsafe extern "C" fn(klass: *mut ObjectClass, data: *const 
> c_void),
>       > = None;
> 
>       const TYPE_INFO: TypeInfo = TypeInfo {
> @@ -544,7 +544,7 @@ pub trait ObjectImpl: ObjectType + 
> ClassInitImpl<Self::Class> {
>           class_size: core::mem::size_of::<Self::Class>(),
>           class_init: Some(rust_class_init::<Self>),
>           class_base_init: Self::CLASS_BASE_INIT,
> -        class_data: core::ptr::null_mut(),
> +        class_data: core::ptr::null(),
>           interfaces: core::ptr::null_mut(),
>       };
> 
> 
> to be split across patches 8-10.

Thanks!



      reply	other threads:[~2025-02-10 13:29 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-10 10:25 [PATCH 00/10] qom: Constify class_data Philippe Mathieu-Daudé
2025-02-10 10:25 ` [PATCH 01/10] target/i386: Constify X86CPUModel uses Philippe Mathieu-Daudé
2025-02-10 10:25 ` [PATCH 02/10] target/sparc: Constify SPARCCPUClass::cpu_def Philippe Mathieu-Daudé
2025-02-10 10:25 ` [PATCH 03/10] target/xtensa: Finalize config in xtensa_register_core() Philippe Mathieu-Daudé
2025-02-10 11:02   ` Max Filippov
2025-02-10 16:25   ` Richard Henderson
2025-02-10 10:25 ` [PATCH 04/10] target/riscv: Declare RISCVCPUClass::misa_mxl_max as RISCVMXL Philippe Mathieu-Daudé
2025-02-10 10:25 ` [PATCH 05/10] target/riscv: Convert misa_mxl_max using GLib macros Philippe Mathieu-Daudé
2025-02-10 10:26 ` [PATCH 06/10] hw: Declare various const data as 'const' Philippe Mathieu-Daudé
2025-02-10 10:26 ` [PATCH 07/10] hw: Make class data 'const' Philippe Mathieu-Daudé
2025-02-10 10:26 ` [PATCH 08/10] qom: Have class_base_init() take a const data argument Philippe Mathieu-Daudé
2025-02-10 10:26 ` [PATCH 09/10] qom: Have class_init() " Philippe Mathieu-Daudé
2025-02-10 10:26 ` [PATCH 10/10] qom: Constify class_data Philippe Mathieu-Daudé
2025-02-10 12:30 ` [PATCH 00/10] " Paolo Bonzini
2025-02-10 13:29   ` Philippe Mathieu-Daudé [this message]

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=f82d5a10-6cf3-4d46-8699-e3bb8f552e6e@linaro.org \
    --to=philmd@linaro.org \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.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).