Re: [PATCH v3 2/7] gpu: nova-core: add TLV parser for firmware files
Timur Tabi <[email protected]> Thu, 9 Jul 2026 21:29:54 +0000
| Newsgroups | dev.linux.lists.nova-gpu,dev.linux.lists.driver-core,org.kernel.vger.rust-for-linux |
|---|---|
| Message-ID | <[email protected]> |
On Thu, 2026-07-09 at 12:43 +0900, Alexandre Courbot wrote: > > sig_bytes.len() cannot be 0, so we know that sig_size cannot be 0, and therefore > > > > sig_bytes.chunks_exact(sig_size).nth(index).ok_or(EINVAL) > > > > chunks_exact() cannot fail. > > Basically we want a guarantee that `sig_size` is not zero. I'd prefer if > we could enforce that using the type system rather than relying on a > guarantee that `get_bytes` doesn't return an empty slice, because even > that guarantee alone is not enough - we also need `num_sigs > 0` and > `sig_bytes.len() % num_sigs == 0` for that. I'm about to post a v4 that has a "get_signature()" method that encapsulates all this processing. I think it addresses most, if not all, of these issues. It does depend on get_bytes() not returning an empty slice, though.