Skip to content

Commit f4e8842

Browse files
committed
Apply deny(unsafe_op_in_unsafe_fn) to all of sys/unsupported.
1 parent 3d192ac commit f4e8842

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

library/std/src/sys/unsupported/common.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,13 @@ pub fn hashmap_random_keys() -> (u64, u64) {
3939
pub enum Void {}
4040

4141
pub unsafe fn strlen(mut s: *const c_char) -> usize {
42-
let mut n = 0;
43-
while *s != 0 {
44-
n += 1;
45-
s = s.offset(1);
42+
// SAFETY: The caller must guarantee `s` points to a valid 0-terminated string.
43+
unsafe {
44+
let mut n = 0;
45+
while *s != 0 {
46+
n += 1;
47+
s = s.offset(1);
48+
}
49+
n
4650
}
47-
return n;
4851
}

library/std/src/sys/unsupported/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![deny(unsafe_op_in_unsafe_fn)]
2+
13
pub mod alloc;
24
pub mod args;
35
pub mod cmath;

library/std/src/sys/unsupported/mutex.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![deny(unsafe_op_in_unsafe_fn)]
2-
31
use crate::cell::Cell;
42

53
pub struct Mutex {

library/std/src/sys/unsupported/rwlock.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![deny(unsafe_op_in_unsafe_fn)]
2-
31
use crate::cell::Cell;
42

53
pub struct RWLock {

0 commit comments

Comments
 (0)