Appease `static_mut_refs`

Made stricter in https://github.com/rust-lang/rust/commit/5ba6db1b648d9.
reviewable/pr921/r23
Tamir Duberstein 4 months ago
parent 48ca623a1f
commit 5b29008691

@ -22,7 +22,7 @@ static CPUS: CpuMap = CpuMap::with_max_entries(1, 0);
/// counts how many times the map programs got executed. /// counts how many times the map programs got executed.
/// This allows the test harness to assert that a specific step got executed. /// This allows the test harness to assert that a specific step got executed.
#[map] #[map]
static mut HITS: Array<u32> = Array::with_max_entries(2, 0); static HITS: Array<u32> = Array::with_max_entries(2, 0);
#[xdp] #[xdp]
pub fn redirect_sock(_ctx: XdpContext) -> u32 { pub fn redirect_sock(_ctx: XdpContext) -> u32 {
@ -61,7 +61,7 @@ pub fn redirect_dev_chain(_ctx: XdpContext) -> u32 {
#[inline(always)] #[inline(always)]
fn inc_hit(index: u32) { fn inc_hit(index: u32) {
if let Some(hit) = unsafe { HITS.get_ptr_mut(index) } { if let Some(hit) = HITS.get_ptr_mut(index) {
unsafe { *hit += 1 }; unsafe { *hit += 1 };
} }
} }

@ -10,7 +10,7 @@ use aya_ebpf::{
}; };
#[map] #[map]
static mut RESULTS: Array<u64> = Array::with_max_entries(3, 0); static RESULTS: Array<u64> = Array::with_max_entries(3, 0);
#[uprobe] #[uprobe]
pub fn test_64_32_call_relocs(_ctx: ProbeContext) { pub fn test_64_32_call_relocs(_ctx: ProbeContext) {

@ -53,6 +53,9 @@ fn use_map_with_rbpf() {
// so we keeps the pointers to our maps in MULTIMAP_MAPS, to be used in helpers. // so we keeps the pointers to our maps in MULTIMAP_MAPS, to be used in helpers.
let mut maps = HashMap::new(); let mut maps = HashMap::new();
let mut map_instances = vec![vec![0u64], vec![0u64], vec![0u64]]; let mut map_instances = vec![vec![0u64], vec![0u64], vec![0u64]];
unsafe {
MULTIMAP_MAPS = [null_mut(); 3];
}
for (name, map) in object.maps.iter() { for (name, map) in object.maps.iter() {
assert_eq!(map.key_size(), size_of::<u32>() as u32); assert_eq!(map.key_size(), size_of::<u32>() as u32);
assert_eq!(map.value_size(), size_of::<u64>() as u32); assert_eq!(map.value_size(), size_of::<u64>() as u32);
@ -110,10 +113,6 @@ fn use_map_with_rbpf() {
assert_eq!(vm.execute_program().unwrap(), 0); assert_eq!(vm.execute_program().unwrap(), 0);
assert_eq!(map_instances, [[24], [42], [44]]); assert_eq!(map_instances, [[24], [42], [44]]);
unsafe {
MULTIMAP_MAPS.iter_mut().for_each(|v| *v = null_mut());
}
} }
#[track_caller] #[track_caller]

Loading…
Cancel
Save