all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox-backup] cleanup: fix some clippy lints
@ 2023-12-06 11:08 Gabriel Goller
  0 siblings, 0 replies; only message in thread
From: Gabriel Goller @ 2023-12-06 11:08 UTC (permalink / raw)
  To: pbs-devel

Fixed some easy clippy warnings:

- pbs-api-types/src/key_derivation.rs
    - We can't derive from Default, as the `api` proc-macro already sets
      a 'default' attribute. That's why we need to manually implement
      it.

- pbs-client/src/pxar/create.rs
    - The second lifetime can be elided, as it is only used in the
      'input'-position.

- src/api2/config/access/ldap.rs
    - convert `if let` to `option.is_some()`

- src/server/pull.rs
    - the compiler will dereference `namespace` anyway
    - same thing with `self.repo.store()`

- src/server/report.rs
    - `to_string()` does the same thing as `Display::fmt()`
    - auto-deref, so the borrow is unnecessary

- src/tape/media_catalog.rs
    - `file.stream_position()` does the same thing

- src/tools/disks/mod.rs
    - `countr_str` is a OsString already, no need to `into()`

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
 pbs-api-types/src/key_derivation.rs | 1 +
 pbs-client/src/pxar/create.rs       | 4 ++--
 src/api2/config/access/ldap.rs      | 2 +-
 src/server/pull.rs                  | 4 ++--
 src/server/report.rs                | 6 +++---
 src/tape/media_catalog.rs           | 4 ++--
 src/tools/disks/mod.rs              | 4 ++--
 7 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/pbs-api-types/src/key_derivation.rs b/pbs-api-types/src/key_derivation.rs
index 8d6cbc89..fd1e1b53 100644
--- a/pbs-api-types/src/key_derivation.rs
+++ b/pbs-api-types/src/key_derivation.rs
@@ -17,6 +17,7 @@ pub enum Kdf {
     PBKDF2,
 }
 
+#[allow(clippy::derivable_impls)]
 impl Default for Kdf {
     #[inline]
     fn default() -> Self {
diff --git a/pbs-client/src/pxar/create.rs b/pbs-client/src/pxar/create.rs
index e7053d9e..3cf2b35a 100644
--- a/pbs-client/src/pxar/create.rs
+++ b/pbs-client/src/pxar/create.rs
@@ -222,9 +222,9 @@ impl Archiver {
         }
     }
 
-    fn archive_dir_contents<'a, 'b, T: SeqWrite + Send>(
+    fn archive_dir_contents<'a, T: SeqWrite + Send>(
         &'a mut self,
-        encoder: &'a mut Encoder<'b, T>,
+        encoder: &'a mut Encoder<'_, T>,
         mut dir: Dir,
         is_root: bool,
     ) -> BoxFuture<'a, Result<(), Error>> {
diff --git a/src/api2/config/access/ldap.rs b/src/api2/config/access/ldap.rs
index 911142a0..e60dc9c1 100644
--- a/src/api2/config/access/ldap.rs
+++ b/src/api2/config/access/ldap.rs
@@ -337,7 +337,7 @@ pub fn update_ldap_realm(
         config.user_classes = Some(user_classes);
     }
 
-    let ldap_config = if let Some(_) = password {
+    let ldap_config = if password.is_some() {
         LdapAuthenticator::api_type_to_config_with_password(&config, password.clone())?
     } else {
         LdapAuthenticator::api_type_to_config(&config)?
diff --git a/src/server/pull.rs b/src/server/pull.rs
index 3b71c156..de9190a3 100644
--- a/src/server/pull.rs
+++ b/src/server/pull.rs
@@ -199,7 +199,7 @@ impl PullSource for RemoteSource {
         });
 
         if !namespace.is_root() {
-            args["ns"] = serde_json::to_value(&namespace)?;
+            args["ns"] = serde_json::to_value(namespace)?;
         }
 
         self.client.login().await?;
@@ -230,7 +230,7 @@ impl PullSource for RemoteSource {
     }
 
     fn get_store(&self) -> &str {
-        &self.repo.store()
+        self.repo.store()
     }
 
     async fn reader(
diff --git a/src/server/report.rs b/src/server/report.rs
index 3a804433..4fb91673 100644
--- a/src/server/report.rs
+++ b/src/server/report.rs
@@ -127,7 +127,7 @@ fn get_directory_content(path: impl AsRef<Path>) -> String {
             return format!(
                 "`$ cat '{}*'`\n```\n# read dir failed - {}\n```",
                 path.as_ref().display(),
-                err.to_string(),
+                err,
             );
         }
     };
@@ -137,7 +137,7 @@ fn get_directory_content(path: impl AsRef<Path>) -> String {
         let entry = match entry {
             Ok(entry) => entry,
             Err(err) => {
-                let _ = writeln!(out, "error during read-dir - {}", err.to_string());
+                let _ = writeln!(out, "error during read-dir - {}", err);
                 continue;
             }
         };
@@ -189,7 +189,7 @@ pub fn generate_report() -> String {
                 .map(|file_name| {
                     let path = Path::new(file_name);
                     if path.is_dir() {
-                        get_directory_content(&path)
+                        get_directory_content(path)
                     } else {
                         get_file_content(file_name)
                     }
diff --git a/src/tape/media_catalog.rs b/src/tape/media_catalog.rs
index 928d4701..9aae0aa1 100644
--- a/src/tape/media_catalog.rs
+++ b/src/tape/media_catalog.rs
@@ -1,6 +1,6 @@
 use std::collections::{HashMap, HashSet};
 use std::fs::File;
-use std::io::{BufReader, Read, Seek, SeekFrom, Write};
+use std::io::{BufReader, Read, Seek, Write};
 use std::os::unix::io::AsRawFd;
 use std::path::{Path, PathBuf};
 
@@ -795,7 +795,7 @@ impl MediaCatalog {
         let mut media_set_uuid = None;
 
         loop {
-            let pos = file.seek(SeekFrom::Current(0))?; // get current pos
+            let pos = file.stream_position()?; // get current pos
 
             if pos == 0 {
                 // read/check magic number
diff --git a/src/tools/disks/mod.rs b/src/tools/disks/mod.rs
index 7a772356..94f89e0a 100644
--- a/src/tools/disks/mod.rs
+++ b/src/tools/disks/mod.rs
@@ -1158,7 +1158,7 @@ pub fn wipe_blockdev(disk: &Disk, worker: Arc<WorkerTask>) -> Result<(), Error>
         of_path,
         "bs=1M".into(),
         "conv=fdatasync".into(),
-        count_str.into(),
+        count_str,
     ];
     dd_command.args(args);
 
@@ -1167,7 +1167,7 @@ pub fn wipe_blockdev(disk: &Disk, worker: Arc<WorkerTask>) -> Result<(), Error>
 
     if is_partition {
         // set the partition type to 0x83 'Linux filesystem'
-        change_parttype(&disk, "8300", worker)?;
+        change_parttype(disk, "8300", worker)?;
     }
 
     Ok(())
-- 
2.39.2





^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-12-06 11:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-06 11:08 [pbs-devel] [PATCH proxmox-backup] cleanup: fix some clippy lints Gabriel Goller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal