Skip to content

Commit 2c08eac

Browse files
authored
Merge pull request #159 from rust-embedded-community/remove-stacked-block
Remove stacked block
2 parents 8c944ce + b86f672 commit 2c08eac

File tree

3 files changed

+5
-12
lines changed

3 files changed

+5
-12
lines changed

src/blockdevice.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,7 @@ where
152152
/// Access a blank sector
153153
pub fn blank_mut(&mut self, block_idx: BlockIdx) -> &mut Block {
154154
self.block_idx = Some(block_idx);
155-
for b in self.block[0].iter_mut() {
156-
*b = 0;
157-
}
155+
self.block[0].fill(0);
158156
&mut self.block[0]
159157
}
160158

src/fat/volume.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,15 +1158,12 @@ impl FatVolume {
11581158
*number_free_cluster -= 1;
11591159
};
11601160
if zero {
1161-
let blocks = [Block::new()];
11621161
let start_block_idx = self.cluster_to_block(new_cluster);
11631162
let num_blocks = BlockCount(u32::from(self.blocks_per_cluster));
11641163
for block_idx in start_block_idx.range(num_blocks) {
1165-
trace!("Zeroing cluster");
1166-
block_cache
1167-
.block_device()
1168-
.write(&blocks, block_idx)
1169-
.map_err(Error::DeviceError)?;
1164+
trace!("Zeroing cluster {:?}", block_idx);
1165+
let _block = block_cache.blank_mut(block_idx);
1166+
block_cache.write_back()?;
11701167
}
11711168
}
11721169
debug!("All done, returning {:?}", new_cluster);

src/sdcard/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,9 +341,7 @@ where
341341
return Err(Error::ReadError);
342342
}
343343

344-
for b in buffer.iter_mut() {
345-
*b = 0xFF;
346-
}
344+
buffer.fill(0xFF);
347345
self.transfer_bytes(buffer)?;
348346

349347
// These two bytes are always sent. They are either a valid CRC, or

0 commit comments

Comments
 (0)