Re: [PATCH 5/6] gpu: nova-core: add NVKV typed decoding

"Eliot Courtney" <[email protected]>
Newsgroups org.kernel.vger.rust-for-linux,dev.linux.lists.nova-gpu,org.freedesktop.lists.dri-devel,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
On Thu Aug 20, 2026 at 3:59 AM JST, Danilo Krummrich wrote:
> On Mon Aug 17, 2026 at 2:56 PM CEST, Eliot Courtney wrote:
>> +/// A fixed capacity vector that holds at most `N` elements.
>> +#[derive(Debug, Copy, Clone, PartialEq, Eq, Zeroable)]
>> +pub(crate) struct ArrayVec<T, const N: usize> {
>> +    data: [T; N],
>
> This should be [MaybeUninit<T>; N].
>
>> +    len: usize,
>> +}
>
> Let's move this into the alloc module.
>
>> +impl<T: Default + Copy, const N: usize> Default for ArrayVec<T, N> {
>> +    fn default() -> Self {
>> +        Self {
>> +            data: [T::default(); N],
>> +            len: 0,
>> +        }
>> +    }
>> +}
>
> For anything that actually constructs an ArrayVec we should probably consider to
> restrict its size with a const_assert!()?
>
> For an initializer approach that'd be not an issue of course.
>
> 	fn init_with<E>(f: impl FnOnce(&mut Self) -> Result<(), E>) -> impl Init<Self, E>

Thanks, that all sounds good to me.

If we move it to the alloc module, I'm thinking to add a few methods
that I think might be useful (e.g. push). But lmk if we should keep it
to the bare minimum - just feels a bit odd to add something to common
infra that you e.g. couldn't even call push() on.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.