Skip to content

Commit f7f0dd5

Browse files
uefi: Fix unsafe_op_in_unsafe_fn in strs module
1 parent a571e27 commit f7f0dd5

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

uefi/src/data_types/strs.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,11 @@ impl CStr8 {
143143
#[must_use]
144144
pub unsafe fn from_ptr<'ptr>(ptr: *const Char8) -> &'ptr Self {
145145
let mut len = 0;
146-
while *ptr.add(len) != NUL_8 {
146+
while unsafe { *ptr.add(len) } != NUL_8 {
147147
len += 1
148148
}
149149
let ptr = ptr.cast::<u8>();
150-
Self::from_bytes_with_nul_unchecked(slice::from_raw_parts(ptr, len + 1))
150+
unsafe { Self::from_bytes_with_nul_unchecked(slice::from_raw_parts(ptr, len + 1)) }
151151
}
152152

153153
/// Creates a CStr8 reference from bytes.
@@ -171,7 +171,7 @@ impl CStr8 {
171171
/// null-terminated string, with no interior null bytes.
172172
#[must_use]
173173
pub const unsafe fn from_bytes_with_nul_unchecked(chars: &[u8]) -> &Self {
174-
&*(ptr::from_ref(chars) as *const Self)
174+
unsafe { &*(ptr::from_ref(chars) as *const Self) }
175175
}
176176

177177
/// Returns the inner pointer to this CStr8.
@@ -352,11 +352,11 @@ impl CStr16 {
352352
#[must_use]
353353
pub unsafe fn from_ptr<'ptr>(ptr: *const Char16) -> &'ptr Self {
354354
let mut len = 0;
355-
while *ptr.add(len) != NUL_16 {
355+
while unsafe { *ptr.add(len) } != NUL_16 {
356356
len += 1
357357
}
358358
let ptr = ptr.cast::<u16>();
359-
Self::from_u16_with_nul_unchecked(slice::from_raw_parts(ptr, len + 1))
359+
unsafe { Self::from_u16_with_nul_unchecked(slice::from_raw_parts(ptr, len + 1)) }
360360
}
361361

362362
/// Creates a `&CStr16` from a u16 slice, stopping at the first nul character.
@@ -405,7 +405,7 @@ impl CStr16 {
405405
/// null-terminated string, with no interior null characters.
406406
#[must_use]
407407
pub const unsafe fn from_u16_with_nul_unchecked(codes: &[u16]) -> &Self {
408-
&*(ptr::from_ref(codes) as *const Self)
408+
unsafe { &*(ptr::from_ref(codes) as *const Self) }
409409
}
410410

411411
/// Creates a `&CStr16` from a [`Char16`] slice, stopping at the first nul character.
@@ -455,7 +455,7 @@ impl CStr16 {
455455
#[must_use]
456456
pub const unsafe fn from_char16_with_nul_unchecked(chars: &[Char16]) -> &Self {
457457
let ptr: *const [Char16] = chars;
458-
&*(ptr as *const Self)
458+
unsafe { &*(ptr as *const Self) }
459459
}
460460

461461
/// Convert a [`&str`] to a `&CStr16`, backed by a buffer.

0 commit comments

Comments
 (0)