merge safe block and address typo

pull/608/head
Andrés Medina 2 years ago
parent c825ad4065
commit b411c5e7c3

@ -712,10 +712,13 @@ impl BtfExt {
// BTF.ext sections // BTF.ext sections
let mut header = std::mem::MaybeUninit::<btf_ext_header>::zeroed(); let mut header = std::mem::MaybeUninit::<btf_ext_header>::zeroed();
// Safety: we have checked that len_to_read is less than // Safety: we have checked that len_to_read is less than
// size_of::<btf_ext_header> and less than data.len() // size_of::<btf_ext_header> and less than
unsafe { std::ptr::copy(data.as_ptr(), header.as_mut_ptr() as *mut u8, len_to_read) }; // data.len(). Additionally, we know that the header has
// Safety: the header began initialized to zero (and we rewrote some of its initla bytes) // been initialized so it's safe to call for assume_init.
unsafe { header.assume_init() } unsafe {
std::ptr::copy(data.as_ptr(), header.as_mut_ptr() as *mut u8, len_to_read);
header.assume_init()
}
}; };
let btf_ext_header { let btf_ext_header {

Loading…
Cancel
Save