[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 00/10] qom: Constify class_data
From: |
Paolo Bonzini |
Subject: |
Re: [PATCH 00/10] qom: Constify class_data |
Date: |
Mon, 10 Feb 2025 13:30:13 +0100 |
User-agent: |
Mozilla Thunderbird |
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.
Paolo
- [PATCH 03/10] target/xtensa: Finalize config in xtensa_register_core(), (continued)
- [PATCH 03/10] target/xtensa: Finalize config in xtensa_register_core(), Philippe Mathieu-Daudé, 2025/02/10
- [PATCH 04/10] target/riscv: Declare RISCVCPUClass::misa_mxl_max as RISCVMXL, Philippe Mathieu-Daudé, 2025/02/10
- [PATCH 05/10] target/riscv: Convert misa_mxl_max using GLib macros, Philippe Mathieu-Daudé, 2025/02/10
- [PATCH 06/10] hw: Declare various const data as 'const', Philippe Mathieu-Daudé, 2025/02/10
- [PATCH 07/10] hw: Make class data 'const', Philippe Mathieu-Daudé, 2025/02/10
- [PATCH 08/10] qom: Have class_base_init() take a const data argument, Philippe Mathieu-Daudé, 2025/02/10
- [PATCH 10/10] qom: Constify class_data, Philippe Mathieu-Daudé, 2025/02/10
- [PATCH 09/10] qom: Have class_init() take a const data argument, Philippe Mathieu-Daudé, 2025/02/10
- Re: [PATCH 00/10] qom: Constify class_data,
Paolo Bonzini <=