Skip to content

Commit

Permalink
avoid two unsafe {} blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxVerevkin committed Jul 17, 2023
1 parent 8d3a7b1 commit 8bff059
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/netlink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,9 @@ impl InterfaceStats {
// // the rest is omitted
// }
assert!(stats.len() >= 8 * 4);
let stats = stats.as_ptr() as *const u64;
Self {
rx_bytes: unsafe { stats.add(2).read_unaligned() },
tx_bytes: unsafe { stats.add(3).read_unaligned() },
rx_bytes: u64::from_ne_bytes(stats[16..24].try_into().unwrap()),
tx_bytes: u64::from_ne_bytes(stats[24..32].try_into().unwrap()),
}
}
}
Expand Down

0 comments on commit 8bff059

Please sign in to comment.