From 83d7e353d129d2f3ced0c3510ceaeae7e32983e4 Mon Sep 17 00:00:00 2001 From: dragon-zhang Date: Fri, 25 Jul 2025 23:29:40 +0800 Subject: [PATCH] fix clippy --- core/src/common/ordered_work_steal.rs | 2 +- core/src/common/work_steal.rs | 2 +- core/src/coroutine/korosensei.rs | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/core/src/common/ordered_work_steal.rs b/core/src/common/ordered_work_steal.rs index 3ea7ad07..b82e3ead 100644 --- a/core/src/common/ordered_work_steal.rs +++ b/core/src/common/ordered_work_steal.rs @@ -347,7 +347,7 @@ impl<'l, T: Debug> OrderedLocalQueue<'l, T> { /// ``` pub fn pop(&self) -> Option { //每从本地弹出61次,就从全局队列弹出 - if self.tick() % 61 == 0 { + if self.tick().is_multiple_of(61) { if let Some(val) = self.shared.pop() { return Some(val); } diff --git a/core/src/common/work_steal.rs b/core/src/common/work_steal.rs index 1b2a8357..b700393c 100644 --- a/core/src/common/work_steal.rs +++ b/core/src/common/work_steal.rs @@ -278,7 +278,7 @@ impl<'l, T: Debug> LocalQueue<'l, T> { /// ``` pub fn pop(&self) -> Option { //每从本地弹出61次,就从全局队列弹出 - if self.tick() % 61 == 0 { + if self.tick().is_multiple_of(61) { if let Some(val) = self.shared.pop() { return Some(val); } diff --git a/core/src/coroutine/korosensei.rs b/core/src/coroutine/korosensei.rs index 880b65c5..6262f159 100644 --- a/core/src/coroutine/korosensei.rs +++ b/core/src/coroutine/korosensei.rs @@ -57,7 +57,7 @@ impl<'c, Param, Yield, Return> Coroutine<'c, Param, Yield, Return> { any(target_os = "linux", target_os = "android"), target_arch = "x86", ))] { - let sp = u64::from(std::mem::transmute::<_, std::ffi::c_uint>(context.uc_mcontext.gregs[usize::try_from(libc::REG_ESP).expect("overflow")])); + let sp = u64::from(std::ffi::c_uint::from_ne_bytes(context.uc_mcontext.gregs[usize::try_from(libc::REG_ESP).expect("overflow")].to_ne_bytes())); } else if #[cfg(all(target_vendor = "apple", target_arch = "x86_64"))] { let sp = u64::try_from((*context.uc_mcontext).__ss.__rsp).expect("overflow"); } else if #[cfg(all( @@ -108,11 +108,11 @@ impl<'c, Param, Yield, Return> Coroutine<'c, Param, Yield, Return> { target_arch = "x86", ))] { let TrapHandlerRegs { eip, esp, ebp, ecx, edx } = regs; - context.uc_mcontext.gregs[usize::try_from(libc::REG_EIP).expect("overflow")] = std::mem::transmute(eip); - context.uc_mcontext.gregs[usize::try_from(libc::REG_ESP).expect("overflow")] = std::mem::transmute(esp); - context.uc_mcontext.gregs[usize::try_from(libc::REG_EBP).expect("overflow")] = std::mem::transmute(ebp); - context.uc_mcontext.gregs[usize::try_from(libc::REG_ECX).expect("overflow")] = std::mem::transmute(ecx); - context.uc_mcontext.gregs[usize::try_from(libc::REG_EDX).expect("overflow")] = std::mem::transmute(edx); + context.uc_mcontext.gregs[usize::try_from(libc::REG_EIP).expect("overflow")] = i32::from_ne_bytes(eip.to_ne_bytes()); + context.uc_mcontext.gregs[usize::try_from(libc::REG_ESP).expect("overflow")] = i32::from_ne_bytes(esp.to_ne_bytes()); + context.uc_mcontext.gregs[usize::try_from(libc::REG_EBP).expect("overflow")] = i32::from_ne_bytes(ebp.to_ne_bytes()); + context.uc_mcontext.gregs[usize::try_from(libc::REG_ECX).expect("overflow")] = i32::from_ne_bytes(ecx.to_ne_bytes()); + context.uc_mcontext.gregs[usize::try_from(libc::REG_EDX).expect("overflow")] = i32::from_ne_bytes(edx.to_ne_bytes()); } else if #[cfg(all(target_vendor = "apple", target_arch = "x86_64"))] { let TrapHandlerRegs { rip, rsp, rbp, rdi, rsi } = regs; (*context.uc_mcontext).__ss.__rip = rip;