Skip to content

Commit b6f9cc3

Browse files
authored
fix: correct arg type of prctl::set_timerslack (#2505)
* fix: correct arg type of prctl::set_timerslack * test: update test
1 parent 7d75bbc commit b6f9cc3

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

changelog/2505.fixed.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The `ns` argument of `sys::prctl::set_timerslack()` should be of type `c_ulong`

src/sys/prctl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ pub fn get_name() -> Result<CString> {
166166

167167
/// Sets the timer slack value for the calling thread. Timer slack is used by the kernel to group
168168
/// timer expirations and make them the supplied amount of nanoseconds late.
169-
pub fn set_timerslack(ns: u64) -> Result<()> {
169+
pub fn set_timerslack(ns: c_ulong) -> Result<()> {
170170
let res = unsafe { libc::prctl(libc::PR_SET_TIMERSLACK, ns, 0, 0, 0) };
171171

172172
Errno::result(res).map(drop)

test/sys/test_prctl.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,14 @@ mod test_prctl {
8989
#[cfg_attr(qemu, ignore)]
9090
#[test]
9191
fn test_get_set_timerslack() {
92-
let original = prctl::get_timerslack().unwrap();
92+
let original = prctl::get_timerslack().unwrap() as libc::c_ulong;
9393

9494
let slack = 60_000;
9595
prctl::set_timerslack(slack).unwrap();
96-
let res = prctl::get_timerslack().unwrap();
97-
assert_eq!(slack, res as u64);
96+
let res = prctl::get_timerslack().unwrap() as libc::c_ulong;
97+
assert_eq!(slack, res);
9898

99-
prctl::set_timerslack(original as u64).unwrap();
99+
prctl::set_timerslack(original).unwrap();
100100
}
101101

102102
#[test]

0 commit comments

Comments
 (0)