Skip to content

Commit 6b9a10d

Browse files
johnhubbardDanilo Krummrich
authored andcommitted
gpu: nova-core: vbios: use from_le_bytes() for PCI ROM header parsing
Clippy fires two clippy::precedence warnings on the manual byte-shifting expression: warning: operator precedence can trip the unwary --> drivers/gpu/nova-core/vbios.rs:511:17 | 511 | / u32::from(data[29]) << 24 512 | | | u32::from(data[28]) << 16 513 | | | u32::from(data[27]) << 8 | |______________________________________________^ Clear the warnings by replacing manual byte-shifting with u32::from_le_bytes(). Using from_le_bytes() is also a tiny code improvement, because it uses less code and is clearer about the intent. Signed-off-by: John Hubbard <jhubbard@nvidia.com> Link: https://patch.msgid.link/20260404212831.78971-2-jhubbard@nvidia.com Signed-off-by: Danilo Krummrich <dakr@kernel.org>
1 parent de0aca1 commit 6b9a10d

1 file changed

Lines changed: 1 addition & 6 deletions

File tree

drivers/gpu/nova-core/vbios.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -507,12 +507,7 @@ impl PciRomHeader {
507507

508508
if data.len() >= 30 {
509509
// Read size_of_block at offset 0x1A.
510-
size_of_block = Some(
511-
u32::from(data[29]) << 24
512-
| u32::from(data[28]) << 16
513-
| u32::from(data[27]) << 8
514-
| u32::from(data[26]),
515-
);
510+
size_of_block = Some(u32::from_le_bytes([data[26], data[27], data[28], data[29]]));
516511
}
517512

518513
// For NBSI images, try to read the nbsiDataOffset at offset 0x16.

0 commit comments

Comments
 (0)