[PATCH] gpu: nova-core: vbios: use size_of instead of magic number

Alexandre Courbot acourbot at nvidia.com
Wed Jul 16 01:43:41 UTC 2025


On Mon Jul 14, 2025 at 7:43 PM JST, Rhys Lloyd wrote:
> 12 is identical to the value of `size_of::<BitHeader>()`,
> so use the latter instead.
>
> Signed-off-by: Rhys Lloyd <krakow20 at gmail.com>
> ---
>  drivers/gpu/nova-core/vbios.rs | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/nova-core/vbios.rs b/drivers/gpu/nova-core/vbios.rs
> index 663fc50e8b66..ac35415b4ffb 100644
> --- a/drivers/gpu/nova-core/vbios.rs
> +++ b/drivers/gpu/nova-core/vbios.rs
> @@ -365,7 +365,7 @@ struct BitHeader {
>  
>  impl BitHeader {
>      fn new(data: &[u8]) -> Result<Self> {
> -        if data.len() < 12 {
> +        if data.len() < core::mem::size_of::<Self>() {

I agree, but would feel better if we also made `BitHeader` `#[repr(C)]`
to really guarantee this.

(or please educate me if this is unneeded :))


More information about the dri-devel mailing list