11use crate :: asid:: Asid ;
2- use crate :: error:: { ensure_ptok , extract_pterr , PtError , PtErrorCode } ;
2+ use crate :: error:: { PtError , PtErrorCode , ensure_ptok , extract_pterr } ;
33use libipt_sys:: {
44 pt_asid, pt_image, pt_image_add_cached, pt_image_add_file, pt_image_alloc, pt_image_copy,
55 pt_image_free, pt_image_name, pt_image_remove_by_asid, pt_image_remove_by_filename,
@@ -23,9 +23,11 @@ unsafe extern "C" fn read_callback(
2323 ip : u64 ,
2424 context : * mut c_void ,
2525) -> i32 {
26- let buffer = std:: slice:: from_raw_parts_mut ( buffer, size) ;
27- let asid = Asid ( * asid) ;
28- BoxedCallback :: call ( context, buffer, ip, asid)
26+ unsafe {
27+ let buffer = std:: slice:: from_raw_parts_mut ( buffer, size) ;
28+ let asid = Asid ( * asid) ;
29+ BoxedCallback :: call ( context, buffer, ip, asid)
30+ }
2931}
3032
3133/// Represent a boxed Rust function that can be passed to and from C code.
@@ -79,9 +81,11 @@ impl BoxedCallback {
7981
8082 /// Invoke the callback behind the given opaque boxed callback pointer.
8183 unsafe fn call ( opaque_cb : * mut c_void , buf : & mut [ u8 ] , size : u64 , asid : Asid ) -> i32 {
82- let raw_boxed_ptr = opaque_cb. cast :: < * mut dyn FnMut ( & mut [ u8 ] , u64 , Asid ) -> i32 > ( ) ;
83- let func = ( * raw_boxed_ptr) . as_mut ( ) . unwrap ( ) ;
84- func ( buf, size, asid)
84+ unsafe {
85+ let raw_boxed_ptr = opaque_cb. cast :: < * mut dyn FnMut ( & mut [ u8 ] , u64 , Asid ) -> i32 > ( ) ;
86+ let func = ( * raw_boxed_ptr) . as_mut ( ) . unwrap ( ) ;
87+ func ( buf, size, asid)
88+ }
8589 }
8690}
8791
0 commit comments