diff options
author | Zhao Liu <zhao1.liu@intel.com> | 2025-01-21 22:04:56 +0800 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2025-01-23 11:50:53 +0100 |
commit | 0f9eb0ff2b25787be62fceb036dba7c3f54fde2d (patch) | |
tree | 525a888f4c0da48be31d36f8a5e9778da13583c3 /rust/qemu-api | |
parent | 8113dbbcdaee05f319a7e48272416d918cb2b04a (diff) | |
download | qemu-0f9eb0ff2b25787be62fceb036dba7c3f54fde2d.zip qemu-0f9eb0ff2b25787be62fceb036dba7c3f54fde2d.tar.gz qemu-0f9eb0ff2b25787be62fceb036dba7c3f54fde2d.tar.bz2 |
rust/qdev: Make REALIZE safe
A safe REALIZE accepts immutable reference.
Since current PL011's realize() only calls a char binding function (
qemu_chr_fe_set_handlers), it is possible to convert mutable reference
(&mut self) to immutable reference (&self), which only needs to convert
the pointers passed to C to mutable pointers.
Thus, make REALIZE accept immutable reference.
Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
Link: https://lore.kernel.org/r/20250121140457.84631-2-zhao1.liu@intel.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'rust/qemu-api')
-rw-r--r-- | rust/qemu-api/src/qdev.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/rust/qemu-api/src/qdev.rs b/rust/qemu-api/src/qdev.rs index 686054e..a5121e3 100644 --- a/rust/qemu-api/src/qdev.rs +++ b/rust/qemu-api/src/qdev.rs @@ -23,7 +23,7 @@ pub trait DeviceImpl { /// /// If not `None`, the parent class's `realize` method is overridden /// with the function pointed to by `REALIZE`. - const REALIZE: Option<fn(&mut Self)> = None; + const REALIZE: Option<fn(&Self)> = None; /// If not `None`, the parent class's `reset` method is overridden /// with the function pointed to by `RESET`. |