[pbs-devel] [PATCH v2 backup 1/5] clippy fixes: the borrowed expression implements the required traits

Maximiliano Sandoval m.sandoval at proxmox.com
Fri Jun 16 10:27:27 CEST 2023


Suggests that the receiver of the expression borrows the expression.

Signed-off-by: Maximiliano Sandoval <m.sandoval at proxmox.com>
---
 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(&note_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<bool, Error> {
         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<Self, Error> {
         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<TapeIndex, Error> {
         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/<name>`.
     pub fn disk_by_name(self: Arc<Self>, name: &str) -> io::Result<Disk> {
         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






More information about the pbs-devel mailing list