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:
Julian Schindel
2026-04-29 21:55:06 +02:00
committed by Rob Bradford
parent cb09c37c55
commit 8b101fb890
6 changed files with 15 additions and 14 deletions

View File

@@ -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,
)
};