summaryrefslogtreecommitdiff
path: root/embassy-boot
diff options
context:
space:
mode:
authorVincent Stakenburg <v.stakenburg@cosinuss.nl>2022-06-30 14:46:17 +0200
committerVincent Stakenburg <v.stakenburg@cosinuss.nl>2022-06-30 14:56:40 +0200
commit3dc26bbe399723d62f2fccda665ee9e1c85e9991 (patch)
tree88788985ec36f98694972556cb4a0fda82e344ae /embassy-boot
parent0e55bb2a208f7038fe15567166e9655abe5480df (diff)
downloadembassy-3dc26bbe399723d62f2fccda665ee9e1c85e9991.zip
simplify `set_magic`
Diffstat (limited to 'embassy-boot')
-rw-r--r--embassy-boot/boot/src/lib.rs17
1 files changed, 4 insertions, 13 deletions
diff --git a/embassy-boot/boot/src/lib.rs b/embassy-boot/boot/src/lib.rs
index b18c88a6..51e1056c 100644
--- a/embassy-boot/boot/src/lib.rs
+++ b/embassy-boot/boot/src/lib.rs
@@ -587,22 +587,13 @@ impl FirmwareUpdater {
) -> Result<(), F::Error> {
flash.read(self.state.from as u32, aligned).await?;
- let mut is_set = true;
- for b in 0..aligned.len() {
- if aligned[b] != magic {
- is_set = false;
- }
- }
- if !is_set {
- for i in 0..aligned.len() {
- aligned[i] = 0;
- }
+ if aligned.iter().find(|&&b| b != magic).is_some() {
+ aligned.fill(0);
+
flash.write(self.state.from as u32, aligned).await?;
flash.erase(self.state.from as u32, self.state.to as u32).await?;
- for i in 0..aligned.len() {
- aligned[i] = magic;
- }
+ aligned.fill(magic);
flash.write(self.state.from as u32, aligned).await?;
}
Ok(())