From 2083642b4b1234ebfe59d67e63937de8444496d7 Mon Sep 17 00:00:00 2001 From: Philipp Schuster Date: Sun, 2 Nov 2025 09:27:27 +0100 Subject: [PATCH] clippy: latest nightly fixes --- uefi-raw/src/protocol/console.rs | 11 +++-------- uefi-raw/src/protocol/media.rs | 4 ++-- uefi-raw/src/protocol/rng.rs | 4 ++-- uefi-raw/src/protocol/shell.rs | 4 ++-- uefi-test-runner/src/boot/memory.rs | 10 +++++----- uefi/src/proto/debug/mod.rs | 16 ++++++++-------- uefi/src/proto/pi/mp.rs | 14 +++++++------- xtask/src/arch.rs | 9 ++------- 8 files changed, 31 insertions(+), 41 deletions(-) diff --git a/uefi-raw/src/protocol/console.rs b/uefi-raw/src/protocol/console.rs index 7f5e92bf9..1ca05e6e7 100644 --- a/uefi-raw/src/protocol/console.rs +++ b/uefi-raw/src/protocol/console.rs @@ -133,14 +133,9 @@ pub struct SimplePointerState { #[derive(Debug)] #[repr(C)] pub struct SimplePointerProtocol { - pub reset: unsafe extern "efiapi" fn( - this: *mut SimplePointerProtocol, - extended_verification: Boolean, - ) -> Status, - pub get_state: unsafe extern "efiapi" fn( - this: *mut SimplePointerProtocol, - state: *mut SimplePointerState, - ) -> Status, + pub reset: unsafe extern "efiapi" fn(this: *mut Self, extended_verification: Boolean) -> Status, + pub get_state: + unsafe extern "efiapi" fn(this: *mut Self, state: *mut SimplePointerState) -> Status, pub wait_for_input: Event, pub mode: *const SimplePointerMode, } diff --git a/uefi-raw/src/protocol/media.rs b/uefi-raw/src/protocol/media.rs index 6baffb108..ae44c71d1 100644 --- a/uefi-raw/src/protocol/media.rs +++ b/uefi-raw/src/protocol/media.rs @@ -8,7 +8,7 @@ use core::ffi::c_void; #[repr(C)] pub struct LoadFileProtocol { pub load_file: unsafe extern "efiapi" fn( - this: *mut LoadFileProtocol, + this: *mut Self, file_path: *const DevicePathProtocol, boot_policy: Boolean, buffer_size: *mut usize, @@ -24,7 +24,7 @@ impl LoadFileProtocol { #[repr(C)] pub struct LoadFile2Protocol { pub load_file: unsafe extern "efiapi" fn( - this: *mut LoadFile2Protocol, + this: *mut Self, file_path: *const DevicePathProtocol, boot_policy: Boolean, buffer_size: *mut usize, diff --git a/uefi-raw/src/protocol/rng.rs b/uefi-raw/src/protocol/rng.rs index 30ece5693..fb637a369 100644 --- a/uefi-raw/src/protocol/rng.rs +++ b/uefi-raw/src/protocol/rng.rs @@ -39,13 +39,13 @@ newtype_enum! { #[repr(C)] pub struct RngProtocol { pub get_info: unsafe extern "efiapi" fn( - this: *mut RngProtocol, + this: *mut Self, algorithm_list_size: *mut usize, algorithm_list: *mut RngAlgorithmType, ) -> Status, pub get_rng: unsafe extern "efiapi" fn( - this: *mut RngProtocol, + this: *mut Self, algorithm: *const RngAlgorithmType, value_length: usize, value: *mut u8, diff --git a/uefi-raw/src/protocol/shell.rs b/uefi-raw/src/protocol/shell.rs index 621e9dd6f..24f5cdb38 100644 --- a/uefi-raw/src/protocol/shell.rs +++ b/uefi-raw/src/protocol/shell.rs @@ -16,8 +16,8 @@ use bitflags::bitflags; #[derive(Debug)] #[repr(C)] pub struct ListEntry { - pub f_link: *mut ListEntry, - pub b_link: *mut ListEntry, + pub f_link: *mut Self, + pub b_link: *mut Self, } /// ShellFileInfo for File Lists diff --git a/uefi-test-runner/src/boot/memory.rs b/uefi-test-runner/src/boot/memory.rs index d360fd1e5..2c008a905 100644 --- a/uefi-test-runner/src/boot/memory.rs +++ b/uefi-test-runner/src/boot/memory.rs @@ -93,15 +93,14 @@ mod bootservices { /// global allocator. mod global { use alloc::boxed::Box; + use core::ops::Deref; use uefi_raw::table::boot::PAGE_SIZE; /// Simple test to ensure our custom allocator works with the `alloc` crate. pub fn alloc_vec() { info!("Allocating a vector using the global allocator"); - #[allow(clippy::useless_vec)] - let mut values = vec![-5, 16, 23, 4, 0]; - + let mut values = Box::new([-5, 16, 23, 4, 0]); values.sort_unstable(); assert_eq!(values[..], [-5, 0, 4, 16, 23], "Failed to sort vector"); @@ -115,8 +114,9 @@ mod global { #[repr(align(0x100))] struct Block([u8; 0x100]); - let value = vec![Block([1; 0x100])]; - assert_eq!(value.as_ptr() as usize % 0x100, 0, "Wrong alignment"); + let value = Box::new(Block([1; 0x100])); + let inner_value = value.deref(); + assert_eq!(align_of_val(inner_value), 0x100, "Wrong alignment"); } { info!("Allocating a memory page ({PAGE_SIZE}) using the global allocator"); diff --git a/uefi/src/proto/debug/mod.rs b/uefi/src/proto/debug/mod.rs index 74e04597a..6391056eb 100644 --- a/uefi/src/proto/debug/mod.rs +++ b/uefi/src/proto/debug/mod.rs @@ -41,20 +41,20 @@ mod exception; pub struct DebugSupport { isa: ProcessorArch, get_maximum_processor_index: - extern "efiapi" fn(this: &mut DebugSupport, max_processor_index: &mut usize) -> Status, + extern "efiapi" fn(this: &mut Self, max_processor_index: &mut usize) -> Status, register_periodic_callback: unsafe extern "efiapi" fn( - this: &mut DebugSupport, + this: &mut Self, processor_index: usize, periodic_callback: Option, ) -> Status, register_exception_callback: unsafe extern "efiapi" fn( - this: &mut DebugSupport, + this: &mut Self, processor_index: usize, exception_callback: Option, exception_type: ExceptionType, ) -> Status, invalidate_instruction_cache: unsafe extern "efiapi" fn( - this: &mut DebugSupport, + this: &mut Self, processor_index: usize, start: *mut c_void, length: u64, @@ -192,20 +192,20 @@ pub enum ProcessorArch: u32 => { #[repr(C)] #[unsafe_protocol("eba4e8d2-3858-41ec-a281-2647ba9660d0")] pub struct DebugPort { - reset: extern "efiapi" fn(this: &DebugPort) -> Status, + reset: extern "efiapi" fn(this: &Self) -> Status, write: extern "efiapi" fn( - this: &DebugPort, + this: &Self, timeout: u32, buffer_size: &mut usize, buffer: *const c_void, ) -> Status, read: extern "efiapi" fn( - this: &DebugPort, + this: &Self, timeout: u32, buffer_size: &mut usize, buffer: *mut c_void, ) -> Status, - poll: extern "efiapi" fn(this: &DebugPort) -> Status, + poll: extern "efiapi" fn(this: &Self) -> Status, } impl DebugPort { diff --git a/uefi/src/proto/pi/mp.rs b/uefi/src/proto/pi/mp.rs index e27fc6ad0..23c131631 100644 --- a/uefi/src/proto/pi/mp.rs +++ b/uefi/src/proto/pi/mp.rs @@ -105,17 +105,17 @@ pub struct CpuPhysicalLocation { #[unsafe_protocol("3fdda605-a76e-4f46-ad29-12f4531b3d08")] pub struct MpServices { get_number_of_processors: extern "efiapi" fn( - this: *const MpServices, + this: *const Self, number_of_processors: *mut usize, number_of_enabled_processors: *mut usize, ) -> Status, get_processor_info: extern "efiapi" fn( - this: *const MpServices, + this: *const Self, processor_number: usize, processor_info_buffer: *mut ProcessorInformation, ) -> Status, startup_all_aps: extern "efiapi" fn( - this: *const MpServices, + this: *const Self, procedure: Procedure, single_thread: bool, wait_event: *mut c_void, @@ -124,7 +124,7 @@ pub struct MpServices { failed_cpu_list: *mut *mut usize, ) -> Status, startup_this_ap: extern "efiapi" fn( - this: *const MpServices, + this: *const Self, procedure: Procedure, processor_number: usize, wait_event: *mut c_void, @@ -133,17 +133,17 @@ pub struct MpServices { finished: *mut bool, ) -> Status, switch_bsp: extern "efiapi" fn( - this: *const MpServices, + this: *const Self, processor_number: usize, enable_old_bsp: bool, ) -> Status, enable_disable_ap: extern "efiapi" fn( - this: *const MpServices, + this: *const Self, processor_number: usize, enable_ap: bool, health_flag: *const u32, ) -> Status, - who_am_i: extern "efiapi" fn(this: *const MpServices, processor_number: *mut usize) -> Status, + who_am_i: extern "efiapi" fn(this: *const Self, processor_number: *mut usize) -> Status, } impl MpServices { diff --git a/xtask/src/arch.rs b/xtask/src/arch.rs index 9bb0bb16e..7bbacaa61 100644 --- a/xtask/src/arch.rs +++ b/xtask/src/arch.rs @@ -2,7 +2,7 @@ use std::fmt; -#[derive(Clone, Copy, Debug, Eq, PartialEq, clap::ValueEnum)] +#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, clap::ValueEnum)] pub enum UefiArch { #[value(name = "aarch64")] AArch64, @@ -11,6 +11,7 @@ pub enum UefiArch { IA32, #[value(name = "x86_64")] + #[default] X86_64, } @@ -32,12 +33,6 @@ impl UefiArch { } } -impl Default for UefiArch { - fn default() -> Self { - Self::X86_64 - } -} - impl fmt::Display for UefiArch { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", self.as_str())