From 7122529b6b45894df6a66aac57d2104f29765c0a Mon Sep 17 00:00:00 2001 From: "zongmin.gu" Date: Mon, 1 Mar 2021 10:44:05 +0800 Subject: [PATCH] Fix affinity array size incorrect issue --- src/libos/src/sched/syscalls.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libos/src/sched/syscalls.rs b/src/libos/src/sched/syscalls.rs index 83f584e1..13dd128f 100644 --- a/src/libos/src/sched/syscalls.rs +++ b/src/libos/src/sched/syscalls.rs @@ -10,7 +10,7 @@ pub fn do_sched_yield() -> Result { pub fn do_sched_getaffinity(pid: pid_t, buf_size: size_t, buf_ptr: *mut u8) -> Result { // Construct safe Rust types let buf_size = { - if buf_size * 8 < AVAIL_CPUSET.cpu_count() { + if buf_size < CpuSet::len() { return_errno!(EINVAL, "buf size is not big enough"); } @@ -39,7 +39,7 @@ pub fn do_sched_getaffinity(pid: pid_t, buf_size: size_t, buf_ptr: *mut u8) -> R pub fn do_sched_setaffinity(pid: pid_t, buf_size: size_t, buf_ptr: *const u8) -> Result { // Convert unsafe C types into safe Rust types let buf_size = { - if buf_size * 8 < AVAIL_CPUSET.cpu_count() { + if buf_size < CpuSet::len() { return_errno!(EINVAL, "buf size is not big enough"); } CpuSet::len()