diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2022-09-02 06:43:22 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-09-02 06:43:22 +0000 |
| commit | 50af13d47064105a983b33d06099faad519288a5 (patch) | |
| tree | 1000f69e1999072b9a62adfd8d546ce874d0de1c | |
| parent | 8b464d2668657284527693fbf9cc348766a00758 (diff) | |
| parent | 3aa0c13ba5cbef09b825619f22221d028532732d (diff) | |
Merge #940
940: Fix a few clippy warnings r=lulf a=lulf
Co-authored-by: Ulf Lilleengen <[email protected]>
| -rw-r--r-- | embassy-boot/boot/src/lib.rs | 48 |
1 files changed, 23 insertions, 25 deletions
diff --git a/embassy-boot/boot/src/lib.rs b/embassy-boot/boot/src/lib.rs index e8ebe628d..4a2b112a9 100644 --- a/embassy-boot/boot/src/lib.rs +++ b/embassy-boot/boot/src/lib.rs | |||
| @@ -28,6 +28,7 @@ impl Partition { | |||
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | /// Return the length of the partition | 30 | /// Return the length of the partition |
| 31 | #[allow(clippy::len_without_is_empty)] | ||
| 31 | pub const fn len(&self) -> usize { | 32 | pub const fn len(&self) -> usize { |
| 32 | self.to - self.from | 33 | self.to - self.from |
| 33 | } | 34 | } |
| @@ -229,31 +230,28 @@ impl BootLoader { | |||
| 229 | 230 | ||
| 230 | // Copy contents from partition N to active | 231 | // Copy contents from partition N to active |
| 231 | let state = self.read_state(p, magic)?; | 232 | let state = self.read_state(p, magic)?; |
| 232 | match state { | 233 | if state == State::Swap { |
| 233 | State::Swap => { | 234 | // |
| 234 | // | 235 | // Check if we already swapped. If we're in the swap state, this means we should revert |
| 235 | // Check if we already swapped. If we're in the swap state, this means we should revert | 236 | // since the app has failed to mark boot as successful |
| 236 | // since the app has failed to mark boot as successful | 237 | // |
| 237 | // | 238 | if !self.is_swapped(p, magic, page)? { |
| 238 | if !self.is_swapped(p, magic, page)? { | 239 | trace!("Swapping"); |
| 239 | trace!("Swapping"); | 240 | self.swap(p, magic, page)?; |
| 240 | self.swap(p, magic, page)?; | 241 | trace!("Swapping done"); |
| 241 | trace!("Swapping done"); | 242 | } else { |
| 242 | } else { | 243 | trace!("Reverting"); |
| 243 | trace!("Reverting"); | 244 | self.revert(p, magic, page)?; |
| 244 | self.revert(p, magic, page)?; | 245 | |
| 245 | 246 | // Overwrite magic and reset progress | |
| 246 | // Overwrite magic and reset progress | 247 | let fstate = p.state(); |
| 247 | let fstate = p.state(); | 248 | magic.fill(!P::STATE::ERASE_VALUE); |
| 248 | magic.fill(!P::STATE::ERASE_VALUE); | 249 | fstate.write(self.state.from as u32, magic)?; |
| 249 | fstate.write(self.state.from as u32, magic)?; | 250 | fstate.erase(self.state.from as u32, self.state.to as u32)?; |
| 250 | fstate.erase(self.state.from as u32, self.state.to as u32)?; | 251 | |
| 251 | 252 | magic.fill(BOOT_MAGIC); | |
| 252 | magic.fill(BOOT_MAGIC); | 253 | fstate.write(self.state.from as u32, magic)?; |
| 253 | fstate.write(self.state.from as u32, magic)?; | ||
| 254 | } | ||
| 255 | } | 254 | } |
| 256 | _ => {} | ||
| 257 | } | 255 | } |
| 258 | Ok(state) | 256 | Ok(state) |
| 259 | } | 257 | } |
| @@ -1005,7 +1003,7 @@ mod tests { | |||
| 1005 | const ERASE_SIZE: usize = ERASE_SIZE; | 1003 | const ERASE_SIZE: usize = ERASE_SIZE; |
| 1006 | 1004 | ||
| 1007 | type EraseFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a; | 1005 | type EraseFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a; |
| 1008 | fn erase<'a>(&'a mut self, from: u32, to: u32) -> Self::EraseFuture<'a> { | 1006 | fn erase(&mut self, from: u32, to: u32) -> Self::EraseFuture<'_> { |
| 1009 | async move { | 1007 | async move { |
| 1010 | let from = from as usize; | 1008 | let from = from as usize; |
| 1011 | let to = to as usize; | 1009 | let to = to as usize; |
