mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: replace as <pointer> casts with safer alternatives
`as` casts can change mutability, which quickly leads to undefined behavior. Signed-off-by: Julian Schindel <mail@arctic-alpaca.de>
This commit is contained in:
committed by
Rob Bradford
parent
cb09c37c55
commit
8b101fb890
@@ -303,7 +303,7 @@ fn core_scheduling_cookie() -> u64 {
|
||||
PR_SCHED_CORE_GET,
|
||||
0,
|
||||
PR_SCHED_CORE_SCOPE_THREAD,
|
||||
&mut cookie as *mut u64,
|
||||
&raw mut cookie,
|
||||
)
|
||||
};
|
||||
if ret == -1 {
|
||||
@@ -1187,12 +1187,13 @@ impl CpuManager {
|
||||
.spawn(move || {
|
||||
// Schedule the thread to run on the expected CPU set
|
||||
if let Some(cpuset) = cpuset.as_ref() {
|
||||
let cpuset: *const libc::cpu_set_t = cpuset;
|
||||
// SAFETY: FFI call with correct arguments
|
||||
let ret = unsafe {
|
||||
libc::sched_setaffinity(
|
||||
0,
|
||||
std::mem::size_of::<libc::cpu_set_t>(),
|
||||
cpuset as *const libc::cpu_set_t,
|
||||
cpuset,
|
||||
)
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user