diff --git a/src/blockdevice.rs b/src/blockdevice.rs index e0f3832..674ae55 100644 --- a/src/blockdevice.rs +++ b/src/blockdevice.rs @@ -152,9 +152,7 @@ where /// Access a blank sector pub fn blank_mut(&mut self, block_idx: BlockIdx) -> &mut Block { self.block_idx = Some(block_idx); - for b in self.block[0].iter_mut() { - *b = 0; - } + self.block[0].fill(0); &mut self.block[0] } diff --git a/src/fat/volume.rs b/src/fat/volume.rs index f160fba..25f67de 100644 --- a/src/fat/volume.rs +++ b/src/fat/volume.rs @@ -1158,15 +1158,12 @@ impl FatVolume { *number_free_cluster -= 1; }; if zero { - let blocks = [Block::new()]; let start_block_idx = self.cluster_to_block(new_cluster); let num_blocks = BlockCount(u32::from(self.blocks_per_cluster)); for block_idx in start_block_idx.range(num_blocks) { - trace!("Zeroing cluster"); - block_cache - .block_device() - .write(&blocks, block_idx) - .map_err(Error::DeviceError)?; + trace!("Zeroing cluster {:?}", block_idx); + let _block = block_cache.blank_mut(block_idx); + block_cache.write_back()?; } } debug!("All done, returning {:?}", new_cluster); diff --git a/src/sdcard/mod.rs b/src/sdcard/mod.rs index 5c3c038..553791f 100644 --- a/src/sdcard/mod.rs +++ b/src/sdcard/mod.rs @@ -341,9 +341,7 @@ where return Err(Error::ReadError); } - for b in buffer.iter_mut() { - *b = 0xFF; - } + buffer.fill(0xFF); self.transfer_bytes(buffer)?; // These two bytes are always sent. They are either a valid CRC, or