Skip to content

Commit 9e79890

Browse files
committed
windows7: Silence false positive truncation warning.
1 parent bad2d36 commit 9e79890

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/windows7.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,14 @@ 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+
let ret = unsafe {
30+
RtlGenRandom(
31+
chunk.as_mut_ptr().cast::<c_void>(),
32+
#[allow(clippy::cast_possible_truncation)]
33+
chunk.len() as u32,
34+
)
35+
};
3036
if ret != TRUE {
3137
return Err(Error::WINDOWS_RTL_GEN_RANDOM);
3238
}

0 commit comments

Comments
 (0)