qemu-devel
[Top][All Lists]
Advanced

[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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]