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 4AAAFAB2B for ; Tue, 8 Aug 2023 10:02:05 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 2A85A669F for ; Tue, 8 Aug 2023 10:02:05 +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 ; Tue, 8 Aug 2023 10:02:03 +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 98D36436B4 for ; Tue, 8 Aug 2023 10:02:03 +0200 (CEST) From: Lukas Wagner To: pbs-devel@lists.proxmox.com Date: Tue, 8 Aug 2023 10:01:39 +0200 Message-Id: <20230808080153.79587-1-l.wagner@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 -1.455 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 FSL_BULK_SIG 0.001 Bulk signature with no Unsubscribe KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RAZOR2_CF_RANGE_51_100 1.886 Razor2 gives confidence level above 50% RAZOR2_CHECK 0.922 Listed in Razor2 (http://razor.sf.net/) SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [github.io, repository.rs, file.rs, check.rs, mod.rs, lib.rs] Subject: [pbs-devel] [PATCH proxmox 01/15] clippy fix: 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: Tue, 08 Aug 2023 08:02:05 -0000 See: https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow Signed-off-by: Lukas Wagner --- proxmox-apt/src/repositories/file.rs | 2 +- proxmox-apt/src/repositories/repository.rs | 2 +- proxmox-openid/src/auth_state.rs | 2 +- proxmox-rest-server/src/worker_task.rs | 10 +++++----- proxmox-schema/src/ser/mod.rs | 4 ++-- proxmox-serde/src/lib.rs | 9 ++++----- proxmox-subscription/src/check.rs | 2 +- 7 files changed, 15 insertions(+), 16 deletions(-) diff --git a/proxmox-apt/src/repositories/file.rs b/proxmox-apt/src/repositories/file.rs index b4c6b08..bfd7836 100644 --- a/proxmox-apt/src/repositories/file.rs +++ b/proxmox-apt/src/repositories/file.rs @@ -293,7 +293,7 @@ impl APTRepositoryFile { } if self.repositories.is_empty() { - return std::fs::remove_file(&path) + return std::fs::remove_file(path) .map_err(|err| self.err(format_err!("unable to remove file - {}", err))); } diff --git a/proxmox-apt/src/repositories/repository.rs b/proxmox-apt/src/repositories/repository.rs index c2df2c7..0b04802 100644 --- a/proxmox-apt/src/repositories/repository.rs +++ b/proxmox-apt/src/repositories/repository.rs @@ -414,7 +414,7 @@ fn uri_to_filename(uri: &str) -> String { if *b <= 0x20 || *b >= 0x7F || encode_chars.contains(*b as char) { let mut hex = [0u8; 2]; // unwrap: we're hex-encoding a single byte into a 2-byte slice - hex::encode_to_slice(&[*b], &mut hex).unwrap(); + hex::encode_to_slice([*b], &mut hex).unwrap(); let hex = unsafe { std::str::from_utf8_unchecked(&hex) }; encoded = format!("{}%{}", encoded, hex); } else { diff --git a/proxmox-openid/src/auth_state.rs b/proxmox-openid/src/auth_state.rs index 8d940ec..f2a299a 100644 --- a/proxmox-openid/src/auth_state.rs +++ b/proxmox-openid/src/auth_state.rs @@ -97,7 +97,7 @@ pub fn store_auth_state( bail!("too many pending openid auth request for realm {}", realm); } - data.push(serde_json::to_value(&auth_state)?); + data.push(serde_json::to_value(auth_state)?); replace_auth_state(&path, &data)?; diff --git a/proxmox-rest-server/src/worker_task.rs b/proxmox-rest-server/src/worker_task.rs index 6263ce7..54b6bc2 100644 --- a/proxmox-rest-server/src/worker_task.rs +++ b/proxmox-rest-server/src/worker_task.rs @@ -1023,11 +1023,11 @@ impl WorkerTaskContext for WorkerTask { fn log(&self, level: log::Level, message: &std::fmt::Arguments) { match level { - log::Level::Error => self.log_warning(&message.to_string()), - log::Level::Warn => self.log_warning(&message.to_string()), - log::Level::Info => self.log_message(&message.to_string()), - log::Level::Debug => self.log_message(&format!("DEBUG: {}", message)), - log::Level::Trace => self.log_message(&format!("TRACE: {}", message)), + log::Level::Error => self.log_warning(message.to_string()), + log::Level::Warn => self.log_warning(message.to_string()), + log::Level::Info => self.log_message(message.to_string()), + log::Level::Debug => self.log_message(format!("DEBUG: {}", message)), + log::Level::Trace => self.log_message(format!("TRACE: {}", message)), } } } diff --git a/proxmox-schema/src/ser/mod.rs b/proxmox-schema/src/ser/mod.rs index bcf473d..3dad6d6 100644 --- a/proxmox-schema/src/ser/mod.rs +++ b/proxmox-schema/src/ser/mod.rs @@ -448,7 +448,7 @@ impl Serializer for ElementSerializer { } fn serialize_str(mut self, v: &str) -> Result { - if v.contains(&['"', '\\', '\n']) { + if v.contains(['"', '\\', '\n']) { self.inner.write_char('"')?; crate::property_string::quote(v, &mut self.inner)?; self.inner.write_char('"')?; @@ -643,7 +643,7 @@ impl ElementSerializeSeq { fn finish(mut self) -> Result { let value = self.inner.finish()?; - if value.contains(&[',', ';', ' ', '"', '\\', '\n']) { + if value.contains([',', ';', ' ', '"', '\\', '\n']) { self.output.write_char('"')?; crate::property_string::quote(&value, &mut self.output)?; self.output.write_char('"')?; diff --git a/proxmox-serde/src/lib.rs b/proxmox-serde/src/lib.rs index e1dc16a..2f1ccca 100644 --- a/proxmox-serde/src/lib.rs +++ b/proxmox-serde/src/lib.rs @@ -86,9 +86,8 @@ pub mod bytes_as_base64 { D: Deserializer<'de>, { use serde::de::Error; - String::deserialize(deserializer).and_then(|string| { - base64::decode(&string).map_err(|err| Error::custom(err.to_string())) - }) + String::deserialize(deserializer) + .and_then(|string| base64::decode(string).map_err(|err| Error::custom(err.to_string()))) } } @@ -125,7 +124,7 @@ pub mod string_as_base64 { fn finish_deserializing<'de, D: Deserializer<'de>>(string: String) -> Result { use serde::de::Error; - let bytes = base64::decode(&string).map_err(|err| { + let bytes = base64::decode(string).map_err(|err| { let msg = format!("base64 decode: {}", err); Error::custom(msg) })?; @@ -219,7 +218,7 @@ pub mod bytes_as_base64url_nopad { { use serde::de::Error; String::deserialize(deserializer).and_then(|string| { - base64::decode_config(&string, base64::URL_SAFE_NO_PAD) + base64::decode_config(string, base64::URL_SAFE_NO_PAD) .map_err(|err| Error::custom(err.to_string())) }) } diff --git a/proxmox-subscription/src/check.rs b/proxmox-subscription/src/check.rs index 3838e9c..9d074ea 100644 --- a/proxmox-subscription/src/check.rs +++ b/proxmox-subscription/src/check.rs @@ -25,7 +25,7 @@ fn register_subscription>( client: C, ) -> Result<(String, String), Error> { // WHCMS sample code feeds the key into this, but it's just a challenge, so keep it simple - let rand = hex::encode(&proxmox_sys::linux::random_data(16)?); + let rand = hex::encode(proxmox_sys::linux::random_data(16)?); let challenge = format!("{}{}", checktime, rand); let params = json!({ -- 2.39.2