[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 10/15] rust: qom: wrap Object with Opaque<>
From: |
Zhao Liu |
Subject: |
Re: [PATCH 10/15] rust: qom: wrap Object with Opaque<> |
Date: |
Tue, 25 Feb 2025 16:47:35 +0800 |
> @@ -621,7 +629,7 @@ pub trait ObjectImpl: ObjectType + IsA<Object> {
> /// We expect the FFI user of this function to pass a valid pointer that
> /// can be downcasted to type `T`. We also expect the device is
> /// readable/writeable from one thread at any time.
> -unsafe extern "C" fn rust_unparent_fn<T: ObjectImpl>(dev: *mut Object) {
> +unsafe extern "C" fn rust_unparent_fn<T: ObjectImpl>(dev: *mut
> bindings::Object) {
> let state = NonNull::new(dev).unwrap().cast::<T>();
> T::UNPARENT.unwrap()(unsafe { state.as_ref() });
> }
> @@ -796,8 +804,9 @@ fn new() -> Owned<Self> {
> // SAFETY: the object created by object_new is allocated on
> // the heap and has a reference count of 1
> unsafe {
> - let obj = &*object_new(Self::TYPE_NAME.as_ptr());
> - Owned::from_raw(obj.unsafe_cast::<Self>())
> + let obj = object_new(Self::TYPE_NAME.as_ptr());
Having the same name is always not ideal, so let's name the first one raw_obj.
> + let obj = Object::from_raw(obj).unsafe_cast::<Self>();
> + Owned::from_raw(obj)
> }
> }
> }
Others look good to me,
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
>
- Re: [PATCH 08/15] rust: timer: wrap QEMUTimer with Opaque<>, (continued)
- [PATCH 10/15] rust: qom: wrap Object with Opaque<>, Paolo Bonzini, 2025/02/21
- Re: [PATCH 10/15] rust: qom: wrap Object with Opaque<>,
Zhao Liu <=
- [PATCH 12/15] rust: sysbus: wrap SysBusDevice with Opaque<>, Paolo Bonzini, 2025/02/21
- [PATCH 11/15] rust: qdev: wrap Clock and DeviceState with Opaque<>, Paolo Bonzini, 2025/02/21
- [PATCH 13/15] rust: memory: wrap MemoryRegion with Opaque<>, Paolo Bonzini, 2025/02/21
- [PATCH 14/15] rust: chardev: wrap Chardev with Opaque<>, Paolo Bonzini, 2025/02/21
- [PATCH 15/15] rust: bindings: remove more unnecessary Send/Sync impls, Paolo Bonzini, 2025/02/21