Thank you for your contribution! Sashiko AI review found 1 potential issue(s) 
to consider:
- [Low] Missing default generic parameter `SIZE = 0` on the `DevresBar` type 
alias.
--

commit 017789d5b34f5d46a0492fb61faa312b02cc8a26
Author: Danilo Krummrich <[email protected]>
rust: pci: return DevresLt from Bar::into_devres()

This commit updates Bar::into_devres() to return DevresLt, which can shorten
the stored static lifetime back to the caller's borrow lifetime. It implements
CovariantForLt and ForLt for Bar and adds a DevresBar type alias.

> diff --git a/rust/kernel/pci/io.rs b/rust/kernel/pci/io.rs
> index 0461e01aaa20e..7a0d2d74129d1 100644
> --- a/rust/kernel/pci/io.rs
> +++ b/rust/kernel/pci/io.rs
[ ... ]
> @@ -151,6 +155,19 @@ pub struct Bar<'a, const SIZE: usize = 0> {
>      num: i32,
>  }
>  
> +impl<const SIZE: usize> ForLt for Bar<'static, SIZE> {
> +    type Of<'a> = Bar<'a, SIZE>;
> +}
> +
> +// SAFETY: `Bar<'a, SIZE>` is covariant over `'a`; it holds `&'a 
> Device<Bound>`,
> +// which is covariant.
> +unsafe impl<const SIZE: usize> CovariantForLt for Bar<'static, SIZE> {}
> +
> +/// A device-managed PCI BAR mapping.
> +///
> +/// See [`Bar::into_devres`].
> +pub type DevresBar<const SIZE: usize> = DevresLt<Bar<'static, SIZE>>;

[Severity: Low]
This isn't a bug, but should DevresBar provide a default size parameter to
match the underlying Bar struct?

The Bar struct defines its size parameter with a default of 0 as seen in the
context above, but the new DevresBar alias omits this default. This omission
requires callers to explicitly specify the size when using the alias, which
creates a slight inconsistency in API ergonomics between the base type and its
device-managed counterpart.

Would it make sense to define it as:
pub type DevresBar<const SIZE: usize = 0> = DevresLt<Bar<'static, SIZE>>; ?

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=6

Reply via email to