From 0cd972326ca4b7ba42d532ae6848449b32529fcb Mon Sep 17 00:00:00 2001 From: adria0 Date: Wed, 29 Jul 2020 10:48:25 +0200 Subject: [PATCH] Fix warnings: mem::uninitialized --- ethash/src/compute.rs | 8 ++++---- ethash/src/shared.rs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ethash/src/compute.rs b/ethash/src/compute.rs index 6e75b4c2a..a668396ea 100644 --- a/ethash/src/compute.rs +++ b/ethash/src/compute.rs @@ -152,7 +152,7 @@ pub fn quick_get_difficulty( // // This cannot be elided by the compiler as it doesn't know the implementation of // `keccak_512`. - let mut buf: [u8; 64 + 32] = mem::uninitialized(); + let mut buf: [u8; 64 + 32] = ::mem::MaybeUninit::uninit().assume_init(); ptr::copy_nonoverlapping(header_hash.as_ptr(), buf.as_mut_ptr(), 32); ptr::copy_nonoverlapping(&nonce as *const u64 as *const u8, buf[32..].as_mut_ptr(), 8); @@ -161,7 +161,7 @@ pub fn quick_get_difficulty( ptr::copy_nonoverlapping(mix_hash.as_ptr(), buf[64..].as_mut_ptr(), 32); // This is initialized in `keccak_256` - let mut hash: [u8; 32] = mem::uninitialized(); + let mut hash: [u8; 32] = ::mem::MaybeUninit::uninit().assume_init(); keccak_256::unchecked(hash.as_mut_ptr(), hash.len(), buf.as_ptr(), buf.len()); hash @@ -219,7 +219,7 @@ fn hash_compute(light: &Light, full_size: usize, header_hash: &H256, nonce: u64) // We explicitly write the first 40 bytes, leaving the last 24 as uninitialized. Then // `keccak_512` reads the first 40 bytes (4th parameter) and overwrites the entire array, // leaving it fully initialized. - let mut out: [u8; NODE_BYTES] = mem::uninitialized(); + let mut out: [u8; NODE_BYTES] = ::mem::MaybeUninit::uninit().assume_init(); ptr::copy_nonoverlapping(header_hash.as_ptr(), out.as_mut_ptr(), header_hash.len()); ptr::copy_nonoverlapping( @@ -239,7 +239,7 @@ fn hash_compute(light: &Light, full_size: usize, header_hash: &H256, nonce: u64) Node { bytes: out } }, // This is fully initialized before being read, see `let mut compress = ...` below - compress_bytes: unsafe { mem::uninitialized() }, + compress_bytes: unsafe { ::mem::MaybeUninit::uninit().assume_init() }, }; let mut mix: [_; MIX_NODES] = [buf.half_mix.clone(), buf.half_mix.clone()]; diff --git a/ethash/src/shared.rs b/ethash/src/shared.rs index 6a5586ada..a3f5144bc 100644 --- a/ethash/src/shared.rs +++ b/ethash/src/shared.rs @@ -82,7 +82,7 @@ macro_rules! static_assert_size_eq { }; (@inner $a:ty, $b:ty) => { unsafe { - let val: $b = ::std::mem::uninitialized(); + let val: $b = ::mem::MaybeUninit::uninit().assume_init(); let _: $a = ::std::mem::transmute(val); } };