From 6a6a36022b4c7e2977efbc2611065310da2b5d60 Mon Sep 17 00:00:00 2001 From: Dylan Reid Date: Thu, 7 Mar 2019 14:48:58 -0800 Subject: sys_util: poll: Make clippy clean u64 casts switched to from, add a Default impl. Signed-off-by: Dylan Reid Change-Id: I17757a081d41df465c74c7a6b410159b4023c70e Reviewed-on: https://chromium-review.googlesource.com/1510068 Tested-by: kokoro Reviewed-by: Stephen Barber --- sys_util/src/poll.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'sys_util/src/poll.rs') diff --git a/sys_util/src/poll.rs b/sys_util/src/poll.rs index 7d8432a..f8dcfe1 100644 --- a/sys_util/src/poll.rs +++ b/sys_util/src/poll.rs @@ -34,6 +34,12 @@ impl EpollEvents { } } +impl Default for EpollEvents { + fn default() -> EpollEvents { + Self::new() + } +} + /// Trait for a token that can be associated with an `fd` in a `PollContext`. /// /// Simple enums that have no or primitive variant data data can use the `#[derive(PollToken)]` @@ -73,7 +79,7 @@ impl PollToken for u64 { impl PollToken for u32 { fn as_raw_token(&self) -> u64 { - *self as u64 + u64::from(*self) } fn from_raw_token(data: u64) -> Self { @@ -83,7 +89,7 @@ impl PollToken for u32 { impl PollToken for u16 { fn as_raw_token(&self) -> u64 { - *self as u64 + u64::from(*self) } fn from_raw_token(data: u64) -> Self { @@ -93,7 +99,7 @@ impl PollToken for u16 { impl PollToken for u8 { fn as_raw_token(&self) -> u64 { - *self as u64 + u64::from(*self) } fn from_raw_token(data: u64) -> Self { @@ -180,7 +186,7 @@ impl<'a, T: PollToken> PollEvents<'a, T> { /// Iterates over each event. pub fn iter(&self) -> PollEventIter, T> { PollEventIter { - mask: 0xffffffff, + mask: 0xffff_ffff, iter: self.events[..self.count].iter(), tokens: PhantomData, } @@ -394,7 +400,7 @@ impl EpollContext { let millis = timeout .as_secs() .checked_mul(1_000) - .and_then(|ms| ms.checked_add(timeout.subsec_nanos() as u64 / 1_000_000)) + .and_then(|ms| ms.checked_add(u64::from(timeout.subsec_nanos()) / 1_000_000)) .unwrap_or(i32::max_value() as u64); min(i32::max_value() as u64, millis) as i32 }; -- cgit 1.4.1