From ab3884c76390d2ec1264094127926e92e350d116 Mon Sep 17 00:00:00 2001 From: enricobuehler Date: Sat, 25 Jul 2026 13:19:31 +0200 Subject: [PATCH] fix(core/abi): cast identity PEM pointers with .cast(), not `as *mut u8` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `c_char` is i8 on x86_64 and u8 on aarch64, so `cert_pem_out as *mut u8` is a REQUIRED conversion on one target and a no-op on the other — where clippy::unnecessary_cast then denies it. `.cast::()` is correct and lint-clean on both. Caught by the new aarch64 clippy leg on its first run. A sweep of the remaining `as *mut u8` / `as *const u8` sites in the client crates found no other c_char-derived casts; the rest convert from c_void or u16. Co-Authored-By: Claude Opus 5 (1M context) --- crates/punktfunk-core/src/abi.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/punktfunk-core/src/abi.rs b/crates/punktfunk-core/src/abi.rs index 9e15751e..09e72f00 100644 --- a/crates/punktfunk-core/src/abi.rs +++ b/crates/punktfunk-core/src/abi.rs @@ -1813,9 +1813,11 @@ pub unsafe extern "C" fn punktfunk_generate_identity( return PunktfunkStatus::InvalidArg; } unsafe { - std::ptr::copy_nonoverlapping(cert.as_ptr(), cert_pem_out as *mut u8, cert.len()); + // `.cast()`, not `as *mut u8`: `c_char` is i8 on x86_64 but u8 on aarch64, so the + // `as` form is a REQUIRED conversion on one and a no-op clippy rejects on the other. + std::ptr::copy_nonoverlapping(cert.as_ptr(), cert_pem_out.cast::(), cert.len()); *cert_pem_out.add(cert.len()) = 0; - std::ptr::copy_nonoverlapping(key.as_ptr(), key_pem_out as *mut u8, key.len()); + std::ptr::copy_nonoverlapping(key.as_ptr(), key_pem_out.cast::(), key.len()); *key_pem_out.add(key.len()) = 0; } PunktfunkStatus::Ok