Skip to content

Commit

Permalink
Clippy, fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
diondokter committed Jul 17, 2024
1 parent 838f4a6 commit aefb7d3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 30 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
2 changes: 1 addition & 1 deletion src/cache/key_pointers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl<KEY: Key, const KEYS: usize> KeyPointersCache<KEY> for CachedKeyPointers<KE
}

fn notice_key_location(&mut self, key: &KEY, item_address: u32) {
match self.key_index(&key) {
match self.key_index(key) {
Some(existing_index) => {
self.key_pointers[existing_index] =
Some((key.clone(), NonZeroU32::new(item_address).unwrap()));
Expand Down
34 changes: 8 additions & 26 deletions src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,8 @@ pub async fn fetch_item<'d, K: Key, V: Value<'d>, S: NorFlash>(
) -> Result<Option<V>, Error<S::Error>> {
let result = run_with_auto_repair!(
function = {
fetch_item_with_location(
flash,
flash_range.clone(),
cache,
data_buffer,
search_key,
)
.await
fetch_item_with_location(flash, flash_range.clone(), cache, data_buffer, search_key)
.await
},
repair = try_repair::<K, _>(flash, flash_range.clone(), cache, data_buffer).await?
);
Expand Down Expand Up @@ -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::<S>(flash_range.clone(), cached_location);
let page_data_end_address =
calculate_page_end_address::<S>(flash_range.clone(), page_index)
Expand Down Expand Up @@ -345,15 +339,8 @@ pub async fn store_item<'d, K: Key, V: Value<'d>, S: NorFlash>(
item: &V,
) -> Result<(), Error<S::Error>> {
run_with_auto_repair!(
function = store_item_inner(
flash,
flash_range.clone(),
cache,
data_buffer,
key,
item
)
.await,
function =
store_item_inner(flash, flash_range.clone(), cache, data_buffer, key, item).await,
repair = try_repair::<K, _>(flash, flash_range.clone(), cache, data_buffer).await?
)
}
Expand Down Expand Up @@ -903,14 +890,9 @@ async fn migrate_items<K: Key, S: NorFlash>(
cache.unmark_dirty();

// Search for the newest item with the key we found
let Some((found_item, found_address, _)) = fetch_item_with_location::<K, S>(
flash,
flash_range.clone(),
cache,
data_buffer,
&key,
)
.await?
let Some((found_item, found_address, _)) =
fetch_item_with_location::<K, S>(flash, flash_range.clone(), cache, data_buffer, &key)
.await?
else {
// We couldn't even find our own item?
return Err(Error::Corrupted {
Expand Down

0 comments on commit aefb7d3

Please sign in to comment.