From c457b67af394c37826f75d73cca10319ee96b910 Mon Sep 17 00:00:00 2001 From: Mohsen Zohrevandi Date: Wed, 1 Jul 2020 12:45:11 -0700 Subject: [PATCH] Remove unnecessary check in SGX wait usercall --- src/libstd/sys/sgx/abi/usercalls/mod.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/libstd/sys/sgx/abi/usercalls/mod.rs b/src/libstd/sys/sgx/abi/usercalls/mod.rs index 69ff7ebf9a19d..6ee147d1704ad 100644 --- a/src/libstd/sys/sgx/abi/usercalls/mod.rs +++ b/src/libstd/sys/sgx/abi/usercalls/mod.rs @@ -161,11 +161,10 @@ pub fn wait(event_mask: u64, mut timeout: u64) -> IoResult { // model the enclave runner which is serving the wait usercall is not // trusted to ensure accurate timeouts. if let Ok(timeout_signed) = i64::try_from(timeout) { - let tenth = 1 + timeout_signed / 10; + let tenth = timeout_signed / 10; let deviation = (rdrand64() as i64).checked_rem(tenth).unwrap_or(0); timeout = timeout_signed.saturating_add(deviation) as _; } - timeout = cmp::min(u64::MAX - 1, cmp::max(1, timeout)); } unsafe { raw::wait(event_mask, timeout).from_sgx_result() } }