Skip to content

Commit 33051f5

Browse files
committed
windows7: Silence false positive truncation warning.
1 parent 9f7ed67 commit 33051f5

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/windows7.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ pub fn getrandom_inner(dest: &mut [MaybeUninit<u8>]) -> Result<(), Error> {
2727
// Prevent overflow of u32
2828
let chunk_size = usize::try_from(i32::MAX).expect("Windows does not support 16-bit targets");
2929
for chunk in dest.chunks_mut(chunk_size) {
30-
let ret = unsafe { RtlGenRandom(chunk.as_mut_ptr().cast::<c_void>(), chunk.len() as u32) };
30+
#[allow(clippy::cast_possible_truncation)]
31+
let chunk_len = chunk.len() as u32;
32+
let ret = unsafe { RtlGenRandom(chunk.as_mut_ptr().cast::<c_void>(), chunk_len) };
3133
if ret != TRUE {
3234
return Err(Error::WINDOWS_RTL_GEN_RANDOM);
3335
}

0 commit comments

Comments
 (0)