]> git.ipfire.org Git - thirdparty/qemu.git/commit
rust: prefer NonNull::new to assertions
authorPaolo Bonzini <pbonzini@redhat.com>
Thu, 23 Jan 2025 10:25:22 +0000 (11:25 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 23 Jan 2025 17:47:46 +0000 (18:47 +0100)
commit7d0520398f7f58214cf5242b34c1b46efa2fcf4f
tree1aa706baadc819ff3f569af00c91ba99fe4696fd
parent24f0e8d818b931758b6dc47f973a6b1b80ecee1f
rust: prefer NonNull::new to assertions

Do not use new_unchecked; the effect is the same, but the
code is easier to read and unsafe regions become smaller.
Likewise, NonNull::new can be used instead of assertion and
followed by as_ref() or as_mut() instead of dereferencing the
pointer.

Suggested-by: Zhao Liu <zhao1.liu@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
rust/hw/char/pl011/src/device.rs
rust/hw/char/pl011/src/device_class.rs
rust/hw/char/pl011/src/memory_ops.rs
rust/qemu-api/src/qdev.rs
rust/qemu-api/src/qom.rs