Skip to content

Commit 572414e

Browse files
ehussgitbot
authored and
gitbot
committed
std: Apply unsafe_op_in_unsafe_fn
1 parent 29c1eef commit 572414e

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

std/src/alloc.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
//!
2121
//! unsafe impl GlobalAlloc for MyAllocator {
2222
//! unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
23-
//! System.alloc(layout)
23+
//! unsafe { System.alloc(layout) }
2424
//! }
2525
//!
2626
//! unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) {
27-
//! System.dealloc(ptr, layout)
27+
//! unsafe { System.dealloc(ptr, layout) }
2828
//! }
2929
//! }
3030
//!
@@ -102,15 +102,15 @@ pub use alloc_crate::alloc::*;
102102
///
103103
/// unsafe impl GlobalAlloc for Counter {
104104
/// unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
105-
/// let ret = System.alloc(layout);
105+
/// let ret = unsafe { System.alloc(layout) };
106106
/// if !ret.is_null() {
107107
/// ALLOCATED.fetch_add(layout.size(), Relaxed);
108108
/// }
109109
/// ret
110110
/// }
111111
///
112112
/// unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) {
113-
/// System.dealloc(ptr, layout);
113+
/// unsafe { System.dealloc(ptr, layout); }
114114
/// ALLOCATED.fetch_sub(layout.size(), Relaxed);
115115
/// }
116116
/// }

std/src/sys/pal/teeos/thread.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ impl Thread {
5656
}
5757
};
5858

59-
let ret = libc::pthread_create(&mut native, &attr, thread_start, p as *mut _);
59+
let ret = unsafe { libc::pthread_create(&mut native, &attr, thread_start, p as *mut _) };
6060
// Note: if the thread creation fails and this assert fails, then p will
6161
// be leaked. However, an alternative design could cause double-free
6262
// which is clearly worse.

0 commit comments

Comments
 (0)