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.
This commit is contained in:
Tobin Harding 2022-03-24 14:30:57 +11:00
parent c612130864
commit b4c7fa0d4e
1 changed files with 3 additions and 3 deletions

View File

@ -1111,6 +1111,7 @@ impl XOnlyPublicKey {
return Err(Error::InvalidTweak); return Err(Error::InvalidTweak);
} }
let mut pk_parity = 0;
unsafe { unsafe {
let mut pubkey = ffi::PublicKey::new(); let mut pubkey = ffi::PublicKey::new();
let mut err = ffi::secp256k1_xonly_pubkey_tweak_add( let mut err = ffi::secp256k1_xonly_pubkey_tweak_add(
@ -1123,18 +1124,17 @@ impl XOnlyPublicKey {
return Err(Error::InvalidTweak); return Err(Error::InvalidTweak);
} }
let mut parity: ::secp256k1_sys::types::c_int = 0;
err = ffi::secp256k1_xonly_pubkey_from_pubkey( err = ffi::secp256k1_xonly_pubkey_from_pubkey(
secp.ctx, secp.ctx,
&mut self.0, &mut self.0,
&mut parity, &mut pk_parity,
&pubkey, &pubkey,
); );
if err == 0 { if err == 0 {
return Err(Error::InvalidPublicKey); return Err(Error::InvalidPublicKey);
} }
Parity::from_i32(parity).map_err(Into::into) Parity::from_i32(pk_parity).map_err(Into::into)
} }
} }