tree-wide: fix needless borrows

found and fixed via clippy

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
Fabian Grünbichler
2021-12-30 12:57:37 +01:00
parent a0c69902c8
commit 9a37bd6c84
104 changed files with 238 additions and 241 deletions

View File

@ -160,7 +160,7 @@ impl BackupGroup {
pub fn matches(&self, filter: &GroupFilter) -> bool {
match filter {
GroupFilter::Group(backup_group) => match BackupGroup::from_str(&backup_group) {
GroupFilter::Group(backup_group) => match BackupGroup::from_str(backup_group) {
Ok(group) => &group == self,
Err(_) => false, // shouldn't happen if value is schema-checked
},

View File

@ -506,7 +506,7 @@ impl <R: Read + Seek> CatalogReader<R> {
if let Some(entry) = self.lookup(&current, comp)? {
current = entry;
} else {
bail!("path {:?} not found in catalog", String::from_utf8_lossy(&path));
bail!("path {:?} not found in catalog", String::from_utf8_lossy(path));
}
}
Ok(current)
@ -612,7 +612,7 @@ impl <R: Read + Seek> CatalogReader<R> {
file_path.extend(&e.name);
match match_list.matches(&file_path, e.get_file_mode()) {
Some(MatchType::Exclude) => continue,
Some(MatchType::Include) => callback(&file_path)?,
Some(MatchType::Include) => callback(file_path)?,
None => (),
}
if is_dir {

View File

@ -123,7 +123,7 @@ impl DataBlob {
raw_data.write_le_value(dummy_head)?;
}
let (iv, tag) = Self::encrypt_to(&config, data, &mut raw_data)?;
let (iv, tag) = Self::encrypt_to(config, data, &mut raw_data)?;
let head = EncryptedDataBlobHeader {
head: DataBlobHeader { magic, crc: [0; 4] }, iv, tag,
@ -491,7 +491,7 @@ impl <'a, 'b> DataChunkBuilder<'a, 'b> {
fn compute_digest(&mut self) {
if !self.digest_computed {
if let Some(ref config) = self.config {
if let Some(config) = self.config {
self.digest = config.compute_digest(self.orig_data);
} else {
self.digest = openssl::sha::sha256(self.orig_data);
@ -531,7 +531,7 @@ impl <'a, 'b> DataChunkBuilder<'a, 'b> {
) -> Result<(DataBlob, [u8; 32]), Error> {
let zero_bytes = vec![0; chunk_size];
let mut chunk_builder = DataChunkBuilder::new(&zero_bytes).compress(compress);
if let Some(ref crypt_config) = crypt_config {
if let Some(crypt_config) = crypt_config {
chunk_builder = chunk_builder.crypt_config(crypt_config);
}

View File

@ -839,7 +839,7 @@ impl DataStore {
) -> Result<(), Error> {
let _guard = self.lock_manifest(backup_dir)?;
let (mut manifest, _) = self.load_manifest(&backup_dir)?;
let (mut manifest, _) = self.load_manifest(backup_dir)?;
update_fn(&mut manifest);
@ -919,7 +919,7 @@ impl DataStore {
}
// sorting by inode improves data locality, which makes it lots faster on spinners
chunk_list.sort_unstable_by(|(_, ino_a), (_, ino_b)| ino_a.cmp(&ino_b));
chunk_list.sort_unstable_by(|(_, ino_a), (_, ino_b)| ino_a.cmp(ino_b));
Ok(chunk_list)
}

View File

@ -214,7 +214,7 @@ impl BackupManifest {
let json: Value = serde_json::from_slice(data)?;
let signature = json["signature"].as_str().map(String::from);
if let Some(ref crypt_config) = crypt_config {
if let Some(crypt_config) = crypt_config {
if let Some(signature) = signature {
let expected_signature = hex::encode(&Self::json_signature(&json, crypt_config)?);

View File

@ -53,7 +53,7 @@ pub fn generate_paper_key<W: Write>(
(lines, true)
} else {
match serde_json::from_str::<KeyConfig>(&data) {
match serde_json::from_str::<KeyConfig>(data) {
Ok(key_config) => {
let lines = serde_json::to_string_pretty(&key_config)?
.lines()
@ -216,7 +216,7 @@ fn paperkey_text<W: Write>(
}
writeln!(output, "-----END PROXMOX BACKUP KEY-----")?;
let qr_code = generate_qr_code("utf8i", &lines)?;
let qr_code = generate_qr_code("utf8i", lines)?;
let qr_code = String::from_utf8(qr_code)
.map_err(|_| format_err!("Failed to read qr code (got non-utf8 data)"))?;

View File

@ -44,7 +44,7 @@ fn mark_selections<F: Fn(&BackupInfo) -> Result<String, Error>> (
for info in list {
let backup_id = info.backup_dir.relative_path();
if let Some(PruneMark::Keep) = mark.get(&backup_id) {
let sel_id: String = select_id(&info)?;
let sel_id: String = select_id(info)?;
already_included.insert(sel_id);
}
}
@ -56,7 +56,7 @@ fn mark_selections<F: Fn(&BackupInfo) -> Result<String, Error>> (
mark.insert(backup_id, PruneMark::Protected);
continue;
}
let sel_id: String = select_id(&info)?;
let sel_id: String = select_id(info)?;
if already_included.contains(&sel_id) { continue; }

View File

@ -89,7 +89,7 @@ impl SnapshotReader {
/// Returns an iterator for all used chunks.
pub fn chunk_iterator(&self) -> Result<SnapshotChunkIterator, Error> {
SnapshotChunkIterator::new(&self)
SnapshotChunkIterator::new(self)
}
}