Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update azure to use latest, fix warnings #66

Merged
merged 5 commits into from
Mar 25, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ variables:
jobs:
- job: linux
pool:
vmImage: ubuntu-16.04
vmImage: ubuntu-latest
strategy:
matrix:
stable:
Expand All @@ -52,7 +52,7 @@ jobs:
displayName: Test
- job: macos
pool:
vmImage: macos-10.14
vmImage: macos-latest
strategy:
matrix:
stable:
Expand All @@ -73,7 +73,7 @@ jobs:
displayName: Test
- job: windows
pool:
vmImage: windows-2019
vmImage: windows-latest
strategy:
matrix:
stable:
Expand Down
2 changes: 1 addition & 1 deletion src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,4 @@ pub const GENERATOR_PUB_J_RAW : [u8;64] = [
0xfc, 0x56, 0xcf, 0x74, 0x9a, 0xa6, 0xa5, 0x65,
0x31, 0x6a, 0xa5, 0x03, 0x74, 0x42, 0x3f, 0x42,
0x53, 0x8f, 0xaa, 0x2c, 0xd3, 0x09, 0x3f, 0xa4
];
];
10 changes: 5 additions & 5 deletions src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ impl PublicKey {
/// Create a new (zeroed) public key usable for the FFI interface
pub fn new() -> PublicKey { PublicKey([0; 64]) }
/// Create a new (uninitialized) public key usable for the FFI interface
pub unsafe fn blank() -> PublicKey { mem::uninitialized() }
pub unsafe fn blank() -> PublicKey { mem::MaybeUninit::uninit().assume_init() }
}

/// Library-internal representation of a Secp256k1 signature
Expand Down Expand Up @@ -114,21 +114,21 @@ impl Signature {
/// Create a signature from raw data
pub fn from_data(data: [u8; 64]) -> Signature { Signature(data) }
/// Create a new (uninitialized) signature usable for the FFI interface
pub unsafe fn blank() -> Signature { mem::uninitialized() }
pub unsafe fn blank() -> Signature { mem::MaybeUninit::uninit().assume_init() }
}

impl RecoverableSignature {
/// Create a new (zeroed) signature usable for the FFI interface
pub fn new() -> RecoverableSignature { RecoverableSignature([0; 65]) }
/// Create a new (uninitialized) signature usable for the FFI interface
pub unsafe fn blank() -> RecoverableSignature { mem::uninitialized() }
pub unsafe fn blank() -> RecoverableSignature { mem::MaybeUninit::uninit().assume_init() }
}

impl AggSigPartialSignature {
/// Create a new (zeroed) aggsig partial signature usable for the FFI interface
pub fn new() -> AggSigPartialSignature { AggSigPartialSignature([0; 32]) }
/// Create a new (uninitialized) signature usable for the FFI interface
pub unsafe fn blank() -> AggSigPartialSignature { mem::uninitialized() }
pub unsafe fn blank() -> AggSigPartialSignature { mem::MaybeUninit::uninit().assume_init() }
}

/// Library-internal representation of an ECDH shared secret
Expand All @@ -141,7 +141,7 @@ impl SharedSecret {
/// Create a new (zeroed) signature usable for the FFI interface
pub fn new() -> SharedSecret { SharedSecret([0; 32]) }
/// Create a new (uninitialized) signature usable for the FFI interface
pub unsafe fn blank() -> SharedSecret { mem::uninitialized() }
pub unsafe fn blank() -> SharedSecret { mem::MaybeUninit::uninit().assume_init() }
}


Expand Down
6 changes: 3 additions & 3 deletions src/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ impl Decodable for PublicKey {
if len == constants::UNCOMPRESSED_PUBLIC_KEY_SIZE {
unsafe {
use std::mem;
let mut ret: [u8; constants::UNCOMPRESSED_PUBLIC_KEY_SIZE] = mem::uninitialized();
let mut ret: [u8; constants::UNCOMPRESSED_PUBLIC_KEY_SIZE] = mem::MaybeUninit::uninit().assume_init();
for i in 0..len {
ret[i] = d.read_seq_elt(i, |d| Decodable::decode(d))?;
}
Expand All @@ -304,7 +304,7 @@ impl Decodable for PublicKey {
} else if len == constants::COMPRESSED_PUBLIC_KEY_SIZE {
unsafe {
use std::mem;
let mut ret: [u8; constants::COMPRESSED_PUBLIC_KEY_SIZE] = mem::uninitialized();
let mut ret: [u8; constants::COMPRESSED_PUBLIC_KEY_SIZE] = mem::MaybeUninit::uninit().assume_init();
for i in 0..len {
ret[i] = d.read_seq_elt(i, |d| Decodable::decode(d))?;
}
Expand Down Expand Up @@ -353,7 +353,7 @@ impl<'de> Deserialize<'de> for PublicKey {
let s = Secp256k1::with_caps(crate::ContextFlag::None);
unsafe {
use std::mem;
let mut ret: [u8; constants::UNCOMPRESSED_PUBLIC_KEY_SIZE] = mem::uninitialized();
let mut ret: [u8; constants::UNCOMPRESSED_PUBLIC_KEY_SIZE] = mem::MaybeUninit::uninit().assume_init();

let mut read_len = 0;
while read_len < constants::UNCOMPRESSED_PUBLIC_KEY_SIZE {
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ impl<'de> serde::Deserialize<'de> for Signature {
let s = Secp256k1::with_caps(crate::ContextFlag::None);
unsafe {
use std::mem;
let mut ret: [u8; constants::COMPACT_SIGNATURE_SIZE] = mem::uninitialized();
let mut ret: [u8; constants::COMPACT_SIGNATURE_SIZE] = mem::MaybeUninit::uninit().assume_init();

for i in 0..constants::COMPACT_SIGNATURE_SIZE {
ret[i] = match a.next_element()? {
Expand Down Expand Up @@ -485,7 +485,7 @@ impl fmt::Display for Error {
}

impl error::Error for Error {
fn cause(&self) -> Option<&error::Error> { None }
fn cause(&self) -> Option<&dyn error::Error> { None }

fn description(&self) -> &str {
match *self {
Expand Down
6 changes: 3 additions & 3 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ macro_rules! impl_array_newtype {
unsafe {
use std::ptr::copy_nonoverlapping;
use std::mem;
let mut ret: $thing = mem::uninitialized();
let mut ret: $thing = mem::MaybeUninit::uninit().assume_init();
copy_nonoverlapping(self.as_ptr(),
ret.as_mut_ptr(),
mem::size_of::<$thing>());
Expand Down Expand Up @@ -153,7 +153,7 @@ macro_rules! impl_array_newtype {
} else {
unsafe {
use std::mem;
let mut ret: [$ty; $len] = mem::uninitialized();
let mut ret: [$ty; $len] = mem::MaybeUninit::uninit().assume_init();
for i in 0..len {
ret[i] = d.read_seq_elt(i, |d| Decodable::decode(d))?;
}
Expand Down Expand Up @@ -190,7 +190,7 @@ macro_rules! impl_array_newtype {
{
unsafe {
use std::mem;
let mut ret: [$ty; $len] = mem::uninitialized();
let mut ret: [$ty; $len] = mem::MaybeUninit::uninit().assume_init();
for i in 0..$len {
ret[i] = match a.next_element()? {
Some(c) => c,
Expand Down
16 changes: 8 additions & 8 deletions src/pedersen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ impl_pretty_debug!(CommitmentInternal);
impl CommitmentInternal {
/// Uninitialized commitment, use with caution
pub unsafe fn blank() -> CommitmentInternal {
mem::uninitialized()
mem::MaybeUninit::uninit().assume_init()
}
}

Expand All @@ -92,7 +92,7 @@ impl Commitment {

/// Uninitialized commitment, use with caution
unsafe fn blank() -> Commitment {
mem::uninitialized()
mem::MaybeUninit::uninit().assume_init()
}

/// Converts a commitment to a public key
Expand Down Expand Up @@ -129,7 +129,7 @@ impl Clone for RangeProof {
fn clone(&self) -> RangeProof {
unsafe {
use std::ptr::copy_nonoverlapping;
let mut ret: [u8; constants::MAX_PROOF_SIZE] = mem::uninitialized();
let mut ret: [u8; constants::MAX_PROOF_SIZE] = mem::MaybeUninit::uninit().assume_init();
copy_nonoverlapping(
self.proof.as_ptr(),
ret.as_mut_ptr(),
Expand Down Expand Up @@ -167,7 +167,7 @@ impl<'di> de::Visitor<'di> for Visitor {
V: de::SeqAccess<'di>,
{
unsafe {
let mut ret: [u8; constants::MAX_PROOF_SIZE] = mem::uninitialized();
let mut ret: [u8; constants::MAX_PROOF_SIZE] = mem::MaybeUninit::uninit().assume_init();
let mut i = 0;
while let Some(val) = v.next_element()? {
ret[i] = val;
Expand Down Expand Up @@ -511,7 +511,7 @@ impl Secp256k1 {
let mut neg = map_vec!(negative, |n| n.as_ptr());
let mut all = map_vec!(positive, |p| p.as_ptr());
all.append(&mut neg);
let mut ret: [u8; 32] = unsafe { mem::uninitialized() };
let mut ret: [u8; 32] = unsafe { mem::MaybeUninit::uninit().assume_init() };
unsafe {
assert_eq!(
ffi::secp256k1_pedersen_blind_sum(
Expand All @@ -533,7 +533,7 @@ impl Secp256k1 {
if self.caps != ContextFlag::Commit {
return Err(Error::IncapableContext);
}
let mut ret: [u8; 32] = unsafe { mem::uninitialized() };
let mut ret: [u8; 32] = unsafe { mem::MaybeUninit::uninit().assume_init() };
unsafe {
assert_eq!(
ffi::secp256k1_blind_switch(
Expand Down Expand Up @@ -664,8 +664,8 @@ impl Secp256k1 {
nonce: SecretKey,
) -> ProofInfo {
let mut value: u64 = 0;
let mut blind: [u8; 32] = unsafe { mem::uninitialized() };
let mut message: [u8; constants::PROOF_MSG_SIZE] = unsafe { mem::uninitialized() };
let mut blind: [u8; 32] = unsafe { mem::MaybeUninit::uninit().assume_init() };
let mut message: [u8; constants::PROOF_MSG_SIZE] = unsafe { mem::MaybeUninit::uninit().assume_init() };
let mut mlen: usize = constants::PROOF_MSG_SIZE;
let mut min: u64 = 0;
let mut max: u64 = 0;
Expand Down