From 33051f56b2c0a70341e0d8984eaedcec7253572c Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Sun, 2 Jun 2024 12:09:44 -0700 Subject: [PATCH] windows7: Silence false positive truncation warning. --- src/windows7.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/windows7.rs b/src/windows7.rs index 6714f66b..3a9a1f90 100644 --- a/src/windows7.rs +++ b/src/windows7.rs @@ -27,7 +27,9 @@ pub fn getrandom_inner(dest: &mut [MaybeUninit]) -> Result<(), Error> { // Prevent overflow of u32 let chunk_size = usize::try_from(i32::MAX).expect("Windows does not support 16-bit targets"); for chunk in dest.chunks_mut(chunk_size) { - let ret = unsafe { RtlGenRandom(chunk.as_mut_ptr().cast::(), chunk.len() as u32) }; + #[allow(clippy::cast_possible_truncation)] + let chunk_len = chunk.len() as u32; + let ret = unsafe { RtlGenRandom(chunk.as_mut_ptr().cast::(), chunk_len) }; if ret != TRUE { return Err(Error::WINDOWS_RTL_GEN_RANDOM); }