patches errors from clippy::seek_to_start_instead_of_rewind

https://rust-lang.github.io/rust-clippy/master/index.html#seek_to_start_instead_of_rewind
This commit is contained in:
behzad nouri 2022-12-06 09:11:03 -05:00
parent bbd49acb2f
commit 401f66c830
4 changed files with 5 additions and 5 deletions

View File

@ -317,7 +317,7 @@ impl BucketStorage {
data.seek(SeekFrom::Start(capacity * cell_size as u64 - 1)) data.seek(SeekFrom::Start(capacity * cell_size as u64 - 1))
.unwrap(); .unwrap();
data.write_all(&[0]).unwrap(); data.write_all(&[0]).unwrap();
data.seek(SeekFrom::Start(0)).unwrap(); data.rewind().unwrap();
measure_new_file.stop(); measure_new_file.stop();
let mut measure_flush = Measure::start("measure_flush"); let mut measure_flush = Measure::start("measure_flush");
data.flush().unwrap(); // can we skip this? data.flush().unwrap(); // can we skip this?

View File

@ -22,7 +22,7 @@ use {
std::{ std::{
fmt::{Debug, Formatter}, fmt::{Debug, Formatter},
fs::File, fs::File,
io::{Read, Seek, SeekFrom}, io::{Read, Seek},
path::Path, path::Path,
time::{Duration, Instant}, time::{Duration, Instant},
}, },
@ -244,7 +244,7 @@ before execting it in the virtual machine.",
let mut file = File::open(Path::new(program)).unwrap(); let mut file = File::open(Path::new(program)).unwrap();
let mut magic = [0u8; 4]; let mut magic = [0u8; 4];
file.read_exact(&mut magic).unwrap(); file.read_exact(&mut magic).unwrap();
file.seek(SeekFrom::Start(0)).unwrap(); file.rewind().unwrap();
let mut contents = Vec::new(); let mut contents = Vec::new();
file.read_to_end(&mut contents).unwrap(); file.read_to_end(&mut contents).unwrap();
let syscall_registry = register_syscalls(&invoke_context.feature_set, true).unwrap(); let syscall_registry = register_syscalls(&invoke_context.feature_set, true).unwrap();

View File

@ -333,7 +333,7 @@ impl AppendVec {
// expensive. // expensive.
data.seek(SeekFrom::Start((size - 1) as u64)).unwrap(); data.seek(SeekFrom::Start((size - 1) as u64)).unwrap();
data.write_all(&[0]).unwrap(); data.write_all(&[0]).unwrap();
data.seek(SeekFrom::Start(0)).unwrap(); data.rewind().unwrap();
data.flush().unwrap(); data.flush().unwrap();
//UNSAFE: Required to create a Mmap //UNSAFE: Required to create a Mmap

View File

@ -126,7 +126,7 @@ impl CacheHashDataFile {
// expensive. // expensive.
data.seek(SeekFrom::Start(capacity - 1)).unwrap(); data.seek(SeekFrom::Start(capacity - 1)).unwrap();
data.write_all(&[0]).unwrap(); data.write_all(&[0]).unwrap();
data.seek(SeekFrom::Start(0)).unwrap(); data.rewind().unwrap();
data.flush().unwrap(); data.flush().unwrap();
Ok(unsafe { MmapMut::map_mut(&data).unwrap() }) Ok(unsafe { MmapMut::map_mut(&data).unwrap() })
} }