From 977a776a2d24324d3e8825e525f6ce90a63a701c Mon Sep 17 00:00:00 2001 From: Matthew Gregan Date: Mon, 6 Nov 2023 12:21:52 +1300 Subject: [PATCH] Fix build for systems with 32-bit `rlim_t`. --- src/rt_linux.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/rt_linux.rs b/src/rt_linux.rs index dab6a47..9eaaf56 100644 --- a/src/rt_linux.rs +++ b/src/rt_linux.rs @@ -8,6 +8,7 @@ extern crate dbus; extern crate libc; use std::cmp; +use std::convert::TryInto; use std::error::Error; use std::io::Error as OSError; @@ -153,10 +154,15 @@ fn get_limits() -> Result<(i64, u64, libc::rlimit), AudioThreadPriorityError> { fn set_limits(request: u64, max: u64) -> Result<(), AudioThreadPriorityError> { // Set a soft limit to the limit requested, to be able to handle going over the limit using - // SIGXCPU. Set the hard limit to the maxium slice to prevent getting SIGKILL. + // SIGXCPU. Set the hard limit to the maximum slice to prevent getting SIGKILL. + #[allow(clippy::useless_conversion)] let new_limit = libc::rlimit { - rlim_cur: request, - rlim_max: max, + rlim_cur: request + .try_into() + .map_err(|_| AudioThreadPriorityError::new("setrlimit"))?, + rlim_max: max + .try_into() + .map_err(|_| AudioThreadPriorityError::new("setrlimit"))?, }; if unsafe { libc::setrlimit(libc::RLIMIT_RTTIME, &new_limit) } < 0 { return Err(AudioThreadPriorityError::new_with_inner(