From c9e70a8758ef10cfe1970e5f7a1e830e0ba5ec8e Mon Sep 17 00:00:00 2001 From: Dave Tucker Date: Wed, 27 Jul 2022 14:36:32 +0000 Subject: [PATCH] aya: Fix rlimit warning on for 32bit systems Signed-off-by: Dave Tucker --- aya/src/maps/mod.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/aya/src/maps/mod.rs b/aya/src/maps/mod.rs index 8e390681..e0e8d066 100644 --- a/aya/src/maps/mod.rs +++ b/aya/src/maps/mod.rs @@ -33,7 +33,7 @@ //! versa. Because of that, all map values must be plain old data and therefore //! implement the [Pod] trait. use std::{ - convert::TryFrom, + convert::{TryFrom, TryInto}, ffi::CString, fmt, io, marker::PhantomData, @@ -226,7 +226,7 @@ impl AsRawFd for MapFd { } #[derive(PartialEq, Eq, PartialOrd, Ord)] -struct RlimitSize(u64); +struct RlimitSize(usize); impl fmt::Display for RlimitSize { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { if self.0 < 1024 { @@ -246,8 +246,9 @@ fn maybe_warn_rlimit() { let ret = unsafe { getrlimit(RLIMIT_MEMLOCK, limit.as_mut_ptr()) }; if ret == 0 { let limit = unsafe { limit.assume_init() }; - let limit: RlimitSize = RlimitSize(limit.rlim_cur); - if limit.0 == RLIM_INFINITY { + + let limit: RlimitSize = RlimitSize(limit.rlim_cur.try_into().unwrap()); + if limit.0 == RLIM_INFINITY.try_into().unwrap() { return; } warn!(