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!