Skip to content

Commit 2083642

Browse files
committed
clippy: latest nightly fixes
1 parent 168c1aa commit 2083642

File tree

8 files changed

+31
-41
lines changed

8 files changed

+31
-41
lines changed

uefi-raw/src/protocol/console.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,9 @@ pub struct SimplePointerState {
133133
#[derive(Debug)]
134134
#[repr(C)]
135135
pub struct SimplePointerProtocol {
136-
pub reset: unsafe extern "efiapi" fn(
137-
this: *mut SimplePointerProtocol,
138-
extended_verification: Boolean,
139-
) -> Status,
140-
pub get_state: unsafe extern "efiapi" fn(
141-
this: *mut SimplePointerProtocol,
142-
state: *mut SimplePointerState,
143-
) -> Status,
136+
pub reset: unsafe extern "efiapi" fn(this: *mut Self, extended_verification: Boolean) -> Status,
137+
pub get_state:
138+
unsafe extern "efiapi" fn(this: *mut Self, state: *mut SimplePointerState) -> Status,
144139
pub wait_for_input: Event,
145140
pub mode: *const SimplePointerMode,
146141
}

uefi-raw/src/protocol/media.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use core::ffi::c_void;
88
#[repr(C)]
99
pub struct LoadFileProtocol {
1010
pub load_file: unsafe extern "efiapi" fn(
11-
this: *mut LoadFileProtocol,
11+
this: *mut Self,
1212
file_path: *const DevicePathProtocol,
1313
boot_policy: Boolean,
1414
buffer_size: *mut usize,
@@ -24,7 +24,7 @@ impl LoadFileProtocol {
2424
#[repr(C)]
2525
pub struct LoadFile2Protocol {
2626
pub load_file: unsafe extern "efiapi" fn(
27-
this: *mut LoadFile2Protocol,
27+
this: *mut Self,
2828
file_path: *const DevicePathProtocol,
2929
boot_policy: Boolean,
3030
buffer_size: *mut usize,

uefi-raw/src/protocol/rng.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ newtype_enum! {
3939
#[repr(C)]
4040
pub struct RngProtocol {
4141
pub get_info: unsafe extern "efiapi" fn(
42-
this: *mut RngProtocol,
42+
this: *mut Self,
4343
algorithm_list_size: *mut usize,
4444
algorithm_list: *mut RngAlgorithmType,
4545
) -> Status,
4646

4747
pub get_rng: unsafe extern "efiapi" fn(
48-
this: *mut RngProtocol,
48+
this: *mut Self,
4949
algorithm: *const RngAlgorithmType,
5050
value_length: usize,
5151
value: *mut u8,

uefi-raw/src/protocol/shell.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ use bitflags::bitflags;
1616
#[derive(Debug)]
1717
#[repr(C)]
1818
pub struct ListEntry {
19-
pub f_link: *mut ListEntry,
20-
pub b_link: *mut ListEntry,
19+
pub f_link: *mut Self,
20+
pub b_link: *mut Self,
2121
}
2222

2323
/// ShellFileInfo for File Lists

uefi-test-runner/src/boot/memory.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,14 @@ mod bootservices {
9393
/// global allocator.
9494
mod global {
9595
use alloc::boxed::Box;
96+
use core::ops::Deref;
9697
use uefi_raw::table::boot::PAGE_SIZE;
9798

9899
/// Simple test to ensure our custom allocator works with the `alloc` crate.
99100
pub fn alloc_vec() {
100101
info!("Allocating a vector using the global allocator");
101102

102-
#[allow(clippy::useless_vec)]
103-
let mut values = vec![-5, 16, 23, 4, 0];
104-
103+
let mut values = Box::new([-5, 16, 23, 4, 0]);
105104
values.sort_unstable();
106105

107106
assert_eq!(values[..], [-5, 0, 4, 16, 23], "Failed to sort vector");
@@ -115,8 +114,9 @@ mod global {
115114
#[repr(align(0x100))]
116115
struct Block([u8; 0x100]);
117116

118-
let value = vec![Block([1; 0x100])];
119-
assert_eq!(value.as_ptr() as usize % 0x100, 0, "Wrong alignment");
117+
let value = Box::new(Block([1; 0x100]));
118+
let inner_value = value.deref();
119+
assert_eq!(align_of_val(inner_value), 0x100, "Wrong alignment");
120120
}
121121
{
122122
info!("Allocating a memory page ({PAGE_SIZE}) using the global allocator");

uefi/src/proto/debug/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,20 @@ mod exception;
4141
pub struct DebugSupport {
4242
isa: ProcessorArch,
4343
get_maximum_processor_index:
44-
extern "efiapi" fn(this: &mut DebugSupport, max_processor_index: &mut usize) -> Status,
44+
extern "efiapi" fn(this: &mut Self, max_processor_index: &mut usize) -> Status,
4545
register_periodic_callback: unsafe extern "efiapi" fn(
46-
this: &mut DebugSupport,
46+
this: &mut Self,
4747
processor_index: usize,
4848
periodic_callback: Option<unsafe extern "efiapi" fn(SystemContext)>,
4949
) -> Status,
5050
register_exception_callback: unsafe extern "efiapi" fn(
51-
this: &mut DebugSupport,
51+
this: &mut Self,
5252
processor_index: usize,
5353
exception_callback: Option<unsafe extern "efiapi" fn(ExceptionType, SystemContext)>,
5454
exception_type: ExceptionType,
5555
) -> Status,
5656
invalidate_instruction_cache: unsafe extern "efiapi" fn(
57-
this: &mut DebugSupport,
57+
this: &mut Self,
5858
processor_index: usize,
5959
start: *mut c_void,
6060
length: u64,
@@ -192,20 +192,20 @@ pub enum ProcessorArch: u32 => {
192192
#[repr(C)]
193193
#[unsafe_protocol("eba4e8d2-3858-41ec-a281-2647ba9660d0")]
194194
pub struct DebugPort {
195-
reset: extern "efiapi" fn(this: &DebugPort) -> Status,
195+
reset: extern "efiapi" fn(this: &Self) -> Status,
196196
write: extern "efiapi" fn(
197-
this: &DebugPort,
197+
this: &Self,
198198
timeout: u32,
199199
buffer_size: &mut usize,
200200
buffer: *const c_void,
201201
) -> Status,
202202
read: extern "efiapi" fn(
203-
this: &DebugPort,
203+
this: &Self,
204204
timeout: u32,
205205
buffer_size: &mut usize,
206206
buffer: *mut c_void,
207207
) -> Status,
208-
poll: extern "efiapi" fn(this: &DebugPort) -> Status,
208+
poll: extern "efiapi" fn(this: &Self) -> Status,
209209
}
210210

211211
impl DebugPort {

uefi/src/proto/pi/mp.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,17 +105,17 @@ pub struct CpuPhysicalLocation {
105105
#[unsafe_protocol("3fdda605-a76e-4f46-ad29-12f4531b3d08")]
106106
pub struct MpServices {
107107
get_number_of_processors: extern "efiapi" fn(
108-
this: *const MpServices,
108+
this: *const Self,
109109
number_of_processors: *mut usize,
110110
number_of_enabled_processors: *mut usize,
111111
) -> Status,
112112
get_processor_info: extern "efiapi" fn(
113-
this: *const MpServices,
113+
this: *const Self,
114114
processor_number: usize,
115115
processor_info_buffer: *mut ProcessorInformation,
116116
) -> Status,
117117
startup_all_aps: extern "efiapi" fn(
118-
this: *const MpServices,
118+
this: *const Self,
119119
procedure: Procedure,
120120
single_thread: bool,
121121
wait_event: *mut c_void,
@@ -124,7 +124,7 @@ pub struct MpServices {
124124
failed_cpu_list: *mut *mut usize,
125125
) -> Status,
126126
startup_this_ap: extern "efiapi" fn(
127-
this: *const MpServices,
127+
this: *const Self,
128128
procedure: Procedure,
129129
processor_number: usize,
130130
wait_event: *mut c_void,
@@ -133,17 +133,17 @@ pub struct MpServices {
133133
finished: *mut bool,
134134
) -> Status,
135135
switch_bsp: extern "efiapi" fn(
136-
this: *const MpServices,
136+
this: *const Self,
137137
processor_number: usize,
138138
enable_old_bsp: bool,
139139
) -> Status,
140140
enable_disable_ap: extern "efiapi" fn(
141-
this: *const MpServices,
141+
this: *const Self,
142142
processor_number: usize,
143143
enable_ap: bool,
144144
health_flag: *const u32,
145145
) -> Status,
146-
who_am_i: extern "efiapi" fn(this: *const MpServices, processor_number: *mut usize) -> Status,
146+
who_am_i: extern "efiapi" fn(this: *const Self, processor_number: *mut usize) -> Status,
147147
}
148148

149149
impl MpServices {

xtask/src/arch.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
use std::fmt;
44

5-
#[derive(Clone, Copy, Debug, Eq, PartialEq, clap::ValueEnum)]
5+
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, clap::ValueEnum)]
66
pub enum UefiArch {
77
#[value(name = "aarch64")]
88
AArch64,
@@ -11,6 +11,7 @@ pub enum UefiArch {
1111
IA32,
1212

1313
#[value(name = "x86_64")]
14+
#[default]
1415
X86_64,
1516
}
1617

@@ -32,12 +33,6 @@ impl UefiArch {
3233
}
3334
}
3435

35-
impl Default for UefiArch {
36-
fn default() -> Self {
37-
Self::X86_64
38-
}
39-
}
40-
4136
impl fmt::Display for UefiArch {
4237
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
4338
write!(f, "{}", self.as_str())

0 commit comments

Comments
 (0)