diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c0e0c72..48b47bf 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -34,11 +34,10 @@ jobs: steps: - uses: actions/checkout@v3 - uses: dtolnay/rust-toolchain@stable + - uses: cargo-bins/cargo-binstall@main - name: Install cargo fuzz - uses: taiki-e/install-action@v2 - with: - tool: cargo-fuzz + run: cargo binstall cargo-fuzz --no-confirm --target x86_64-unknown-linux-gnu - name: Smoke-test fuzz targets run: | diff --git a/CHANGELOG.md b/CHANGELOG.md index a2e4c68..741a1fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,18 +4,21 @@ ## Unreleased +## 3.0.0 17-07-24 + +- *Breaking:* Map keys are now always passed by reference. This avoids extra cloning and memory use for bigger keys. - Added `space_left` function for queue - Added a new `map::remove_all_items()` API to remove all stored items in flash. -# 2.0.2 07-05-24 +## 2.0.2 07-05-24 - Added check for too big items that won't ever fit in flash so it returns a good clear error. -# 2.0.1 06-05-24 +## 2.0.1 06-05-24 - Implemented the `get_len` function for all built-in key types -# 2.0.0 06-05-24 +## 2.0.0 06-05-24 - *Breaking:* Made the cache API a bit more strict. Caches now always have to be passed as a mutable reference. The API before would lead to a lot of extra unncesessary binary size. diff --git a/Cargo.toml b/Cargo.toml index 08c3b9f..9d975d8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sequential-storage" -version = "2.0.2" +version = "3.0.0" edition = "2021" license = "MIT OR Apache-2.0" description = "A crate for storing data in flash with minimal erase cycles." diff --git a/example/Cargo.lock b/example/Cargo.lock index a2c5e87..926ed0e 100644 --- a/example/Cargo.lock +++ b/example/Cargo.lock @@ -731,7 +731,7 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "sequential-storage" -version = "2.0.2" +version = "3.0.0" dependencies = [ "defmt", "embedded-storage-async", diff --git a/example/src/main.rs b/example/src/main.rs index 185edeb..9569e45 100644 --- a/example/src/main.rs +++ b/example/src/main.rs @@ -96,7 +96,7 @@ async fn run_map( flash_range.clone(), &mut NoCache::new(), &mut data_buffer, - 0u8, + &0u8, &0u8, ) .await @@ -108,7 +108,7 @@ async fn run_map( flash_range.clone(), &mut NoCache::new(), &mut data_buffer, - 1u8, + &1u8, &123u32, ) .await @@ -120,7 +120,7 @@ async fn run_map( flash_range.clone(), &mut NoCache::new(), &mut data_buffer, - 2u8, + &2u8, &0.123f32, ) .await @@ -132,7 +132,7 @@ async fn run_map( flash_range.clone(), &mut NoCache::new(), &mut data_buffer, - 3, + &3, ) .await ); @@ -145,7 +145,7 @@ async fn run_map( flash_range.clone(), &mut NoCache::new(), &mut data_buffer, - 1, + &1, ) .await ); diff --git a/fuzz/fuzz_targets/map.rs b/fuzz/fuzz_targets/map.rs index c1377bc..24fbaf6 100644 --- a/fuzz/fuzz_targets/map.rs +++ b/fuzz/fuzz_targets/map.rs @@ -105,7 +105,7 @@ fn fuzz(ops: Input, mut cache: impl KeyCacheImpl + Debug) { FLASH_RANGE, &mut cache, &mut buf.0, - key, + &key, &value.as_slice(), )) { Ok(_) => { @@ -121,7 +121,7 @@ fn fuzz(ops: Input, mut cache: impl KeyCacheImpl + Debug) { FLASH_RANGE, &mut cache, &mut buf.0, - key, + &key, )) { Ok(Some(check_item)) if check_item == value => { #[cfg(fuzzing_repro)] @@ -152,7 +152,7 @@ fn fuzz(ops: Input, mut cache: impl KeyCacheImpl + Debug) { FLASH_RANGE, &mut cache, &mut buf.0, - key, + &key, )) { Ok(Some(fetch_result)) => { let map_value = map @@ -186,7 +186,7 @@ fn fuzz(ops: Input, mut cache: impl KeyCacheImpl + Debug) { FLASH_RANGE, &mut cache, &mut buf.0, - key, + &key, )) { Ok(()) => { map.remove(&key); @@ -201,7 +201,7 @@ fn fuzz(ops: Input, mut cache: impl KeyCacheImpl + Debug) { FLASH_RANGE, &mut cache, &mut buf.0, - key, + &key, )) { Ok(Some(_)) => { #[cfg(fuzzing_repro)] @@ -247,7 +247,7 @@ fn fuzz(ops: Input, mut cache: impl KeyCacheImpl + Debug) { FLASH_RANGE, &mut cache, &mut buf.0, - key, + &key, )) { Ok(Some(_)) => { #[cfg(fuzzing_repro)] diff --git a/src/cache/key_pointers.rs b/src/cache/key_pointers.rs index 2a76248..8719772 100644 --- a/src/cache/key_pointers.rs +++ b/src/cache/key_pointers.rs @@ -1,9 +1,11 @@ use core::{fmt::Debug, num::NonZeroU32}; -pub(crate) trait KeyPointersCache { +use crate::map::Key; + +pub(crate) trait KeyPointersCache { fn key_location(&self, key: &KEY) -> Option; - fn notice_key_location(&mut self, key: KEY, item_address: u32); + fn notice_key_location(&mut self, key: &KEY, item_address: u32); fn notice_key_erased(&mut self, key: &KEY); fn invalidate_cache_state(&mut self); @@ -45,20 +47,20 @@ impl CachedKeyPointers { } } -impl KeyPointersCache for CachedKeyPointers { +impl KeyPointersCache for CachedKeyPointers { fn key_location(&self, key: &KEY) -> Option { self.key_index(key) .map(|index| self.key_pointers[index].as_ref().unwrap().1.get()) } - fn notice_key_location(&mut self, key: KEY, item_address: u32) { - match self.key_index(&key) { + fn notice_key_location(&mut self, key: &KEY, item_address: u32) { + match self.key_index(key) { Some(existing_index) => { self.key_pointers[existing_index] = - Some((key, NonZeroU32::new(item_address).unwrap())); + Some((key.clone(), NonZeroU32::new(item_address).unwrap())); move_to_front(&mut self.key_pointers, existing_index); } - None => self.insert_front((key, NonZeroU32::new(item_address).unwrap())), + None => self.insert_front((key.clone(), NonZeroU32::new(item_address).unwrap())), } } @@ -77,12 +79,12 @@ impl KeyPointersCache for CachedKeyPointers KeyPointersCache for UncachedKeyPointers { +impl KeyPointersCache for UncachedKeyPointers { fn key_location(&self, _key: &KEY) -> Option { None } - fn notice_key_location(&mut self, _key: KEY, _item_address: u32) {} + fn notice_key_location(&mut self, _key: &KEY, _item_address: u32) {} fn notice_key_erased(&mut self, _key: &KEY) {} diff --git a/src/cache/mod.rs b/src/cache/mod.rs index a0b6438..7c9ef27 100644 --- a/src/cache/mod.rs +++ b/src/cache/mod.rs @@ -4,7 +4,7 @@ use core::{fmt::Debug, ops::Range}; use embedded_storage_async::nor_flash::NorFlash; -use crate::{item::ItemHeader, PageState}; +use crate::{item::ItemHeader, map::Key, PageState}; use self::{ key_pointers::{CachedKeyPointers, KeyPointersCache, UncachedKeyPointers}, @@ -26,7 +26,7 @@ pub trait CacheImpl: PrivateCacheImpl {} /// Trait implemented by all cache types that know about keys #[allow(private_bounds)] -pub trait KeyCacheImpl: CacheImpl + PrivateKeyCacheImpl {} +pub trait KeyCacheImpl: CacheImpl + PrivateKeyCacheImpl {} pub(crate) trait Invalidate { fn invalidate_cache_state(&mut self); @@ -133,7 +133,7 @@ impl PrivateCacheImpl for &mut T { } } -pub(crate) trait PrivateKeyCacheImpl: PrivateCacheImpl { +pub(crate) trait PrivateKeyCacheImpl: PrivateCacheImpl { type KPC: KeyPointersCache; fn key_pointers(&mut self) -> &mut Self::KPC; @@ -142,7 +142,7 @@ pub(crate) trait PrivateKeyCacheImpl: PrivateCacheImpl { self.key_pointers().key_location(key) } - fn notice_key_location(&mut self, key: KEY, item_address: u32, dirty: bool) { + fn notice_key_location(&mut self, key: &KEY, item_address: u32, dirty: bool) { if dirty { self.mark_dirty(); } @@ -155,7 +155,7 @@ pub(crate) trait PrivateKeyCacheImpl: PrivateCacheImpl { } } -impl> PrivateKeyCacheImpl for &mut T { +impl> PrivateKeyCacheImpl for &mut T { type KPC = T::KPC; fn key_pointers(&mut self) -> &mut Self::KPC { @@ -240,13 +240,13 @@ impl PrivateCacheImpl for NoCache { } impl CacheImpl for NoCache {} -impl KeyCacheImpl for NoCache {} +impl KeyCacheImpl for NoCache {} impl Invalidate for NoCache { fn invalidate_cache_state(&mut self) {} } -impl PrivateKeyCacheImpl for NoCache { +impl PrivateKeyCacheImpl for NoCache { type KPC = UncachedKeyPointers; fn key_pointers(&mut self) -> &mut Self::KPC { @@ -309,7 +309,7 @@ impl PrivateCacheImpl for PageStateCache { } impl CacheImpl for PageStateCache {} -impl KeyCacheImpl for PageStateCache {} +impl KeyCacheImpl for PageStateCache {} impl Invalidate for PageStateCache { fn invalidate_cache_state(&mut self) { @@ -319,7 +319,7 @@ impl Invalidate for PageStateCache { } } -impl PrivateKeyCacheImpl for PageStateCache { +impl PrivateKeyCacheImpl for PageStateCache { type KPC = UncachedKeyPointers; fn key_pointers(&mut self) -> &mut Self::KPC { @@ -382,7 +382,7 @@ impl PrivateCacheImpl for PagePointerCache } impl CacheImpl for PagePointerCache {} -impl KeyCacheImpl for PagePointerCache {} +impl KeyCacheImpl for PagePointerCache {} impl Invalidate for PagePointerCache { fn invalidate_cache_state(&mut self) { @@ -392,7 +392,7 @@ impl Invalidate for PagePointerCache { } } -impl PrivateKeyCacheImpl for PagePointerCache { +impl PrivateKeyCacheImpl for PagePointerCache { type KPC = UncachedKeyPointers; fn key_pointers(&mut self) -> &mut Self::KPC { @@ -417,14 +417,14 @@ impl PrivateKeyCacheImpl for PagePointerC /// the chance of a cache hit. /// The keys are cached in a fifo and any time its location is updated in cache it's added to the front. #[derive(Debug)] -pub struct KeyPointerCache { +pub struct KeyPointerCache { dirt_tracker: DirtTracker, page_states: CachedPageStates, page_pointers: CachedPagePointers, key_pointers: CachedKeyPointers, } -impl KeyPointerCache { +impl KeyPointerCache { /// Construct a new instance pub const fn new() -> Self { Self { @@ -436,7 +436,7 @@ impl KeyPointerCache Default +impl Default for KeyPointerCache { fn default() -> Self { @@ -444,7 +444,7 @@ impl Default } } -impl PrivateCacheImpl +impl PrivateCacheImpl for KeyPointerCache { type PSC = CachedPageStates; @@ -463,16 +463,16 @@ impl PrivateCacheImpl } } -impl CacheImpl +impl CacheImpl for KeyPointerCache { } -impl KeyCacheImpl +impl KeyCacheImpl for KeyPointerCache { } -impl Invalidate +impl Invalidate for KeyPointerCache { fn invalidate_cache_state(&mut self) { @@ -483,7 +483,7 @@ impl Invalidate } } -impl PrivateKeyCacheImpl +impl PrivateKeyCacheImpl for KeyPointerCache { type KPC = CachedKeyPointers; diff --git a/src/cache/tests.rs b/src/cache/tests.rs index b95fc4c..73d2f25 100644 --- a/src/cache/tests.rs +++ b/src/cache/tests.rs @@ -213,7 +213,7 @@ mod map_tests { FLASH_RANGE, cache, &mut data_buffer, - i as u16, + &(i as u16), &vec![i as u8; LENGHT_PER_KEY[i]].as_slice(), ) .await @@ -231,7 +231,7 @@ mod map_tests { FLASH_RANGE, cache, &mut data_buffer, - i as u16, + &(i as u16), ) .await .unwrap() diff --git a/src/map.rs b/src/map.rs index d26d512..5e7f59f 100644 --- a/src/map.rs +++ b/src/map.rs @@ -38,7 +38,7 @@ //! flash_range.clone(), //! &mut NoCache::new(), //! &mut data_buffer, -//! 42, +//! &42, //! ).await.unwrap(), //! None //! ); @@ -52,7 +52,7 @@ //! flash_range.clone(), //! &mut NoCache::new(), //! &mut data_buffer, -//! 42u8, +//! &42u8, //! &104729u32, //! ).await.unwrap(); //! @@ -64,7 +64,7 @@ //! flash_range.clone(), //! &mut NoCache::new(), //! &mut data_buffer, -//! 42, +//! &42, //! ).await.unwrap(), //! Some(104729) //! ); @@ -127,18 +127,12 @@ pub async fn fetch_item<'d, K: Key, V: Value<'d>, S: NorFlash>( flash_range: Range, cache: &mut impl KeyCacheImpl, data_buffer: &'d mut [u8], - search_key: K, + search_key: &K, ) -> Result, Error> { let result = run_with_auto_repair!( function = { - fetch_item_with_location( - flash, - flash_range.clone(), - cache, - data_buffer, - search_key.clone(), - ) - .await + fetch_item_with_location(flash, flash_range.clone(), cache, data_buffer, search_key) + .await }, repair = try_repair::(flash, flash_range.clone(), cache, data_buffer).await? ); @@ -166,7 +160,7 @@ async fn fetch_item_with_location<'d, K: Key, S: NorFlash>( flash_range: Range, cache: &mut impl PrivateKeyCacheImpl, data_buffer: &'d mut [u8], - search_key: K, + search_key: &K, ) -> Result)>, Error> { assert_eq!(flash_range.start % S::ERASE_SIZE as u32, 0); assert_eq!(flash_range.end % S::ERASE_SIZE as u32, 0); @@ -180,7 +174,7 @@ async fn fetch_item_with_location<'d, K: Key, S: NorFlash>( } 'cache: { - if let Some(cached_location) = cache.key_location(&search_key) { + if let Some(cached_location) = cache.key_location(search_key) { let page_index = calculate_page_index::(flash_range.clone(), cached_location); let page_data_end_address = calculate_page_end_address::(flash_range.clone(), page_index) @@ -268,7 +262,7 @@ async fn fetch_item_with_location<'d, K: Key, S: NorFlash>( let mut it = ItemIter::new(page_data_start_address, page_data_end_address); while let Some((item, address)) = it.next(flash, data_buffer).await? { let (found_key, found_key_len) = K::deserialize_from(item.data())?; - if found_key == search_key { + if found_key == *search_key { newest_found_item_data = Some((address, found_key_len)); } } @@ -341,19 +335,12 @@ pub async fn store_item<'d, K: Key, V: Value<'d>, S: NorFlash>( flash_range: Range, cache: &mut impl KeyCacheImpl, data_buffer: &mut [u8], - key: K, + key: &K, item: &V, ) -> Result<(), Error> { run_with_auto_repair!( - function = store_item_inner( - flash, - flash_range.clone(), - cache, - data_buffer, - key.clone(), - item - ) - .await, + function = + store_item_inner(flash, flash_range.clone(), cache, data_buffer, key, item).await, repair = try_repair::(flash, flash_range.clone(), cache, data_buffer).await? ) } @@ -363,7 +350,7 @@ async fn store_item_inner<'d, K: Key, S: NorFlash>( flash_range: Range, cache: &mut impl KeyCacheImpl, data_buffer: &mut [u8], - key: K, + key: &K, item: &dyn Value<'d>, ) -> Result<(), Error> { assert_eq!(flash_range.start % S::ERASE_SIZE as u32, 0); @@ -446,7 +433,7 @@ async fn store_item_inner<'d, K: Key, S: NorFlash>( match free_spot_address { Some(free_spot_address) => { - cache.notice_key_location(key.clone(), free_spot_address, true); + cache.notice_key_location(key, free_spot_address, true); Item::write_new( flash, flash_range.clone(), @@ -558,7 +545,7 @@ pub async fn remove_item( flash_range: Range, cache: &mut impl KeyCacheImpl, data_buffer: &mut [u8], - search_key: K, + search_key: &K, ) -> Result<(), Error> { run_with_auto_repair!( function = remove_item_inner::( @@ -566,7 +553,7 @@ pub async fn remove_item( flash_range.clone(), cache, data_buffer, - Some(search_key.clone()) + Some(search_key) ) .await, repair = try_repair::(flash, flash_range.clone(), cache, data_buffer).await? @@ -605,7 +592,7 @@ async fn remove_item_inner( flash_range: Range, cache: &mut impl KeyCacheImpl, data_buffer: &mut [u8], - search_key: Option, + search_key: Option<&K>, ) -> Result<(), Error> { if let Some(key) = &search_key { cache.notice_key_erased(key); @@ -651,8 +638,8 @@ async fn remove_item_inner( item::MaybeItem::Corrupted(_, _) => continue, item::MaybeItem::Erased(_, _) => continue, item::MaybeItem::Present(item) => { - let item_match = match &search_key { - Some(search_key) => &K::deserialize_from(item.data())?.0 == search_key, + let item_match = match search_key { + Some(search_key) => K::deserialize_from(item.data())?.0 == *search_key, _ => true, }; // If this item has the same key as the key we're trying to erase, then erase the item. @@ -903,14 +890,9 @@ async fn migrate_items( cache.unmark_dirty(); // Search for the newest item with the key we found - let Some((found_item, found_address, _)) = fetch_item_with_location::( - flash, - flash_range.clone(), - cache, - data_buffer, - key.clone(), - ) - .await? + let Some((found_item, found_address, _)) = + fetch_item_with_location::(flash, flash_range.clone(), cache, data_buffer, &key) + .await? else { // We couldn't even find our own item? return Err(Error::Corrupted { @@ -922,7 +904,7 @@ async fn migrate_items( let found_item = found_item.reborrow(data_buffer); if found_address == item_address { - cache.notice_key_location(key, next_page_write_address, true); + cache.notice_key_location(&key, next_page_write_address, true); found_item .write(flash, flash_range.clone(), cache, next_page_write_address) .await?; @@ -1010,7 +992,7 @@ mod tests { flash_range.clone(), &mut cache::NoCache::new(), &mut data_buffer, - 0, + &0, ) .await .unwrap(); @@ -1021,7 +1003,7 @@ mod tests { flash_range.clone(), &mut cache::NoCache::new(), &mut data_buffer, - 60, + &60, ) .await .unwrap(); @@ -1032,7 +1014,7 @@ mod tests { flash_range.clone(), &mut cache::NoCache::new(), &mut data_buffer, - 0xFF, + &0xFF, ) .await .unwrap(); @@ -1043,7 +1025,7 @@ mod tests { flash_range.clone(), &mut cache::NoCache::new(), &mut data_buffer, - 0u8, + &0u8, &[5], ) .await @@ -1053,7 +1035,7 @@ mod tests { flash_range.clone(), &mut cache::NoCache::new(), &mut data_buffer, - 0u8, + &0u8, &[5, 6], ) .await @@ -1064,7 +1046,7 @@ mod tests { flash_range.clone(), &mut cache::NoCache::new(), &mut data_buffer, - 0, + &0, ) .await .unwrap() @@ -1076,7 +1058,7 @@ mod tests { flash_range.clone(), &mut cache::NoCache::new(), &mut data_buffer, - 1u8, + &1u8, &[2, 2, 2, 2, 2, 2], ) .await @@ -1087,7 +1069,7 @@ mod tests { flash_range.clone(), &mut cache::NoCache::new(), &mut data_buffer, - 0, + &0, ) .await .unwrap() @@ -1099,7 +1081,7 @@ mod tests { flash_range.clone(), &mut cache::NoCache::new(), &mut data_buffer, - 1, + &1, ) .await .unwrap() @@ -1112,7 +1094,7 @@ mod tests { flash_range.clone(), &mut cache::NoCache::new(), &mut data_buffer, - (index % 10) as u8, + &((index % 10) as u8), &vec![(index % 10) as u8 * 2; index % 10].as_slice(), ) .await @@ -1125,7 +1107,7 @@ mod tests { flash_range.clone(), &mut cache::NoCache::new(), &mut data_buffer, - i, + &i, ) .await .unwrap() @@ -1139,7 +1121,7 @@ mod tests { flash_range.clone(), &mut cache::NoCache::new(), &mut data_buffer, - 11u8, + &11u8, &[0; 10], ) .await @@ -1152,7 +1134,7 @@ mod tests { flash_range.clone(), &mut cache::NoCache::new(), &mut data_buffer, - i, + &i, ) .await .unwrap() @@ -1178,7 +1160,7 @@ mod tests { 0x00..0x40, &mut cache::NoCache::new(), &mut data_buffer, - i, + &i, &vec![i; i as usize].as_slice(), ) .await @@ -1191,7 +1173,7 @@ mod tests { 0x00..0x40, &mut cache::NoCache::new(), &mut data_buffer, - UPPER_BOUND, + &UPPER_BOUND, &vec![0; UPPER_BOUND as usize].as_slice(), ) .await, @@ -1204,7 +1186,7 @@ mod tests { 0x00..0x40, &mut cache::NoCache::new(), &mut data_buffer, - i, + &i, ) .await .unwrap() @@ -1231,7 +1213,7 @@ mod tests { 0x0000..0x1000, &mut cache::NoCache::new(), &mut data_buffer, - i, + &i, &vec![i; i as usize].as_slice(), ) .await @@ -1244,7 +1226,7 @@ mod tests { 0x0000..0x1000, &mut cache::NoCache::new(), &mut data_buffer, - UPPER_BOUND, + &UPPER_BOUND, &vec![0; UPPER_BOUND as usize].as_slice(), ) .await, @@ -1257,7 +1239,7 @@ mod tests { 0x0000..0x1000, &mut cache::NoCache::new(), &mut data_buffer, - i, + &i, ) .await .unwrap() @@ -1285,7 +1267,7 @@ mod tests { 0x0000..0x4000, &mut cache::NoCache::new(), &mut data_buffer, - i as u16, + &(i as u16), &vec![i as u8; LENGHT_PER_KEY[i]].as_slice(), ) .await @@ -1299,7 +1281,7 @@ mod tests { 0x0000..0x4000, &mut cache::NoCache::new(), &mut data_buffer, - i as u16, + &(i as u16), ) .await .unwrap() @@ -1329,7 +1311,7 @@ mod tests { FLASH_RANGE, &mut cache::NoCache::new(), &mut data_buffer, - i as u8, + &(i as u8), &vec![i as u8; j + 2].as_slice(), ) .await @@ -1345,7 +1327,7 @@ mod tests { FLASH_RANGE, &mut cache::NoCache::new(), &mut data_buffer, - i + &i ) .await .unwrap() @@ -1358,7 +1340,7 @@ mod tests { FLASH_RANGE, &mut cache::NoCache::new(), &mut data_buffer, - j, + &j, ) .await .unwrap(); @@ -1370,7 +1352,7 @@ mod tests { FLASH_RANGE, &mut cache::NoCache::new(), &mut data_buffer, - i + &i ) .await .unwrap() @@ -1382,7 +1364,7 @@ mod tests { FLASH_RANGE, &mut cache::NoCache::new(), &mut data_buffer, - j + &j ) .await .unwrap() @@ -1402,14 +1384,14 @@ mod tests { // Add some data to flash for value in 0..10 { - for key in 0..24 { + for key in 0..24u8 { store_item( &mut flash, FLASH_RANGE, &mut cache::NoCache::new(), &mut data_buffer, - key as u8, - &vec![key as u8; value + 2].as_slice(), + &key, + &vec![key; value + 2].as_slice(), ) .await .unwrap(); @@ -1417,13 +1399,13 @@ mod tests { } // Sanity check that we can find all the keys we just added. - for key in 0..24 { + for key in 0..24u8 { assert!(fetch_item::( &mut flash, FLASH_RANGE, &mut cache::NoCache::new(), &mut data_buffer, - key + &key ) .await .unwrap() @@ -1447,7 +1429,7 @@ mod tests { FLASH_RANGE, &mut cache::NoCache::new(), &mut data_buffer, - key + &key ) .await .unwrap() @@ -1465,7 +1447,7 @@ mod tests { FLASH_RANGE, &mut cache::NoCache::new(), &mut [0; 1024], - 0u8, + &0u8, &[0; 1024 - 4 * 2 - 8 - 1], ) .await @@ -1477,7 +1459,7 @@ mod tests { FLASH_RANGE, &mut cache::NoCache::new(), &mut [0; 1024], - 0u8, + &0u8, &[0; 1024 - 4 * 2 - 8 - 1 + 1], ) .await,