Skip to content

Commit 5c73c5e

Browse files
xizheyingitbot
authored and
gitbot
committed
remove assume_init in stack_overflow
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
1 parent b353e19 commit 5c73c5e

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

std/src/sys/pal/unix/stack_overflow.rs

+9-6
Original file line numberDiff line numberDiff line change
@@ -319,26 +319,29 @@ mod imp {
319319
))]
320320
unsafe fn get_stack_start() -> Option<*mut libc::c_void> {
321321
let mut ret = None;
322-
let attr: mem::MaybeUninit<libc::pthread_attr_t> = if cfg!(target_os = "freebsd") {
322+
let mut attr: mem::MaybeUninit<libc::pthread_attr_t> = if cfg!(target_os = "freebsd") {
323323
let mut attr = mem::MaybeUninit::uninit();
324324
assert_eq!(libc::pthread_attr_init((&raw mut attr) as *mut _), 0);
325325
attr
326326
} else {
327327
mem::MaybeUninit::zeroed()
328328
};
329-
let mut attr = unsafe { attr.assume_init() };
329+
330330
#[cfg(target_os = "freebsd")]
331-
let e = libc::pthread_attr_get_np(libc::pthread_self(), &mut attr);
331+
let e = libc::pthread_attr_get_np(libc::pthread_self(), attr.as_mut_ptr());
332332
#[cfg(not(target_os = "freebsd"))]
333-
let e = libc::pthread_getattr_np(libc::pthread_self(), &mut attr);
333+
let e = libc::pthread_getattr_np(libc::pthread_self(), attr.as_mut_ptr());
334334
if e == 0 {
335335
let mut stackaddr = crate::ptr::null_mut();
336336
let mut stacksize = 0;
337-
assert_eq!(libc::pthread_attr_getstack(&attr, &mut stackaddr, &mut stacksize), 0);
337+
assert_eq!(
338+
libc::pthread_attr_getstack(attr.as_ptr(), &mut stackaddr, &mut stacksize),
339+
0
340+
);
338341
ret = Some(stackaddr);
339342
}
340343
if e == 0 || cfg!(target_os = "freebsd") {
341-
assert_eq!(libc::pthread_attr_destroy(&mut attr), 0);
344+
assert_eq!(libc::pthread_attr_destroy(attr.as_mut_ptr()), 0);
342345
}
343346
ret
344347
}

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

-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ impl Thread {
5151
let mut native: libc::pthread_t = mem::zeroed();
5252
let mut attr: mem::MaybeUninit<libc::pthread_attr_t> = mem::MaybeUninit::uninit();
5353
assert_eq!(libc::pthread_attr_init(attr.as_mut_ptr()), 0);
54-
//let mut attr: libc::pthread_attr_t = unsafe { attr.assume_init() };
5554

5655
#[cfg(target_os = "espidf")]
5756
if stack > 0 {

0 commit comments

Comments
 (0)