Skip to content

Commit 4511623

Browse files
uefi: Replace addr_of_mut with raw pointer syntax
1 parent 5e8c1b5 commit 4511623

2 files changed

Lines changed: 14 additions & 18 deletions

File tree

uefi/src/proto/media/file/info.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -193,13 +193,13 @@ impl FileInfo {
193193
) -> core::result::Result<&'buf mut Self, FileInfoCreationError> {
194194
unsafe {
195195
Self::new_impl(storage, file_name, |ptr, size| {
196-
ptr::addr_of_mut!((*ptr).size).write(size);
197-
ptr::addr_of_mut!((*ptr).file_size).write(file_size);
198-
ptr::addr_of_mut!((*ptr).physical_size).write(physical_size);
199-
ptr::addr_of_mut!((*ptr).create_time).write(create_time);
200-
ptr::addr_of_mut!((*ptr).last_access_time).write(last_access_time);
201-
ptr::addr_of_mut!((*ptr).modification_time).write(modification_time);
202-
ptr::addr_of_mut!((*ptr).attribute).write(attribute);
196+
(&raw mut (*ptr).size).write(size);
197+
(&raw mut (*ptr).file_size).write(file_size);
198+
(&raw mut (*ptr).physical_size).write(physical_size);
199+
(&raw mut (*ptr).create_time).write(create_time);
200+
(&raw mut (*ptr).last_access_time).write(last_access_time);
201+
(&raw mut (*ptr).modification_time).write(modification_time);
202+
(&raw mut (*ptr).attribute).write(attribute);
203203
})
204204
}
205205
}
@@ -314,11 +314,11 @@ impl FileSystemInfo {
314314
) -> core::result::Result<&'buf mut Self, FileInfoCreationError> {
315315
unsafe {
316316
Self::new_impl(storage, volume_label, |ptr, size| {
317-
ptr::addr_of_mut!((*ptr).size).write(size);
318-
ptr::addr_of_mut!((*ptr).read_only).write(read_only);
319-
ptr::addr_of_mut!((*ptr).volume_size).write(volume_size);
320-
ptr::addr_of_mut!((*ptr).free_space).write(free_space);
321-
ptr::addr_of_mut!((*ptr).block_size).write(block_size);
317+
(&raw mut (*ptr).size).write(size);
318+
(&raw mut (*ptr).read_only).write(read_only);
319+
(&raw mut (*ptr).volume_size).write(volume_size);
320+
(&raw mut (*ptr).free_space).write(free_space);
321+
(&raw mut (*ptr).block_size).write(block_size);
322322
})
323323
}
324324
}

uefi/src/proto/media/load_file.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,11 @@ impl LoadFile {
7272
file_path: &DevicePath,
7373
boot_policy: BootPolicy,
7474
) -> Result<Box<[u8]>> {
75-
let this = core::ptr::addr_of_mut!(*self).cast();
76-
7775
let fetch_data_fn = |buf: &'a mut [u8]| {
7876
let mut size = buf.len();
7977
let status = unsafe {
8078
(self.0.load_file)(
81-
this,
79+
&raw mut self.0,
8280
file_path.as_ffi_ptr().cast(),
8381
boot_policy.into(),
8482
&mut size,
@@ -135,13 +133,11 @@ impl LoadFile2 {
135133
#[cfg(feature = "alloc")]
136134
#[allow(clippy::extra_unused_lifetimes)] // false positive, it is used
137135
pub fn load_file<'a>(&mut self, file_path: &DevicePath) -> Result<Box<[u8]>> {
138-
let this = core::ptr::addr_of_mut!(*self).cast();
139-
140136
let fetch_data_fn = |buf: &'a mut [u8]| {
141137
let mut size = buf.len();
142138
let status = unsafe {
143139
(self.0.load_file)(
144-
this,
140+
&raw mut self.0,
145141
file_path.as_ffi_ptr().cast(),
146142
Boolean::FALSE, /* always false - see spec */
147143
&mut size,

0 commit comments

Comments
 (0)