From 0897e5f4ece1fdc24920be89c6980f416fceb3a5 Mon Sep 17 00:00:00 2001 From: tsailin Date: Mon, 4 Mar 2024 14:39:56 +0800 Subject: [PATCH] FiX alignment checks https://github.com/rust-lang/rust/pull/98112 alignment checks for pointer dereferences when debug assertions are enabled, so use std::mem::transmute instead --- rsbinder/src/binder_object.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rsbinder/src/binder_object.rs b/rsbinder/src/binder_object.rs index a33c495..6f3fc44 100644 --- a/rsbinder/src/binder_object.rs +++ b/rsbinder/src/binder_object.rs @@ -173,13 +173,13 @@ impl From<&SIBinder> for flat_binder_object { impl From<(*const u8, usize)> for &flat_binder_object { fn from(pointer: (*const u8, usize)) -> Self { - unsafe { & *(pointer.0.add(pointer.1) as *const flat_binder_object) } + unsafe { std::mem::transmute::<*const u8, &flat_binder_object>(&*(pointer.0.add(pointer.1))) } } } impl From<(*mut u8, usize)> for &mut flat_binder_object { fn from(pointer: (*mut u8, usize)) -> Self { - unsafe { &mut *(pointer.0.add(pointer.1) as *mut flat_binder_object) } + unsafe { std::mem::transmute::<*const u8, &mut flat_binder_object>(&*(pointer.0.add(pointer.1))) } } }