From b4c7fa0d4e0f679ce3afa9272cd8bf40350b4467 Mon Sep 17 00:00:00 2001 From: Tobin Harding Date: Thu, 24 Mar 2022 14:30:57 +1100 Subject: [PATCH] Let the compiler work out int size We have two places in the code where we pass a mutable parity integer to ffi code. At one callsite we tell the compiler explicitly what type it is (`::secp256k1_sys::types::c_int`) and at the other call site we let the compiler figure out the type. Is one way better than the other? I don't know. But letting the compiler figure it out seems to make the code easier to read. --- src/key.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/key.rs b/src/key.rs index 9b1a84b..79b76d5 100644 --- a/src/key.rs +++ b/src/key.rs @@ -1111,6 +1111,7 @@ impl XOnlyPublicKey { return Err(Error::InvalidTweak); } + let mut pk_parity = 0; unsafe { let mut pubkey = ffi::PublicKey::new(); let mut err = ffi::secp256k1_xonly_pubkey_tweak_add( @@ -1123,18 +1124,17 @@ impl XOnlyPublicKey { return Err(Error::InvalidTweak); } - let mut parity: ::secp256k1_sys::types::c_int = 0; err = ffi::secp256k1_xonly_pubkey_from_pubkey( secp.ctx, &mut self.0, - &mut parity, + &mut pk_parity, &pubkey, ); if err == 0 { return Err(Error::InvalidPublicKey); } - Parity::from_i32(parity).map_err(Into::into) + Parity::from_i32(pk_parity).map_err(Into::into) } }