here redbpf get the &mut from the *mut, we don't know if kernel init the memory with zero or not, but in rust, memory filled with zero should not be seems as initialize
and the as_mut also says
If the value may be uninitialized, as_uninit_mut must be used instead.
in rust, we can't get the
&mut
from a pointer*mut
, even it is not nullhttps://github.com/foniod/redbpf/blob/eed2cdc62c08633d83215af696445ec91f30649b/redbpf-probes/src/ringbuf.rs#L167=
here redbpf get the
&mut
from the*mut
, we don't know if kernel init the memory with zero or not, but in rust, memory filled with zero should not be seems as initializeand the
as_mut
also saysI recommand return the ptr directly and remove the unsafe mark, user who want to use it to init field should use https://doc.rust-lang.org/core/ptr/macro.addr_of_mut.html and use
ptr::write
to init field