Skip to content

Commit 51d785a

Browse files
uefi: Fix unsafe_op_in_unsafe_fn in info module
1 parent 1887dc2 commit 51d785a

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ trait InfoInternal: Align + ptr_meta::Pointee<Metadata = usize> {
4545
/// struct.
4646
unsafe fn name_ptr(ptr: *mut u8) -> *mut Char16 {
4747
let offset_of_str = Self::name_offset();
48-
ptr.add(offset_of_str).cast::<Char16>()
48+
unsafe { ptr.add(offset_of_str).cast::<Char16>() }
4949
}
5050

5151
/// Create a new info type in user-provided storage.
@@ -95,13 +95,13 @@ trait InfoInternal: Align + ptr_meta::Pointee<Metadata = usize> {
9595
// Create a pointer to the part of info where the name is
9696
// stored. Note that `info_ptr` is used rather than `storage` to
9797
// comply with Stacked Borrows.
98-
let info_name_ptr = Self::name_ptr(info_ptr.cast::<u8>());
98+
let info_name_ptr = unsafe { Self::name_ptr(info_ptr.cast::<u8>()) };
9999

100100
// Initialize the name slice.
101-
ptr::copy(name.as_ptr(), info_name_ptr, name_length_ucs2);
101+
unsafe { ptr::copy(name.as_ptr(), info_name_ptr, name_length_ucs2) };
102102

103103
// The struct is now valid and safe to dereference.
104-
let info = &mut *info_ptr;
104+
let info = unsafe { &mut *info_ptr };
105105
Ok(info)
106106
}
107107
}
@@ -111,10 +111,10 @@ where
111111
T: InfoInternal + ?Sized,
112112
{
113113
unsafe fn from_uefi<'ptr>(ptr: *mut c_void) -> &'ptr mut Self {
114-
let name_ptr = Self::name_ptr(ptr.cast::<u8>());
115-
let name = CStr16::from_ptr(name_ptr);
114+
let name_ptr = unsafe { Self::name_ptr(ptr.cast::<u8>()) };
115+
let name = unsafe { CStr16::from_ptr(name_ptr) };
116116
let name_len = name.as_slice_with_nul().len();
117-
&mut *ptr_meta::from_raw_parts_mut(ptr.cast::<()>(), name_len)
117+
unsafe { &mut *ptr_meta::from_raw_parts_mut(ptr.cast::<()>(), name_len) }
118118
}
119119
}
120120

0 commit comments

Comments
 (0)