From: Maximiliano Sandoval <m.sandoval@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox v2 03/18] remove needless borrows
Date: Wed, 26 Jun 2024 14:43:31 +0200 [thread overview]
Message-ID: <20240626124346.531790-3-m.sandoval@proxmox.com> (raw)
In-Reply-To: <20240626124346.531790-1-m.sandoval@proxmox.com>
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 <m.sandoval@proxmox.com>
---
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<String>) ->
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<S: Serializer>(data: &[u8], serializer: S) -> Result<S::Ok, S::Error> {
- serializer.serialize_str(&base64::encode(&data))
+ serializer.serialize_str(&base64::encode(data))
}
pub fn deserialize<'de, D: Deserializer<'de>>(deserializer: D) -> Result<Vec<u8>, 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<Vec<u8>, 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
next prev parent reply other threads:[~2024-06-26 12:44 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-26 12:43 [pbs-devel] [PATCH proxmox v2 01/18] use unwrap_or_default instead of unwrap_or(Vec::new) Maximiliano Sandoval
2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 02/18] use contains_key instead of .get().is_{some, none}() Maximiliano Sandoval
2024-06-26 12:43 ` Maximiliano Sandoval [this message]
2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 04/18] remove unnecesary pub(self) Maximiliano Sandoval
2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 05/18] time-api: remove redundant field names Maximiliano Sandoval
2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 06/18] acme: remove duplicated attribute Maximiliano Sandoval
2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 07/18] acl: remove null pointer cast Maximiliano Sandoval
2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 08/18] use const blocks in thread_local! calls Maximiliano Sandoval
2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 09/18] remove unneeded returns Maximiliano Sandoval
2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 10/18] shared-memory: remove unneeded generic parameter Maximiliano Sandoval
2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 11/18] network-api: remove useless uses of format! Maximiliano Sandoval
2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 12/18] http: remove redundant redefinition of binding Maximiliano Sandoval
2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 13/18] http: remove unnecessary cast Maximiliano Sandoval
2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 14/18] acme: elide explicit lifetimes Maximiliano Sandoval
2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 15/18] acme: derive Default for Status Maximiliano Sandoval
2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 16/18] acl: directly return struct rather than a binding Maximiliano Sandoval
2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 17/18] acme-api: remove manual implementation of Option::map Maximiliano Sandoval
2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 18/18] auth-api: do not clone struct implementing Copy Maximiliano Sandoval
2024-06-28 9:44 ` [pbs-devel] applied-series: [PATCH proxmox v2 01/18] use unwrap_or_default instead of unwrap_or(Vec::new) Wolfgang Bumiller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240626124346.531790-3-m.sandoval@proxmox.com \
--to=m.sandoval@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox