From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ronja.mits.lan by ronja.mits.lan with LMTP id wP0qOhMNfGbcEwAAxxbTJA (envelope-from ); Wed, 26 Jun 2024 14:44:03 +0200 Received: from proxmox-new.maurer-it.com (unknown [192.168.2.33]) by ronja.mits.lan (Postfix) with ESMTPS id D684BF6463A; Wed, 26 Jun 2024 14:44: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 B8E4148740; Wed, 26 Jun 2024 14:44:03 +0200 (CEST) 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 (4096 bits)) (No client certificate requested) by proxmox-new.maurer-it.com (Proxmox) with ESMTPS; Wed, 26 Jun 2024 14:44:02 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id ACCE2C49; Wed, 26 Jun 2024 14:43:57 +0200 (CEST) From: Maximiliano Sandoval To: pbs-devel@lists.proxmox.com Date: Wed, 26 Jun 2024 14:43:31 +0200 Message-Id: <20240626124346.531790-3-m.sandoval@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240626124346.531790-1-m.sandoval@proxmox.com> References: <20240626124346.531790-1-m.sandoval@proxmox.com> MIME-Version: 1.0 Subject: [pbs-devel] [PATCH proxmox v2 03/18] remove needless borrows 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: , Reply-To: Proxmox Backup Server development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" X-SPAM-LEVEL: Spam detection results: 0 DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods MAILING_LIST_MULTI -2 Multiple indicators imply a widely-seen list manager RAZOR2_CF_RANGE_51_100 2.43 Razor2 gives confidence level above 50% RAZOR2_CHECK 1.729 Listed in Razor2 (http://razor.sf.net/) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an SPF Record Fixes the following clippy warnings: warning: the borrowed expression implements the required traits --> proxmox-tfa/src/api/recovery.rs:86:24 | 86 | Ok(hex::encode(&hmac)) | ^^^^^ help: change this to: `hmac` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrows_for_generic_args and warning: this expression creates a reference which is immediately dereferenced by the compiler --> proxmox-network-api/src/api_impl.rs:108:47 | 108 | interface.set_bond_slave_list(&slaves)?; | ^^^^^^^ help: change this to: `slaves` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow = note: `#[warn(clippy::needless_borrow)]` on by default Signed-off-by: Maximiliano Sandoval --- proxmox-acme-api/src/account_api_impl.rs | 8 ++++---- proxmox-auth-api/src/pam_authenticator.rs | 2 +- proxmox-auth-api/src/ticket.rs | 2 +- proxmox-client/src/client.rs | 4 ++-- proxmox-network-api/src/api_impl.rs | 2 +- proxmox-tfa/src/api/recovery.rs | 4 ++-- proxmox-tfa/src/u2f.rs | 15 +++++++-------- 7 files changed, 18 insertions(+), 19 deletions(-) diff --git a/proxmox-acme-api/src/account_api_impl.rs b/proxmox-acme-api/src/account_api_impl.rs index 71880e62..3a06dcc6 100644 --- a/proxmox-acme-api/src/account_api_impl.rs +++ b/proxmox-acme-api/src/account_api_impl.rs @@ -70,7 +70,7 @@ pub async fn register_account( let account = AccountData::from_account_dir_tos(account, directory_url, tos_url); - super::account_config::create_account_config(&name, &account)?; + super::account_config::create_account_config(name, &account)?; Ok(account.location) } @@ -89,7 +89,7 @@ pub async fn deactivate_account( { Ok(account) => { account_data.account = account.data.clone(); - super::account_config::save_account_config(&name, &account_data)?; + super::account_config::save_account_config(name, &account_data)?; } Err(err) if !force => return Err(err), Err(err) => { @@ -102,7 +102,7 @@ pub async fn deactivate_account( } } - super::account_config::mark_account_deactivated(&name)?; + super::account_config::mark_account_deactivated(name)?; Ok(()) } @@ -120,7 +120,7 @@ pub async fn update_account(name: &AcmeAccountName, contact: Option) -> let account = client.update_account(&data).await?; account_data.account = account.data.clone(); - super::account_config::save_account_config(&name, &account_data)?; + super::account_config::save_account_config(name, &account_data)?; Ok(()) } diff --git a/proxmox-auth-api/src/pam_authenticator.rs b/proxmox-auth-api/src/pam_authenticator.rs index fb8e7e7e..d34575be 100644 --- a/proxmox-auth-api/src/pam_authenticator.rs +++ b/proxmox-auth-api/src/pam_authenticator.rs @@ -183,7 +183,7 @@ struct PamGuard<'a> { impl Drop for PamGuard<'_> { fn drop(&mut self) { - pam_sys::wrapped::end(&mut self.handle, self.result); + pam_sys::wrapped::end(self.handle, self.result); } } diff --git a/proxmox-auth-api/src/ticket.rs b/proxmox-auth-api/src/ticket.rs index ff088158..498e9385 100644 --- a/proxmox-auth-api/src/ticket.rs +++ b/proxmox-auth-api/src/ticket.rs @@ -160,7 +160,7 @@ where let is_valid = keyring.verify( MessageDigest::sha256(), - &signature, + signature, &self.verification_data(aad), )?; diff --git a/proxmox-client/src/client.rs b/proxmox-client/src/client.rs index 1cae2883..fe18097a 100644 --- a/proxmox-client/src/client.rs +++ b/proxmox-client/src/client.rs @@ -52,7 +52,7 @@ impl TlsOptions { .filter(|&b| b != b':') .collect(); - let fp = <[u8; 32]>::from_hex(&hex).map_err(|_| ParseFingerprintError)?; + let fp = <[u8; 32]>::from_hex(hex).map_err(|_| ParseFingerprintError)?; Ok(Self::Fingerprint(fp.into())) } @@ -469,7 +469,7 @@ fn verify_fingerprint(chain: &x509::X509StoreContextRef, expected_fingerprint: & if expected_fingerprint != fp.as_ref() { log::error!("bad fingerprint: {}", fp_string(&fp)); - log::error!("expected fingerprint: {}", fp_string(&expected_fingerprint)); + log::error!("expected fingerprint: {}", fp_string(expected_fingerprint)); return false; } diff --git a/proxmox-network-api/src/api_impl.rs b/proxmox-network-api/src/api_impl.rs index b3b9ec53..18602900 100644 --- a/proxmox-network-api/src/api_impl.rs +++ b/proxmox-network-api/src/api_impl.rs @@ -105,7 +105,7 @@ pub fn create_interface(iface: String, config: InterfaceUpdater) -> Result<(), E } } if let Some(slaves) = &config.slaves { - interface.set_bond_slave_list(&slaves)?; + interface.set_bond_slave_list(slaves)?; } } NetworkInterfaceType::Vlan => { diff --git a/proxmox-tfa/src/api/recovery.rs b/proxmox-tfa/src/api/recovery.rs index 970770b6..9629d6ff 100644 --- a/proxmox-tfa/src/api/recovery.rs +++ b/proxmox-tfa/src/api/recovery.rs @@ -49,7 +49,7 @@ impl Recovery { getrandom(&mut secret)?; let mut this = Self { - secret: hex::encode(&secret), + secret: hex::encode(secret), entries: Vec::with_capacity(10), created: proxmox_time::epoch_i64(), }; @@ -83,7 +83,7 @@ impl Recovery { .sign_oneshot_to_vec(data) .map_err(|err| format_err!("error calculating hmac: {}", err))?; - Ok(hex::encode(&hmac)) + Ok(hex::encode(hmac)) } /// Iterator over available keys. diff --git a/proxmox-tfa/src/u2f.rs b/proxmox-tfa/src/u2f.rs index 43907a19..ffd7d64c 100644 --- a/proxmox-tfa/src/u2f.rs +++ b/proxmox-tfa/src/u2f.rs @@ -36,9 +36,9 @@ impl StdError for Error { impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { - Error::Generic(e) => f.write_str(&e), - Error::Decode(m, _e) => f.write_str(&m), - Error::Ssl(m, _e) => f.write_str(&m), + Error::Generic(e) => f.write_str(e), + Error::Decode(m, _e) => f.write_str(m), + Error::Ssl(m, _e) => f.write_str(m), } } } @@ -604,14 +604,13 @@ mod bytes_as_base64 { use serde::{Deserialize, Deserializer, Serializer}; pub fn serialize(data: &[u8], serializer: S) -> Result { - serializer.serialize_str(&base64::encode(&data)) + serializer.serialize_str(&base64::encode(data)) } pub fn deserialize<'de, D: Deserializer<'de>>(deserializer: D) -> Result, D::Error> { 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()))) } } @@ -625,7 +624,7 @@ mod bytes_as_base64url_nopad { pub fn deserialize<'de, D: Deserializer<'de>>(deserializer: D) -> Result, D::Error> { 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())) }) } -- 2.39.2 _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel