Reworking bssl_crypto: make with_output_array_fallible use a bool. This function took a `c_int` and checked that it was 1. But since `initialized_struct_fallible` now expects a bool, this should too. Change-Id: Ice7997c0847299f42fbc71fcc7b29acb66014bde Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/65547 Reviewed-by: Bob Beck <bbe@google.com>
diff --git a/rust/bssl-crypto/src/lib.rs b/rust/bssl-crypto/src/lib.rs index 21a2725..38096c3 100644 --- a/rust/bssl-crypto/src/lib.rs +++ b/rust/bssl-crypto/src/lib.rs
@@ -311,7 +311,7 @@ /// Safety: the closure must fully initialize the array if it returns one. unsafe fn with_output_array_fallible<const N: usize, F>(func: F) -> Option<[u8; N]> where - F: FnOnce(*mut u8, usize) -> core::ffi::c_int, + F: FnOnce(*mut u8, usize) -> bool, { let mut out_uninit = core::mem::MaybeUninit::<[u8; N]>::uninit(); let out_ptr = if N != 0 { @@ -319,7 +319,7 @@ } else { core::ptr::null_mut() }; - if func(out_ptr, N) == 1 { + if func(out_ptr, N) { // Safety: `func` promises to fill all of `out_uninit` if it returns one. unsafe { Some(out_uninit.assume_init()) } } else {
diff --git a/rust/bssl-crypto/src/x25519.rs b/rust/bssl-crypto/src/x25519.rs index b91af54..26030b1 100644 --- a/rust/bssl-crypto/src/x25519.rs +++ b/rust/bssl-crypto/src/x25519.rs
@@ -76,7 +76,7 @@ // Safety: `X25519` indeed writes `SHARED_KEY_LEN` bytes. unsafe { with_output_array_fallible(|out, _| { - bssl_sys::X25519(out, self.0.as_ffi_ptr(), other_public_key.as_ffi_ptr()) + bssl_sys::X25519(out, self.0.as_ffi_ptr(), other_public_key.as_ffi_ptr()) == 1 }) } }