Skip to content

Commit e1f1878

Browse files
committed
Fix set_name for vxworks. Length of name should be truncated to VX_TASK_RENAME_LENGTH-1
1 parent 414482f commit e1f1878

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

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

+2-10
Original file line numberDiff line numberDiff line change
@@ -222,16 +222,8 @@ impl Thread {
222222

223223
#[cfg(target_os = "vxworks")]
224224
pub fn set_name(name: &CStr) {
225-
// FIXME(libc): adding real STATUS, ERROR type eventually.
226-
unsafe extern "C" {
227-
fn taskNameSet(task_id: libc::TASK_ID, task_name: *mut libc::c_char) -> libc::c_int;
228-
}
229-
230-
// VX_TASK_NAME_LEN is 31 in VxWorks 7.
231-
const VX_TASK_NAME_LEN: usize = 31;
232-
233-
let mut name = truncate_cstr::<{ VX_TASK_NAME_LEN }>(name);
234-
let res = unsafe { taskNameSet(libc::taskIdSelf(), name.as_mut_ptr()) };
225+
let mut name = truncate_cstr::<{ libc::VX_TASK_RENAME_LENGTH - 1 }>(name);
226+
let res = unsafe { libc::taskNameSet(libc::taskIdSelf(), name.as_mut_ptr()) };
235227
debug_assert_eq!(res, libc::OK);
236228
}
237229

0 commit comments

Comments
 (0)