Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correct arg type of prctl::set_timerslack #2505

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/2505.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The `ns` argument of `sys::prctl::set_timerslack()` should be of type `c_ulong`
2 changes: 1 addition & 1 deletion src/sys/prctl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ pub fn get_name() -> Result<CString> {

/// 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)
Expand Down
8 changes: 4 additions & 4 deletions test/sys/test_prctl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down