From 5b2900869112990eb8478f2700bd067b20fa7d3d Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Sat, 21 Sep 2024 10:57:29 -0400 Subject: [PATCH] Appease `static_mut_refs` Made stricter in https://github.com/rust-lang/rust/commit/5ba6db1b648d9. --- test/integration-ebpf/src/redirect.rs | 4 ++-- test/integration-ebpf/src/relocations.rs | 2 +- test/integration-test/src/tests/rbpf.rs | 7 +++---- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/test/integration-ebpf/src/redirect.rs b/test/integration-ebpf/src/redirect.rs index 83a44423..85a0a0a8 100644 --- a/test/integration-ebpf/src/redirect.rs +++ b/test/integration-ebpf/src/redirect.rs @@ -22,7 +22,7 @@ static CPUS: CpuMap = CpuMap::with_max_entries(1, 0); /// counts how many times the map programs got executed. /// This allows the test harness to assert that a specific step got executed. #[map] -static mut HITS: Array = Array::with_max_entries(2, 0); +static HITS: Array = Array::with_max_entries(2, 0); #[xdp] pub fn redirect_sock(_ctx: XdpContext) -> u32 { @@ -61,7 +61,7 @@ pub fn redirect_dev_chain(_ctx: XdpContext) -> u32 { #[inline(always)] 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 }; } } diff --git a/test/integration-ebpf/src/relocations.rs b/test/integration-ebpf/src/relocations.rs index de5bb0f9..dc9e71ca 100644 --- a/test/integration-ebpf/src/relocations.rs +++ b/test/integration-ebpf/src/relocations.rs @@ -10,7 +10,7 @@ use aya_ebpf::{ }; #[map] -static mut RESULTS: Array = Array::with_max_entries(3, 0); +static RESULTS: Array = Array::with_max_entries(3, 0); #[uprobe] pub fn test_64_32_call_relocs(_ctx: ProbeContext) { diff --git a/test/integration-test/src/tests/rbpf.rs b/test/integration-test/src/tests/rbpf.rs index 900d1462..66c2234f 100644 --- a/test/integration-test/src/tests/rbpf.rs +++ b/test/integration-test/src/tests/rbpf.rs @@ -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. let mut maps = HashMap::new(); let mut map_instances = vec![vec![0u64], vec![0u64], vec![0u64]]; + unsafe { + MULTIMAP_MAPS = [null_mut(); 3]; + } for (name, map) in object.maps.iter() { assert_eq!(map.key_size(), size_of::() as u32); assert_eq!(map.value_size(), size_of::() as u32); @@ -110,10 +113,6 @@ fn use_map_with_rbpf() { assert_eq!(vm.execute_program().unwrap(), 0); assert_eq!(map_instances, [[24], [42], [44]]); - - unsafe { - MULTIMAP_MAPS.iter_mut().for_each(|v| *v = null_mut()); - } } #[track_caller]