Skip to content

Commit 11db1ff

Browse files
committed
windows7: Silence false positive truncation warning.
1 parent 677180b commit 11db1ff

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/windows7.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ const TRUE: BOOLEAN = 1u8;
2525

2626
pub fn getrandom_inner(dest: &mut [MaybeUninit<u8>]) -> Result<(), Error> {
2727
// Prevent overflow of u32
28-
for chunk in dest.chunks_mut(u32::max_value() as usize) {
29-
let ret = unsafe { RtlGenRandom(chunk.as_mut_ptr().cast::<c_void>(), chunk.len() as u32) };
28+
for chunk in dest.chunks_mut(u32::MAX as usize) {
29+
#[allow(clippy::cast_possible_truncation)]
30+
let chunk_len = chunk.len() as u32;
31+
let ret = unsafe { RtlGenRandom(chunk.as_mut_ptr().cast::<c_void>(), chunk_len) };
3032
if ret != TRUE {
3133
return Err(Error::WINDOWS_RTL_GEN_RANDOM);
3234
}

0 commit comments

Comments
 (0)