Skip to content

Commit

Permalink
windows7: Silence false positive truncation warning.
Browse files Browse the repository at this point in the history
  • Loading branch information
briansmith committed Jun 21, 2024
1 parent 9f7ed67 commit 33051f5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/windows7.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ pub fn getrandom_inner(dest: &mut [MaybeUninit<u8>]) -> 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::<c_void>(), 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::<c_void>(), chunk_len) };
if ret != TRUE {
return Err(Error::WINDOWS_RTL_GEN_RANDOM);
}
Expand Down

0 comments on commit 33051f5

Please sign in to comment.