From 19e4e821d582b625797b8a17737dfa823a6aca21 Mon Sep 17 00:00:00 2001 From: Aapo Alasuutari Date: Fri, 7 Oct 2022 07:50:18 +0300 Subject: fix(ext/ffi): Fix usize and isize FFI callback parameters missing match arm (#16172) Mea culpa. Back when I re-introduced parameter and return value types to FFI callbacks I failed to properly account for the change in match arm logic. As a result, usize and isize parameters in FFI callbacks currently enter the branch meant for void only. This PR changes the match arms to all be explicit, making sure that void is the only arm marked unreachable and that it stays that way. --- ext/ffi/lib.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/ext/ffi/lib.rs b/ext/ffi/lib.rs index bc3a58209..1f7619f7e 100644 --- a/ext/ffi/lib.rs +++ b/ext/ffi/lib.rs @@ -1495,7 +1495,7 @@ unsafe fn do_ffi_callback( let value = *((*val) as *const u32); v8::Integer::new_from_unsigned(scope, value).into() } - NativeType::I64 => { + NativeType::I64 | NativeType::ISize => { let result = *((*val) as *const i64); if result > MAX_SAFE_INTEGER as i64 || result < MIN_SAFE_INTEGER as i64 { @@ -1504,7 +1504,7 @@ unsafe fn do_ffi_callback( v8::Number::new(scope, result as f64).into() } } - NativeType::U64 => { + NativeType::U64 | NativeType::USize => { let result = *((*val) as *const u64); if result > MAX_SAFE_INTEGER as u64 { v8::BigInt::new_from_u64(scope, result).into() @@ -1520,9 +1520,7 @@ unsafe fn do_ffi_callback( v8::Number::new(scope, result as f64).into() } } - _ => { - unreachable!() - } + NativeType::Void => unreachable!(), }; params.push(value); } -- cgit v1.2.3