Apply suggestions from code review

Co-authored-by: Alessandro Decina <alessandro.d@gmail.com>
pull/14/head
Rafael Ortiz 4 years ago committed by GitHub
parent 44baee9c19
commit a3d968c599
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -57,8 +57,8 @@ pub(crate) struct bpf_map_def {
pub(crate) max_entries: u32, pub(crate) max_entries: u32,
pub(crate) map_flags: u32, pub(crate) map_flags: u32,
// optional features // optional features
pub(crate) id: u32, // id pub(crate) id: u32,
pub(crate) pinning: u32, // pinning pub(crate) pinning: u32,
} }
/// The main entry point into the library, used to work with eBPF programs and maps. /// The main entry point into the library, used to work with eBPF programs and maps.

@ -516,7 +516,7 @@ fn parse_map_def(name: &str, data: &[u8]) -> Result<bpf_map_def, ParseError> {
} }
if data.len() < mem::size_of::<bpf_map_def>() { if data.len() < mem::size_of::<bpf_map_def>() {
let mut map_def = bpf_map_def { ..Default::default() }; let mut map_def = bpf_map_def::default();
unsafe { unsafe {
ptr::copy(data.as_ptr() as *const bpf_map_def, &mut map_def as *mut bpf_map_def, 1); ptr::copy(data.as_ptr() as *const bpf_map_def, &mut map_def as *mut bpf_map_def, 1);
// id and pinning will be garbage data // id and pinning will be garbage data

Loading…
Cancel
Save