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 9C0A1B8AF9 for ; Wed, 6 Dec 2023 12:08:14 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 7D4B737FCA for ; Wed, 6 Dec 2023 12:08:14 +0100 (CET) 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 ; Wed, 6 Dec 2023 12:08:13 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 433D940EF9 for ; Wed, 6 Dec 2023 12:08:13 +0100 (CET) From: Gabriel Goller To: pbs-devel@lists.proxmox.com Date: Wed, 6 Dec 2023 12:08:09 +0100 Message-Id: <20231206110809.130587-1-g.goller@proxmox.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.161 Adjusted score from AWL reputation of From: address 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 - URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [mod.rs, pull.rs, report.rs, create.rs, ldap.rs] Subject: [pbs-devel] [PATCH proxmox-backup] cleanup: fix some clippy lints 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: Wed, 06 Dec 2023 11:08:14 -0000 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 --- 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) -> 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) -> 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) -> 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) -> 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