mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-10 09:09:55 -04:00
gpu: nova-core: vbios: change PmuLookupTableEntry to use size_of
Annotate the PmuLookupTableEntry with an `#[repr(C, packed)]` attribute. Removes another magic number by making the struct the same size as the data it needs to read, allowing the use of `size_of::<PmuLookupTableEntry>()` [acourbot@nvidia.com: remove `dead_code` expect to fix `unfulfilled_lint_expectations` lint] Reviewed-by: Alexandre Courbot <acourbot@nvidia.com> Signed-off-by: Rhys Lloyd <krakow20@gmail.com> Link: https://lore.kernel.org/r/20250718073633.194032-3-krakow20@gmail.com Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
This commit is contained in:
committed by
Alexandre Courbot
parent
0f85b6c1cb
commit
2872c8982c
@@ -892,7 +892,7 @@ fn try_from(base: BiosImageBase) -> Result<Self> {
|
||||
/// The [`PmuLookupTableEntry`] structure is a single entry in the [`PmuLookupTable`].
|
||||
///
|
||||
/// See the [`PmuLookupTable`] description for more information.
|
||||
#[expect(dead_code)]
|
||||
#[repr(C, packed)]
|
||||
struct PmuLookupTableEntry {
|
||||
application_id: u8,
|
||||
target_id: u8,
|
||||
@@ -901,7 +901,7 @@ struct PmuLookupTableEntry {
|
||||
|
||||
impl PmuLookupTableEntry {
|
||||
fn new(data: &[u8]) -> Result<Self> {
|
||||
if data.len() < 6 {
|
||||
if data.len() < core::mem::size_of::<Self>() {
|
||||
return Err(EINVAL);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user