rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rhys Lloyd <krakow20@gmail.com>
To: acourbot@nvidia.com, dakr@kernel.org
Cc: Rhys Lloyd <krakow20@gmail.com>,
	rust-for-linux@vger.kernel.org, airlied@gmail.com,
	simona@ffwll.ch, nouveau@lists.freedesktop.org,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: [PATCH] gpu: nova-core: vbios: use size_of instead of magic number
Date: Mon, 14 Jul 2025 03:43:14 -0700	[thread overview]
Message-ID: <20250714104322.100511-3-krakow20@gmail.com> (raw)
In-Reply-To: <20250714104322.100511-1-krakow20@gmail.com>

12 is identical to the value of `size_of::<BitHeader>()`,
so use the latter instead.

Signed-off-by: Rhys Lloyd <krakow20@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>() {
             return Err(EINVAL);
         }
 

base-commit: 215a3f91713383a3c0d2da82d223a608a3c17ac1
-- 
2.50.1


  parent reply	other threads:[~2025-07-14 10:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-14 10:43 [PATCH] gpu: nova-core: vbios: change PmuLookupTableEntry to relax alignment Rhys Lloyd
2025-07-14 10:43 ` [PATCH] gpu: nova-core: vbios: split out PmuLookupTableHeader from PmuLookupTable Rhys Lloyd
2025-07-16  1:40   ` Alexandre Courbot
2025-07-14 10:43 ` Rhys Lloyd [this message]
2025-07-16  1:43   ` [PATCH] gpu: nova-core: vbios: use size_of instead of magic number Alexandre Courbot
2025-07-14 10:51 ` [PATCH] gpu: nova-core: vbios: change PmuLookupTableEntry to relax alignment Benno Lossin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250714104322.100511-3-krakow20@gmail.com \
    --to=krakow20@gmail.com \
    --cc=acourbot@nvidia.com \
    --cc=airlied@gmail.com \
    --cc=dakr@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nouveau@lists.freedesktop.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=simona@ffwll.ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).