From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 13101A1BE9 for ; Fri, 16 Jun 2023 10:28:04 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id E9E042FA93 for ; Fri, 16 Jun 2023 10:27:33 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Fri, 16 Jun 2023 10:27:33 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 781B145B98 for ; Fri, 16 Jun 2023 10:27:32 +0200 (CEST) From: Maximiliano Sandoval To: pbs-devel@lists.proxmox.com Date: Fri, 16 Jun 2023 10:27:27 +0200 Message-Id: <20230616082731.45647-2-m.sandoval@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230616082731.45647-1-m.sandoval@proxmox.com> References: <20230616082731.45647-1-m.sandoval@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pbs-devel] [PATCH v2 backup 1/5] clippy fixes: the borrowed expression implements the required traits X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Jun 2023 08:28:04 -0000 Suggests that the receiver of the expression borrows the expression. Signed-off-by: Maximiliano Sandoval --- src/api2/admin/datastore.rs | 2 +- src/api2/config/acme.rs | 4 ++-- src/api2/tape/restore.rs | 2 +- src/auth.rs | 2 +- src/config/mod.rs | 4 ++-- src/config/tfa.rs | 2 +- src/server/jobstate.rs | 2 +- src/tape/drive/virtual_tape.rs | 8 ++++---- src/tape/encryption_keys.rs | 2 +- src/tape/media_catalog.rs | 2 +- src/tools/disks/mod.rs | 2 +- src/tools/disks/zfs.rs | 2 +- 12 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs index 3551e2f0..a95031e7 100644 --- a/src/api2/admin/datastore.rs +++ b/src/api2/admin/datastore.rs @@ -237,7 +237,7 @@ pub fn list_groups( .to_owned(); let note_path = get_group_note_path(&datastore, &ns, group.as_ref()); - let comment = file_read_firstline(¬e_path).ok(); + let comment = file_read_firstline(note_path).ok(); group_info.push(GroupListItem { backup: group.into(), diff --git a/src/api2/config/acme.rs b/src/api2/config/acme.rs index 3ea18493..1954318b 100644 --- a/src/api2/config/acme.rs +++ b/src/api2/config/acme.rs @@ -585,7 +585,7 @@ pub fn add_plugin(r#type: String, core: DnsPluginCore, data: String) -> Result<( param_bail!("type", "invalid ACME plugin type: {:?}", r#type); } - let data = String::from_utf8(base64::decode(&data)?) + let data = String::from_utf8(base64::decode(data)?) .map_err(|_| format_err!("data must be valid UTF-8"))?; let id = core.id.clone(); @@ -695,7 +695,7 @@ pub fn update_plugin( let (mut plugins, expected_digest) = plugin::config()?; if let Some(digest) = digest { - let digest = <[u8; 32]>::from_hex(&digest)?; + let digest = <[u8; 32]>::from_hex(digest)?; crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?; } diff --git a/src/api2/tape/restore.rs b/src/api2/tape/restore.rs index 7b4fee9c..19df4a12 100644 --- a/src/api2/tape/restore.rs +++ b/src/api2/tape/restore.rs @@ -949,7 +949,7 @@ fn restore_list_worker( for (datastore, _) in store_map.used_datastores().values() { let tmp_path = media_set_tmpdir(datastore, &media_set_uuid); - match std::fs::remove_dir_all(&tmp_path) { + match std::fs::remove_dir_all(tmp_path) { Ok(()) => {} Err(err) if err.kind() == std::io::ErrorKind::NotFound => {} Err(err) => task_warn!(worker, "error cleaning up: {}", err), diff --git a/src/auth.rs b/src/auth.rs index 3c2654b9..432bdb2c 100644 --- a/src/auth.rs +++ b/src/auth.rs @@ -341,7 +341,7 @@ impl proxmox_auth_api::api::AuthContext for PbsAuthContext { if let Ok(Empty) = Ticket::parse(password).and_then(|ticket| { ticket.verify( - &self.keyring, + self.keyring, TERM_PREFIX, Some(&crate::tools::ticket::term_aad(userid, &path, port)), ) diff --git a/src/config/mod.rs b/src/config/mod.rs index e86802ab..00e42dac 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -187,9 +187,9 @@ pub(crate) fn set_proxy_certificate(cert_pem: &[u8], key_pem: &[u8]) -> Result<( let cert_path = PathBuf::from(configdir!("/proxy.pem")); create_configdir()?; - pbs_config::replace_backup_config(&key_path, key_pem) + pbs_config::replace_backup_config(key_path, key_pem) .map_err(|err| format_err!("error writing certificate private key - {}", err))?; - pbs_config::replace_backup_config(&cert_path, cert_pem) + pbs_config::replace_backup_config(cert_path, cert_pem) .map_err(|err| format_err!("error writing certificate file - {}", err))?; Ok(()) diff --git a/src/config/tfa.rs b/src/config/tfa.rs index 6b1312bb..9c322abd 100644 --- a/src/config/tfa.rs +++ b/src/config/tfa.rs @@ -280,7 +280,7 @@ impl proxmox_tfa::api::OpenUserChallengeData for UserAccess { /// `remove` user data if it exists. fn remove(&self, userid: &str) -> Result { let path = challenge_data_path_str(userid); - match std::fs::remove_file(&path) { + match std::fs::remove_file(path) { Ok(()) => Ok(true), Err(err) if err.not_found() => Ok(false), Err(err) => Err(err.into()), diff --git a/src/server/jobstate.rs b/src/server/jobstate.rs index 3f0acb8c..a13d768b 100644 --- a/src/server/jobstate.rs +++ b/src/server/jobstate.rs @@ -229,7 +229,7 @@ impl Job { pub fn new(jobtype: &str, jobname: &str) -> Result { let path = get_path(jobtype, jobname); - let _lock = get_lock(&path)?; + let _lock = get_lock(path)?; Ok(Self { jobtype: jobtype.to_string(), diff --git a/src/tape/drive/virtual_tape.rs b/src/tape/drive/virtual_tape.rs index d3b7b0f3..b13c58c4 100644 --- a/src/tape/drive/virtual_tape.rs +++ b/src/tape/drive/virtual_tape.rs @@ -90,7 +90,7 @@ impl VirtualTapeHandle { fn load_tape_index(&self, tape_name: &str) -> Result { let path = self.tape_index_path(tape_name); - let raw = proxmox_sys::fs::file_get_contents(&path)?; + let raw = proxmox_sys::fs::file_get_contents(path)?; if raw.is_empty() { return Ok(TapeIndex { files: 0 }); } @@ -103,7 +103,7 @@ impl VirtualTapeHandle { let raw = serde_json::to_string_pretty(&serde_json::to_value(index)?)?; let options = CreateOptions::new(); - replace_file(&path, raw.as_bytes(), options, false)?; + replace_file(path, raw.as_bytes(), options, false)?; Ok(()) } @@ -131,7 +131,7 @@ impl VirtualTapeHandle { let default = serde_json::to_value(VirtualDriveStatus { current_tape: None })?; - let data = proxmox_sys::fs::file_get_json(&path, Some(default))?; + let data = proxmox_sys::fs::file_get_json(path, Some(default))?; let status: VirtualDriveStatus = serde_json::from_value(data)?; Ok(status) } @@ -141,7 +141,7 @@ impl VirtualTapeHandle { let raw = serde_json::to_string_pretty(&serde_json::to_value(status)?)?; let options = CreateOptions::new(); - replace_file(&path, raw.as_bytes(), options, false)?; + replace_file(path, raw.as_bytes(), options, false)?; Ok(()) } diff --git a/src/tape/encryption_keys.rs b/src/tape/encryption_keys.rs index f9fdccd4..bc6dee3b 100644 --- a/src/tape/encryption_keys.rs +++ b/src/tape/encryption_keys.rs @@ -38,7 +38,7 @@ mod hex_key { D: Deserializer<'de>, { let s = String::deserialize(deserializer)?; - <[u8; 32]>::from_hex(&s).map_err(serde::de::Error::custom) + <[u8; 32]>::from_hex(s).map_err(serde::de::Error::custom) } } diff --git a/src/tape/media_catalog.rs b/src/tape/media_catalog.rs index 3b182a8d..928d4701 100644 --- a/src/tape/media_catalog.rs +++ b/src/tape/media_catalog.rs @@ -254,7 +254,7 @@ impl MediaCatalog { .write(true) .create(true) .truncate(true) - .open(&tmp_path)?; + .open(tmp_path)?; if cfg!(test) { // We cannot use chown inside test environment (no permissions) diff --git a/src/tools/disks/mod.rs b/src/tools/disks/mod.rs index 31ce5acb..72e374ca 100644 --- a/src/tools/disks/mod.rs +++ b/src/tools/disks/mod.rs @@ -108,7 +108,7 @@ impl DiskManage { /// Get a `Disk` for a name in `/sys/block/`. pub fn disk_by_name(self: Arc, name: &str) -> io::Result { let syspath = format!("/sys/block/{}", name); - self.disk_by_sys_path(&syspath) + self.disk_by_sys_path(syspath) } /// Gather information about mounted disks: diff --git a/src/tools/disks/zfs.rs b/src/tools/disks/zfs.rs index 45df81d9..b12a948b 100644 --- a/src/tools/disks/zfs.rs +++ b/src/tools/disks/zfs.rs @@ -122,7 +122,7 @@ lazy_static::lazy_static! { fn parse_objset_stat(pool: &str, objset_id: &str) -> Result<(String, BlockDevStat), Error> { let path = PathBuf::from(format!("{}/{}/{}", ZFS_KSTAT_BASE_PATH, pool, objset_id)); - let text = match proxmox_sys::fs::file_read_optional_string(&path)? { + let text = match proxmox_sys::fs::file_read_optional_string(path)? { Some(text) => text, None => bail!("could not parse '{}' stat file", objset_id), }; -- 2.39.2