Skip to content

Commit 3ab3beb

Browse files
fix(ffi): use .cast() instead of as cast for raw pointer conversion
Replace 'as *mut u8' casts with .cast::<u8>() method to fix clippy warnings about unnecessary casts on ARM architectures. On ARM, c_char is u8, making the explicit cast unnecessary. Using .cast::<u8>() is the modern Rust approach and avoids clippy warnings while maintaining platform compatibility.
1 parent 69741e7 commit 3ab3beb

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

key-wallet-ffi/src/derivation.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ pub extern "C" fn derivation_bip44_account_path(
131131
}
132132

133133
unsafe {
134-
ptr::copy_nonoverlapping(bytes.as_ptr(), path_out as *mut u8, bytes.len());
134+
ptr::copy_nonoverlapping(bytes.as_ptr(), path_out.cast::<u8>(), bytes.len());
135135
}
136136

137137
FFIError::set_success(error);
@@ -189,7 +189,7 @@ pub extern "C" fn derivation_bip44_payment_path(
189189
}
190190

191191
unsafe {
192-
ptr::copy_nonoverlapping(bytes.as_ptr(), path_out as *mut u8, bytes.len());
192+
ptr::copy_nonoverlapping(bytes.as_ptr(), path_out.cast::<u8>(), bytes.len());
193193
}
194194

195195
FFIError::set_success(error);
@@ -244,7 +244,7 @@ pub extern "C" fn derivation_coinjoin_path(
244244
}
245245

246246
unsafe {
247-
ptr::copy_nonoverlapping(bytes.as_ptr(), path_out as *mut u8, bytes.len());
247+
ptr::copy_nonoverlapping(bytes.as_ptr(), path_out.cast::<u8>(), bytes.len());
248248
}
249249

250250
FFIError::set_success(error);
@@ -299,7 +299,7 @@ pub extern "C" fn derivation_identity_registration_path(
299299
}
300300

301301
unsafe {
302-
ptr::copy_nonoverlapping(bytes.as_ptr(), path_out as *mut u8, bytes.len());
302+
ptr::copy_nonoverlapping(bytes.as_ptr(), path_out.cast::<u8>(), bytes.len());
303303
}
304304

305305
FFIError::set_success(error);
@@ -356,7 +356,7 @@ pub extern "C" fn derivation_identity_topup_path(
356356
}
357357

358358
unsafe {
359-
ptr::copy_nonoverlapping(bytes.as_ptr(), path_out as *mut u8, bytes.len());
359+
ptr::copy_nonoverlapping(bytes.as_ptr(), path_out.cast::<u8>(), bytes.len());
360360
}
361361

362362
FFIError::set_success(error);
@@ -417,7 +417,7 @@ pub extern "C" fn derivation_identity_authentication_path(
417417
}
418418

419419
unsafe {
420-
ptr::copy_nonoverlapping(bytes.as_ptr(), path_out as *mut u8, bytes.len());
420+
ptr::copy_nonoverlapping(bytes.as_ptr(), path_out.cast::<u8>(), bytes.len());
421421
}
422422

423423
FFIError::set_success(error);

0 commit comments

Comments
 (0)