[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 03/10] rust/irq: Add a helper to convert [InterruptSource] to
From: |
Paolo Bonzini |
Subject: |
Re: [PATCH 03/10] rust/irq: Add a helper to convert [InterruptSource] to [*mut IRQState] |
Date: |
Wed, 29 Jan 2025 11:51:02 +0100 |
User-agent: |
Mozilla Thunderbird |
On Sat, Jan 25, 2025 at 1:32 PM Zhao Liu <zhao1.liu@intel.com> wrote:
This is useful to hanlde InterruptSource slice and pass it to C
bindings.
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
This may be a bad suggestion, after all. clippy complains that you're
casting &[*mut IRQState] to mutable (https://rust-lang.github.io/rust-
clippy/master/#as_ptr_cast_mut).
I can think of two solutions:
1) add #[allow(clippy::as_ptr_cast_mut)] and explain with a comment
// Casting to *mut *mut IRQState is valid, because
// the source slice `pins` uses interior mutability.
2) drop as_slice_of_qemu_irq() and replace it with something like
pub(crate) const fn slice_as_ptr(slice: &[Self]) -> *mut *mut IRQState {
slice[0].as_ptr()
}
You choose.
Paolo
- [PATCH 00/10] rust: Add HPET timer device, Zhao Liu, 2025/01/25
- [PATCH 02/10] rust/qdev: add the macro to define bit property, Zhao Liu, 2025/01/25
- [PATCH 03/10] rust/irq: Add a helper to convert [InterruptSource] to [*mut IRQState], Zhao Liu, 2025/01/25
- Re: [PATCH 03/10] rust/irq: Add a helper to convert [InterruptSource] to [*mut IRQState],
Paolo Bonzini <=
- [PATCH 04/10] rust: add bindings for gpio_{in|out} initialization, Zhao Liu, 2025/01/25
- [PATCH 05/10] rust: add bindings for memattrs, Zhao Liu, 2025/01/25
- [PATCH 01/10] i386/fw_cfg: move hpet_cfg definition to hpet.c, Zhao Liu, 2025/01/25
- [PATCH 06/10] rust: add bindings for timer, Zhao Liu, 2025/01/25
- [PATCH 07/10] rust/timer/hpet: define hpet_cfg, Zhao Liu, 2025/01/25
- [PATCH 08/10] rust/timer/hpet: add basic HPET timer and HPETState, Zhao Liu, 2025/01/25