From 42997b3f08ee8d689cb78c74dcf3e1299e930822 Mon Sep 17 00:00:00 2001 From: Steve Lau Date: Sun, 15 Sep 2024 18:00:00 +0800 Subject: [PATCH 1/2] fix: correct arg type of prctl::set_timerslack --- changelog/2505.fixed.md | 1 + src/sys/prctl.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 changelog/2505.fixed.md diff --git a/changelog/2505.fixed.md b/changelog/2505.fixed.md new file mode 100644 index 0000000000..2dc6f19169 --- /dev/null +++ b/changelog/2505.fixed.md @@ -0,0 +1 @@ +The `ns` argument of `sys::prctl::set_timerslack()` should be of type `c_ulong` diff --git a/src/sys/prctl.rs b/src/sys/prctl.rs index 35b1ce170f..d183e105ef 100644 --- a/src/sys/prctl.rs +++ b/src/sys/prctl.rs @@ -166,7 +166,7 @@ pub fn get_name() -> Result { /// Sets the timer slack value for the calling thread. Timer slack is used by the kernel to group /// timer expirations and make them the supplied amount of nanoseconds late. -pub fn set_timerslack(ns: u64) -> Result<()> { +pub fn set_timerslack(ns: c_ulong) -> Result<()> { let res = unsafe { libc::prctl(libc::PR_SET_TIMERSLACK, ns, 0, 0, 0) }; Errno::result(res).map(drop) From 31f0883101a1bac7f34c1f9665942f6e186ae4d1 Mon Sep 17 00:00:00 2001 From: Steve Lau Date: Sun, 15 Sep 2024 18:05:58 +0800 Subject: [PATCH 2/2] test: update test --- test/sys/test_prctl.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/sys/test_prctl.rs b/test/sys/test_prctl.rs index b409735af6..85327034d2 100644 --- a/test/sys/test_prctl.rs +++ b/test/sys/test_prctl.rs @@ -89,14 +89,14 @@ mod test_prctl { #[cfg_attr(qemu, ignore)] #[test] fn test_get_set_timerslack() { - let original = prctl::get_timerslack().unwrap(); + let original = prctl::get_timerslack().unwrap() as libc::c_ulong; let slack = 60_000; prctl::set_timerslack(slack).unwrap(); - let res = prctl::get_timerslack().unwrap(); - assert_eq!(slack, res as u64); + let res = prctl::get_timerslack().unwrap() as libc::c_ulong; + assert_eq!(slack, res); - prctl::set_timerslack(original as u64).unwrap(); + prctl::set_timerslack(original).unwrap(); } #[test]