public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox v2 01/18] use unwrap_or_default instead of unwrap_or(Vec::new)
@ 2024-06-26 12:43 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
                   ` (17 more replies)
  0 siblings, 18 replies; 19+ messages in thread
From: Maximiliano Sandoval @ 2024-06-26 12:43 UTC (permalink / raw)
  To: pbs-devel

Fixes the clippy warning:

warning: use of `unwrap_or_else` to construct default value
    --> proxmox-tfa/src/api/mod.rs:1355:43
     |
1355 |         |cap| cap.map(Vec::with_capacity).unwrap_or_else(Vec::new),
     |                                           ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()`
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_or_default
     = note: `#[warn(clippy::unwrap_or_default)]` on by default

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
Differences from v1:
- run rustfmt
- add missing negation from going to get().is_none() to contains_key()

 proxmox-tfa/src/api/mod.rs         | 2 +-
 proxmox-tfa/src/api/serde_tools.rs | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/proxmox-tfa/src/api/mod.rs b/proxmox-tfa/src/api/mod.rs
index f7aeea5a..16444f17 100644
--- a/proxmox-tfa/src/api/mod.rs
+++ b/proxmox-tfa/src/api/mod.rs
@@ -1352,7 +1352,7 @@ where
     let expire_before = proxmox_time::epoch_i64() - CHALLENGE_TIMEOUT_SECS;
     deserializer.deserialize_seq(serde_tools::fold(
         "a challenge entry",
-        |cap| cap.map(Vec::with_capacity).unwrap_or_else(Vec::new),
+        |cap| cap.map(Vec::with_capacity).unwrap_or_default(),
         move |out, reg: T| {
             if !reg.is_expired(expire_before) {
                 out.push(reg);
diff --git a/proxmox-tfa/src/api/serde_tools.rs b/proxmox-tfa/src/api/serde_tools.rs
index 8fbe0fc2..206128bd 100644
--- a/proxmox-tfa/src/api/serde_tools.rs
+++ b/proxmox-tfa/src/api/serde_tools.rs
@@ -83,7 +83,7 @@ where
 /// {
 ///     deserializer.deserialize_seq(proxmox_serde::fold(
 ///         "a sequence of integers",
-///         |cap| cap.map(Vec::with_capacity).unwrap_or_else(Vec::new),
+///         |cap| cap.map(Vec::with_capacity).unwrap_or_default(),
 ///         |out, num: u64| {
 ///             if num != 4 {
 ///                 out.push(num.to_string());
-- 
2.39.2



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel




^ permalink raw reply	[flat|nested] 19+ messages in thread

* [pbs-devel] [PATCH proxmox v2 02/18] use contains_key instead of .get().is_{some, none}()
  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 ` Maximiliano Sandoval
  2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 03/18] remove needless borrows Maximiliano Sandoval
                   ` (16 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: Maximiliano Sandoval @ 2024-06-26 12:43 UTC (permalink / raw)
  To: pbs-devel

Fixes the clippy lints:

warning: unnecessary use of `get("lo").is_none()`
   --> proxmox-network-api/src/config/parser.rs:603:30
    |
603 |         if config.interfaces.get("lo").is_none() {
    |            ------------------^^^^^^^^^^^^^^^^^^^
    |            |
    |            help: replace it with: `!config.interfaces.contains_key("lo")`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_get_then_check
    = note: `#[warn(clippy::unnecessary_get_then_check)]` on by default

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 proxmox-access-control/src/acl.rs        | 6 +++---
 proxmox-acme-api/src/plugin_config.rs    | 2 +-
 proxmox-network-api/src/config/parser.rs | 2 +-
 proxmox-section-config/src/lib.rs        | 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/proxmox-access-control/src/acl.rs b/proxmox-access-control/src/acl.rs
index b6b7b400..af68159c 100644
--- a/proxmox-access-control/src/acl.rs
+++ b/proxmox-access-control/src/acl.rs
@@ -973,14 +973,14 @@ mod test {
             let node = tree.find_node(path);
             assert!(node.is_some());
             if let Some(node) = node {
-                assert!(node.users.get(&user1).is_none());
+                assert!(!node.users.contains_key(&user1));
             }
         }
         for path in &user2_paths {
             let node = tree.find_node(path);
             assert!(node.is_some());
             if let Some(node) = node {
-                assert!(node.users.get(&user2).is_some());
+                assert!(node.users.contains_key(&user2));
             }
         }
 
@@ -990,7 +990,7 @@ mod test {
             let node = tree.find_node(path);
             assert!(node.is_some());
             if let Some(node) = node {
-                assert!(node.users.get(&user2).is_none());
+                assert!(!node.users.contains_key(&user2));
             }
         }
 
diff --git a/proxmox-acme-api/src/plugin_config.rs b/proxmox-acme-api/src/plugin_config.rs
index 4ebd0315..d75bea59 100644
--- a/proxmox-acme-api/src/plugin_config.rs
+++ b/proxmox-acme-api/src/plugin_config.rs
@@ -67,7 +67,7 @@ pub(crate) fn plugin_config() -> Result<(PluginData, ConfigDigest), Error> {
     let digest = ConfigDigest::from_slice(content.as_bytes());
     let mut data = CONFIG.parse(plugin_cfg_filename, &content)?;
 
-    if data.sections.get("standalone").is_none() {
+    if !data.sections.contains_key("standalone") {
         let standalone = StandalonePlugin::default();
         data.set_data("standalone", "standalone", &standalone)
             .unwrap();
diff --git a/proxmox-network-api/src/config/parser.rs b/proxmox-network-api/src/config/parser.rs
index dc8e2d0a..2d20b9e4 100644
--- a/proxmox-network-api/src/config/parser.rs
+++ b/proxmox-network-api/src/config/parser.rs
@@ -600,7 +600,7 @@ impl<R: BufRead> NetworkParser<R> {
             }
         }
 
-        if config.interfaces.get("lo").is_none() {
+        if !config.interfaces.contains_key("lo") {
             let mut interface = Interface::new(String::from("lo"));
             set_method_v4(&mut interface, NetworkConfigMethod::Loopback)?;
             interface.interface_type = NetworkInterfaceType::Loopback;
diff --git a/proxmox-section-config/src/lib.rs b/proxmox-section-config/src/lib.rs
index 526ee8f1..e36d8995 100644
--- a/proxmox-section-config/src/lib.rs
+++ b/proxmox-section-config/src/lib.rs
@@ -322,7 +322,7 @@ impl SectionConfig {
         let mut done = HashSet::new();
 
         for section_id in &config.order {
-            if config.sections.get(section_id).is_none() {
+            if !config.sections.contains_key(section_id) {
                 continue;
             };
             list.push(section_id);
-- 
2.39.2



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel




^ permalink raw reply	[flat|nested] 19+ messages in thread

* [pbs-devel] [PATCH proxmox v2 03/18] remove needless borrows
  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
  2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 04/18] remove unnecesary pub(self) Maximiliano Sandoval
                   ` (15 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: Maximiliano Sandoval @ 2024-06-26 12:43 UTC (permalink / raw)
  To: pbs-devel

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




^ permalink raw reply	[flat|nested] 19+ messages in thread

* [pbs-devel] [PATCH proxmox v2 04/18] remove unnecesary pub(self)
  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 ` [pbs-devel] [PATCH proxmox v2 03/18] remove needless borrows Maximiliano Sandoval
@ 2024-06-26 12:43 ` Maximiliano Sandoval
  2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 05/18] time-api: remove redundant field names Maximiliano Sandoval
                   ` (14 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: Maximiliano Sandoval @ 2024-06-26 12:43 UTC (permalink / raw)
  To: pbs-devel

Fixes the clippy warning:

warning: unnecessary `pub(self)`
    --> proxmox-tfa/src/api/mod.rs:1268:1
     |
1268 | pub(self) fn bool_is_false(v: &bool) -> bool {
     | ^^^^^^^^^ help: remove it
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pub_self

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 proxmox-auth-api/src/auth_key.rs | 2 +-
 proxmox-tfa/src/api/mod.rs       | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/proxmox-auth-api/src/auth_key.rs b/proxmox-auth-api/src/auth_key.rs
index 733ffba9..3ea4bbd3 100644
--- a/proxmox-auth-api/src/auth_key.rs
+++ b/proxmox-auth-api/src/auth_key.rs
@@ -86,7 +86,7 @@ impl PrivateKey {
         PublicKey::from_pem(&self.public_key_to_pem()?)
     }
 
-    pub(self) fn sign(&self, digest: MessageDigest, data: &[u8]) -> Result<Vec<u8>, Error> {
+    fn sign(&self, digest: MessageDigest, data: &[u8]) -> Result<Vec<u8>, Error> {
         let mut signer = if self.key.id() == Id::ED25519 {
             // ed25519 does not support signing with digest
             Signer::new_without_digest(&self.key)
diff --git a/proxmox-tfa/src/api/mod.rs b/proxmox-tfa/src/api/mod.rs
index 16444f17..1437aa1b 100644
--- a/proxmox-tfa/src/api/mod.rs
+++ b/proxmox-tfa/src/api/mod.rs
@@ -75,7 +75,7 @@ pub trait OpenUserChallengeData {
     }
 }
 
-pub(self) struct NoUserData;
+struct NoUserData;
 
 impl OpenUserChallengeData for NoUserData {
     fn open(&self, _userid: &str) -> Result<Box<dyn UserChallengeAccess>, Error> {
@@ -1265,7 +1265,7 @@ impl TfaChallenge {
     }
 }
 
-pub(self) fn bool_is_false(v: &bool) -> bool {
+fn bool_is_false(v: &bool) -> bool {
     !v
 }
 
-- 
2.39.2



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel




^ permalink raw reply	[flat|nested] 19+ messages in thread

* [pbs-devel] [PATCH proxmox v2 05/18] time-api: remove redundant field names
  2024-06-26 12:43 [pbs-devel] [PATCH proxmox v2 01/18] use unwrap_or_default instead of unwrap_or(Vec::new) Maximiliano Sandoval
                   ` (2 preceding siblings ...)
  2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 04/18] remove unnecesary pub(self) Maximiliano Sandoval
@ 2024-06-26 12:43 ` Maximiliano Sandoval
  2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 06/18] acme: remove duplicated attribute Maximiliano Sandoval
                   ` (13 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: Maximiliano Sandoval @ 2024-06-26 12:43 UTC (permalink / raw)
  To: pbs-devel

Fixes the clippy warning:

warning: redundant field names in struct initialization
  --> proxmox-time-api/src/time_impl.rs:53:9
   |
53 |         localtime: localtime,
   |         ^^^^^^^^^^^^^^^^^^^^ help: replace it with: `localtime`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 proxmox-time-api/src/time_impl.rs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/proxmox-time-api/src/time_impl.rs b/proxmox-time-api/src/time_impl.rs
index 3d5aee6f..a548c717 100644
--- a/proxmox-time-api/src/time_impl.rs
+++ b/proxmox-time-api/src/time_impl.rs
@@ -49,7 +49,7 @@ pub fn get_server_time_info() -> Result<ServerTimeInfo, Error> {
 
     Ok(ServerTimeInfo {
         timezone: read_etc_localtime()?,
-        time: time,
-        localtime: localtime,
+        time,
+        localtime,
     })
 }
-- 
2.39.2



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel




^ permalink raw reply	[flat|nested] 19+ messages in thread

* [pbs-devel] [PATCH proxmox v2 06/18] acme: remove duplicated attribute
  2024-06-26 12:43 [pbs-devel] [PATCH proxmox v2 01/18] use unwrap_or_default instead of unwrap_or(Vec::new) Maximiliano Sandoval
                   ` (3 preceding siblings ...)
  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 ` Maximiliano Sandoval
  2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 07/18] acl: remove null pointer cast Maximiliano Sandoval
                   ` (12 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: Maximiliano Sandoval @ 2024-06-26 12:43 UTC (permalink / raw)
  To: pbs-devel

Fixes the following clippy warning:

warning: duplicated attribute
  --> proxmox-acme/src/lib.rs:42:7
   |
42 | #[cfg(feature = "impl")]
   |       ^^^^^^^^^^^^^^^^
   |
note: first defined here
  --> proxmox-acme/src/lib.rs:41:7
   |
41 | #[cfg(feature = "impl")]
   |       ^^^^^^^^^^^^^^^^
help: remove this attribute
  --> proxmox-acme/src/lib.rs:42:7
   |
42 | #[cfg(feature = "impl")]
   |       ^^^^^^^^^^^^^^^^
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#duplicated_attributes
   = note: `#[warn(clippy::duplicated_attributes)]` on by default

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 proxmox-acme/src/lib.rs | 1 -
 1 file changed, 1 deletion(-)

diff --git a/proxmox-acme/src/lib.rs b/proxmox-acme/src/lib.rs
index b0374ecd..692691bf 100644
--- a/proxmox-acme/src/lib.rs
+++ b/proxmox-acme/src/lib.rs
@@ -39,7 +39,6 @@ pub mod directory;
 #[cfg(feature = "impl")]
 pub mod error;
 #[cfg(feature = "impl")]
-#[cfg(feature = "impl")]
 pub mod order;
 
 #[cfg(feature = "impl")]
-- 
2.39.2



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel




^ permalink raw reply	[flat|nested] 19+ messages in thread

* [pbs-devel] [PATCH proxmox v2 07/18] acl: remove null pointer cast
  2024-06-26 12:43 [pbs-devel] [PATCH proxmox v2 01/18] use unwrap_or_default instead of unwrap_or(Vec::new) Maximiliano Sandoval
                   ` (4 preceding siblings ...)
  2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 06/18] acme: remove duplicated attribute Maximiliano Sandoval
@ 2024-06-26 12:43 ` Maximiliano Sandoval
  2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 08/18] use const blocks in thread_local! calls Maximiliano Sandoval
                   ` (11 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: Maximiliano Sandoval @ 2024-06-26 12:43 UTC (permalink / raw)
  To: pbs-devel

Fixes the clippy warning:

warning: casting raw pointers to the same type and constness is unnecessary (`*mut fs::acl::libc::c_void` -> `*mut fs::acl::libc::c_void`)
   --> proxmox-sys/src/fs/acl.rs:130:23
    |
130 |         let mut ptr = ptr::null_mut() as *mut c_void;
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `ptr::null_mut()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast
    = note: `#[warn(clippy::unnecessary_cast)]` on by default

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 proxmox-sys/src/fs/acl.rs | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/proxmox-sys/src/fs/acl.rs b/proxmox-sys/src/fs/acl.rs
index 5ac01bc3..6f256008 100644
--- a/proxmox-sys/src/fs/acl.rs
+++ b/proxmox-sys/src/fs/acl.rs
@@ -127,7 +127,7 @@ impl ACL {
     }
 
     pub fn create_entry(&mut self) -> Result<ACLEntry, nix::errno::Errno> {
-        let mut ptr = ptr::null_mut() as *mut c_void;
+        let mut ptr = ptr::null_mut();
         let res = unsafe { acl_create_entry(&mut self.ptr, &mut ptr) };
         if res < 0 {
             return Err(Errno::last());
@@ -200,7 +200,7 @@ impl<'a> ACLEntry<'a> {
 
     pub fn get_permissions(&self) -> Result<u64, nix::errno::Errno> {
         let mut permissions = 0;
-        let mut permset = ptr::null_mut() as *mut c_void;
+        let mut permset = ptr::null_mut();
         let mut res = unsafe { acl_get_permset(self.ptr, &mut permset) };
         if res < 0 {
             return Err(Errno::last());
@@ -221,7 +221,7 @@ impl<'a> ACLEntry<'a> {
     }
 
     pub fn set_permissions(&mut self, permissions: u64) -> Result<u64, nix::errno::Errno> {
-        let mut permset = ptr::null_mut() as *mut c_void;
+        let mut permset = ptr::null_mut();
         let mut res = unsafe { acl_get_permset(self.ptr, &mut permset) };
         if res < 0 {
             return Err(Errno::last());
-- 
2.39.2



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel




^ permalink raw reply	[flat|nested] 19+ messages in thread

* [pbs-devel] [PATCH proxmox v2 08/18] use const blocks in thread_local! calls
  2024-06-26 12:43 [pbs-devel] [PATCH proxmox v2 01/18] use unwrap_or_default instead of unwrap_or(Vec::new) Maximiliano Sandoval
                   ` (5 preceding siblings ...)
  2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 07/18] acl: remove null pointer cast Maximiliano Sandoval
@ 2024-06-26 12:43 ` Maximiliano Sandoval
  2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 09/18] remove unneeded returns Maximiliano Sandoval
                   ` (10 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: Maximiliano Sandoval @ 2024-06-26 12:43 UTC (permalink / raw)
  To: pbs-devel

Fixes the clippy warning:

warning: initializer for `thread_local` value can be made `const`
   --> proxmox-router/src/cli/command.rs:221:71
    |
221 |     static HELP_CONTEXT: RefCell<Option<Arc<CommandLineInterface>>> = RefCell::new(None);
    |                                                                       ^^^^^^^^^^^^^^^^^^ help: replace with: `const { RefCell::new(None) }`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#thread_local_initializer_can_be_made_const
    = note: `#[warn(clippy::thread_local_initializer_can_be_made_const)]` on by default

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 proxmox-api-macro/src/lib.rs      | 2 +-
 proxmox-router/src/cli/command.rs | 2 +-
 proxmox-schema/src/de/mod.rs      | 2 +-
 proxmox-schema/src/de/verify.rs   | 4 ++--
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/proxmox-api-macro/src/lib.rs b/proxmox-api-macro/src/lib.rs
index 9888b76c..3c34b48b 100644
--- a/proxmox-api-macro/src/lib.rs
+++ b/proxmox-api-macro/src/lib.rs
@@ -313,7 +313,7 @@ pub fn derive_updater_type(item: TokenStream_1) -> TokenStream_1 {
     .into()
 }
 
-thread_local!(static NON_FATAL_ERRORS: RefCell<Option<TokenStream>> = RefCell::new(None));
+thread_local!(static NON_FATAL_ERRORS: RefCell<Option<TokenStream>> = const { RefCell::new(None) });
 
 /// The local error TLS must be freed at the end of a macro as any leftover `TokenStream` (even an
 /// empty one) will just panic between different runs as the multiple source files are handled by
diff --git a/proxmox-router/src/cli/command.rs b/proxmox-router/src/cli/command.rs
index a97c9d48..fca05e32 100644
--- a/proxmox-router/src/cli/command.rs
+++ b/proxmox-router/src/cli/command.rs
@@ -218,7 +218,7 @@ const API_METHOD_COMMAND_HELP: ApiMethod = ApiMethod::new(
 );
 
 std::thread_local! {
-    static HELP_CONTEXT: RefCell<Option<Arc<CommandLineInterface>>> = RefCell::new(None);
+    static HELP_CONTEXT: RefCell<Option<Arc<CommandLineInterface>>> = const { RefCell::new(None) };
 }
 
 fn help_command(
diff --git a/proxmox-schema/src/de/mod.rs b/proxmox-schema/src/de/mod.rs
index 09ccfeb3..79fb18e7 100644
--- a/proxmox-schema/src/de/mod.rs
+++ b/proxmox-schema/src/de/mod.rs
@@ -24,7 +24,7 @@ pub use no_schema::{split_list, SplitList};
 // Used to disable calling `check_constraints` on a `StringSchema` if it is being deserialized
 // for a `PropertyString`, which performs its own checking.
 thread_local! {
-    static IN_PROPERTY_STRING: Cell<bool> = Cell::new(false);
+    static IN_PROPERTY_STRING: Cell<bool> = const { Cell::new(false) };
 }
 
 pub(crate) struct InPropertyStringGuard;
diff --git a/proxmox-schema/src/de/verify.rs b/proxmox-schema/src/de/verify.rs
index 24a14772..615e69cf 100644
--- a/proxmox-schema/src/de/verify.rs
+++ b/proxmox-schema/src/de/verify.rs
@@ -16,8 +16,8 @@ struct VerifyState {
 }
 
 thread_local! {
-    static VERIFY_SCHEMA: RefCell<Option<VerifyState>> = RefCell::new(None);
-    static ERRORS: RefCell<Vec<(String, anyhow::Error)>> = RefCell::new(Vec::new());
+    static VERIFY_SCHEMA: RefCell<Option<VerifyState>> = const { RefCell::new(None) };
+    static ERRORS: RefCell<Vec<(String, anyhow::Error)>> = const { RefCell::new(Vec::new()) };
 }
 
 pub(crate) struct SchemaGuard(Option<VerifyState>);
-- 
2.39.2



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel




^ permalink raw reply	[flat|nested] 19+ messages in thread

* [pbs-devel] [PATCH proxmox v2 09/18] remove unneeded returns
  2024-06-26 12:43 [pbs-devel] [PATCH proxmox v2 01/18] use unwrap_or_default instead of unwrap_or(Vec::new) Maximiliano Sandoval
                   ` (6 preceding siblings ...)
  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 ` Maximiliano Sandoval
  2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 10/18] shared-memory: remove unneeded generic parameter Maximiliano Sandoval
                   ` (9 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: Maximiliano Sandoval @ 2024-06-26 12:43 UTC (permalink / raw)
  To: pbs-devel

Fixes the clippy warning:

warning: unneeded `return` statement
   --> proxmox-tfa/src/api/mod.rs:468:17
    |
468 | /                 return TfaResult::Failure {
469 | |                     needs_saving: true,
470 | |                     tfa_limit_reached,
471 | |                     totp_limit_reached,
472 | |                 };
    | |_________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
    = note: `#[warn(clippy::needless_return)]` on by default
help: remove `return`
    |
468 ~                 TfaResult::Failure {
469 +                     needs_saving: true,
470 +                     tfa_limit_reached,
471 +                     totp_limit_reached,
472 ~                 }
    |

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 proxmox-notify/src/context/pbs.rs | 2 +-
 proxmox-notify/src/context/pve.rs | 2 +-
 proxmox-tfa/src/api/mod.rs        | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/proxmox-notify/src/context/pbs.rs b/proxmox-notify/src/context/pbs.rs
index 2de305f5..09c555e4 100644
--- a/proxmox-notify/src/context/pbs.rs
+++ b/proxmox-notify/src/context/pbs.rs
@@ -101,7 +101,7 @@ impl Context for PBSContext {
     }
 
     fn default_config(&self) -> &'static str {
-        return DEFAULT_CONFIG;
+        DEFAULT_CONFIG
     }
 
     fn lookup_template(
diff --git a/proxmox-notify/src/context/pve.rs b/proxmox-notify/src/context/pve.rs
index 647f7c89..d49ab27c 100644
--- a/proxmox-notify/src/context/pve.rs
+++ b/proxmox-notify/src/context/pve.rs
@@ -51,7 +51,7 @@ impl Context for PVEContext {
     }
 
     fn default_config(&self) -> &'static str {
-        return DEFAULT_CONFIG;
+        DEFAULT_CONFIG
     }
 
     fn lookup_template(
diff --git a/proxmox-tfa/src/api/mod.rs b/proxmox-tfa/src/api/mod.rs
index 1437aa1b..7f4bbb31 100644
--- a/proxmox-tfa/src/api/mod.rs
+++ b/proxmox-tfa/src/api/mod.rs
@@ -465,11 +465,11 @@ impl TfaConfig {
                         Some(proxmox_time::epoch_i64() + access.tfa_failure_lock_time());
                 }
 
-                return TfaResult::Failure {
+                TfaResult::Failure {
                     needs_saving: true,
                     tfa_limit_reached,
                     totp_limit_reached,
-                };
+                }
             }
         }
     }
-- 
2.39.2



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel




^ permalink raw reply	[flat|nested] 19+ messages in thread

* [pbs-devel] [PATCH proxmox v2 10/18] shared-memory: remove unneeded generic parameter
  2024-06-26 12:43 [pbs-devel] [PATCH proxmox v2 01/18] use unwrap_or_default instead of unwrap_or(Vec::new) Maximiliano Sandoval
                   ` (7 preceding siblings ...)
  2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 09/18] remove unneeded returns Maximiliano Sandoval
@ 2024-06-26 12:43 ` Maximiliano Sandoval
  2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 11/18] network-api: remove useless uses of format! Maximiliano Sandoval
                   ` (8 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: Maximiliano Sandoval @ 2024-06-26 12:43 UTC (permalink / raw)
  To: pbs-devel

Fixes the clippy warning:

warning: type parameter `T` goes unused in function definition
  --> proxmox-shared-memory/tests/raw_shared_mutex.rs:80:19
   |
80 | fn create_test_dir<T: Init>(filename: &str) -> Option<PathBuf> {
   |                   ^^^^^^^^^ help: consider removing the parameter
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#extra_unused_type_parameters
   = note: `#[warn(clippy::extra_unused_type_parameters)]` on by default

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 proxmox-shared-memory/tests/raw_shared_mutex.rs | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/proxmox-shared-memory/tests/raw_shared_mutex.rs b/proxmox-shared-memory/tests/raw_shared_mutex.rs
index fff37c0c..7608377e 100644
--- a/proxmox-shared-memory/tests/raw_shared_mutex.rs
+++ b/proxmox-shared-memory/tests/raw_shared_mutex.rs
@@ -77,7 +77,7 @@ impl Init for MultiMutexData {
     }
 }
 
-fn create_test_dir<T: Init>(filename: &str) -> Option<PathBuf> {
+fn create_test_dir(filename: &str) -> Option<PathBuf> {
     let test_dir: String = env!("CARGO_TARGET_TMPDIR").to_string();
 
     let mut path = PathBuf::from(&test_dir);
@@ -100,7 +100,7 @@ fn create_test_dir<T: Init>(filename: &str) -> Option<PathBuf> {
 }
 #[test]
 fn test_shared_memory_mutex() -> Result<(), Error> {
-    let path = match create_test_dir::<SingleMutexData>("data1.shm") {
+    let path = match create_test_dir("data1.shm") {
         None => {
             return Ok(()); // no O_TMPFILE support, can't run test
         }
@@ -138,7 +138,7 @@ fn test_shared_memory_mutex() -> Result<(), Error> {
 
 #[test]
 fn test_shared_memory_multi_mutex() -> Result<(), Error> {
-    let path = match create_test_dir::<SingleMutexData>("data2.shm") {
+    let path = match create_test_dir("data2.shm") {
         None => {
             return Ok(()); // no O_TMPFILE support, can't run test
         }
-- 
2.39.2



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel




^ permalink raw reply	[flat|nested] 19+ messages in thread

* [pbs-devel] [PATCH proxmox v2 11/18] network-api: remove useless uses of format!
  2024-06-26 12:43 [pbs-devel] [PATCH proxmox v2 01/18] use unwrap_or_default instead of unwrap_or(Vec::new) Maximiliano Sandoval
                   ` (8 preceding siblings ...)
  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 ` Maximiliano Sandoval
  2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 12/18] http: remove redundant redefinition of binding Maximiliano Sandoval
                   ` (7 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: Maximiliano Sandoval @ 2024-06-26 12:43 UTC (permalink / raw)
  To: pbs-devel

Fixes the clippy warning:

warning: useless use of `format!`
   --> proxmox-network-api/src/config/mod.rs:632:13
    |
632 | /             format!(
633 | |                 r#"
634 | | iface enp3s0 inet static
635 | |     address 10.0.0.100/16
636 | |     gateway 10.0.0.1"#
637 | |             )
    | |_____________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_format
help: consider using `.to_string()`
    |
632 ~             r#"
633 + iface enp3s0 inet static
634 ~     address 10.0.0.100/16
635 ~     gateway 10.0.0.1"#.to_string()

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 proxmox-network-api/src/config/mod.rs | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/proxmox-network-api/src/config/mod.rs b/proxmox-network-api/src/config/mod.rs
index b53279e2..22bf9bbb 100644
--- a/proxmox-network-api/src/config/mod.rs
+++ b/proxmox-network-api/src/config/mod.rs
@@ -604,12 +604,11 @@ mod tests {
         };
         assert_eq!(
             String::try_from(nw_config).unwrap().trim(),
-            format!(
-                r#"
+            r#"
 iface enp3s0 inet static
 	address 10.0.0.100/16"#
-            )
-            .trim()
+                .to_string()
+                .trim()
         );
     }
 
@@ -629,13 +628,12 @@ iface enp3s0 inet static
         };
         assert_eq!(
             String::try_from(nw_config).unwrap().trim(),
-            format!(
-                r#"
+            r#"
 iface enp3s0 inet static
 	address 10.0.0.100/16
 	gateway 10.0.0.1"#
-            )
-            .trim()
+                .to_string()
+                .trim()
         );
     }
 
-- 
2.39.2



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel




^ permalink raw reply	[flat|nested] 19+ messages in thread

* [pbs-devel] [PATCH proxmox v2 12/18] http: remove redundant redefinition of binding
  2024-06-26 12:43 [pbs-devel] [PATCH proxmox v2 01/18] use unwrap_or_default instead of unwrap_or(Vec::new) Maximiliano Sandoval
                   ` (9 preceding siblings ...)
  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 ` Maximiliano Sandoval
  2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 13/18] http: remove unnecessary cast Maximiliano Sandoval
                   ` (6 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: Maximiliano Sandoval @ 2024-06-26 12:43 UTC (permalink / raw)
  To: pbs-devel

Fixes the clippy error:

error: redundant redefinition of a binding `data`
   --> proxmox-http/src/websocket/mod.rs:375:9
    |
375 |         let data = data;
    |         ^^^^^^^^^^^^^^^^
    |
help: `data` is initially defined here
   --> proxmox-http/src/websocket/mod.rs:369:27
    |
369 |     pub fn try_from_bytes(data: &[u8]) -> Result<Option<FrameHeader>, WebSocketError> {
    |                           ^^^^
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_locals
    = note: `#[deny(clippy::redundant_locals)]` on by default

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 proxmox-http/src/websocket/mod.rs | 2 --
 1 file changed, 2 deletions(-)

diff --git a/proxmox-http/src/websocket/mod.rs b/proxmox-http/src/websocket/mod.rs
index 2efc06ae..b3179e1f 100644
--- a/proxmox-http/src/websocket/mod.rs
+++ b/proxmox-http/src/websocket/mod.rs
@@ -372,8 +372,6 @@ impl FrameHeader {
             return Ok(None);
         }
 
-        let data = data;
-
         // we do not support extensions
         if data[0] & 0b01110000 > 0 {
             return Err(WebSocketError::new(
-- 
2.39.2



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel




^ permalink raw reply	[flat|nested] 19+ messages in thread

* [pbs-devel] [PATCH proxmox v2 13/18] http: remove unnecessary cast
  2024-06-26 12:43 [pbs-devel] [PATCH proxmox v2 01/18] use unwrap_or_default instead of unwrap_or(Vec::new) Maximiliano Sandoval
                   ` (10 preceding siblings ...)
  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 ` Maximiliano Sandoval
  2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 14/18] acme: elide explicit lifetimes Maximiliano Sandoval
                   ` (5 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: Maximiliano Sandoval @ 2024-06-26 12:43 UTC (permalink / raw)
  To: pbs-devel

Fixes the clippy warning:

warning: casting to the same type is unnecessary (`usize` -> `usize`)
   --> proxmox-http/src/websocket/mod.rs:446:40
    |
446 |             mask.copy_from_slice(&data[mask_offset as usize..payload_offset as usize]);
    |                                        ^^^^^^^^^^^^^^^^^^^^ help: try: `mask_offset`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast
    = note: `#[warn(clippy::unnecessary_cast)]` on by default

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 proxmox-http/src/websocket/mod.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/proxmox-http/src/websocket/mod.rs b/proxmox-http/src/websocket/mod.rs
index b3179e1f..6d3faea6 100644
--- a/proxmox-http/src/websocket/mod.rs
+++ b/proxmox-http/src/websocket/mod.rs
@@ -441,7 +441,7 @@ impl FrameHeader {
                 return Ok(None);
             }
             let mut mask = [0u8; 4];
-            mask.copy_from_slice(&data[mask_offset as usize..payload_offset as usize]);
+            mask.copy_from_slice(&data[mask_offset..payload_offset as usize]);
             Some(mask)
         } else {
             None
-- 
2.39.2



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel




^ permalink raw reply	[flat|nested] 19+ messages in thread

* [pbs-devel] [PATCH proxmox v2 14/18] acme: elide explicit lifetimes
  2024-06-26 12:43 [pbs-devel] [PATCH proxmox v2 01/18] use unwrap_or_default instead of unwrap_or(Vec::new) Maximiliano Sandoval
                   ` (11 preceding siblings ...)
  2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 13/18] http: remove unnecessary cast Maximiliano Sandoval
@ 2024-06-26 12:43 ` Maximiliano Sandoval
  2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 15/18] acme: derive Default for Status Maximiliano Sandoval
                   ` (4 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: Maximiliano Sandoval @ 2024-06-26 12:43 UTC (permalink / raw)
  To: pbs-devel

Fixes the clippy warning:

warning: the following explicit lifetimes could be elided: 'a
  --> proxmox-acme/src/async_client.rs:65:30
   |
65 |     pub async fn new_account<'a>(
   |                              ^^
66 |         &'a mut self,
   |          ^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes
   = note: `#[warn(clippy::needless_lifetimes)]` on by default

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 proxmox-acme/src/async_client.rs | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/proxmox-acme/src/async_client.rs b/proxmox-acme/src/async_client.rs
index 51365c7e..ce5a6c79 100644
--- a/proxmox-acme/src/async_client.rs
+++ b/proxmox-acme/src/async_client.rs
@@ -62,13 +62,13 @@ impl AcmeClient {
     ///
     /// If an RSA key size is provided, an RSA key will be generated. Otherwise an EC key using the
     /// P-256 curve will be generated.
-    pub async fn new_account<'a>(
-        &'a mut self,
+    pub async fn new_account(
+        &mut self,
         tos_agreed: bool,
         contact: Vec<String>,
         rsa_bits: Option<u32>,
         eab_creds: Option<(String, String)>,
-    ) -> Result<&'a Account, anyhow::Error> {
+    ) -> Result<&Account, anyhow::Error> {
         let mut account = Account::creator()
             .set_contacts(contact)
             .agree_to_tos(tos_agreed);
-- 
2.39.2



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel




^ permalink raw reply	[flat|nested] 19+ messages in thread

* [pbs-devel] [PATCH proxmox v2 15/18] acme: derive Default for Status
  2024-06-26 12:43 [pbs-devel] [PATCH proxmox v2 01/18] use unwrap_or_default instead of unwrap_or(Vec::new) Maximiliano Sandoval
                   ` (12 preceding siblings ...)
  2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 14/18] acme: elide explicit lifetimes Maximiliano Sandoval
@ 2024-06-26 12:43 ` Maximiliano Sandoval
  2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 16/18] acl: directly return struct rather than a binding Maximiliano Sandoval
                   ` (3 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: Maximiliano Sandoval @ 2024-06-26 12:43 UTC (permalink / raw)
  To: pbs-devel

Fixes the clippy warning:

warning: this `impl` can be derived
  --> proxmox-acme/src/order.rs:36:1
   |
36 | / impl Default for Status {
37 | |     fn default() -> Self {
38 | |         Status::New
39 | |     }
40 | | }
   | |_^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derivable_impls
   = note: `#[warn(clippy::derivable_impls)]` on by default
   = help: remove the manual implementation...
help: ...and instead derive it...
   |
12 + #[derive(Default)]
13 | pub enum Status {
   |
help: ...and mark the default variant
   |
15 ~     #[default]
16 ~     New,
   |

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 proxmox-acme/src/order.rs | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/proxmox-acme/src/order.rs b/proxmox-acme/src/order.rs
index 404d4ae7..b6551004 100644
--- a/proxmox-acme/src/order.rs
+++ b/proxmox-acme/src/order.rs
@@ -9,9 +9,11 @@ use crate::Error;
 /// Status of an [`Order`].
 #[derive(Clone, Copy, Debug, Eq, PartialEq, Deserialize, Serialize)]
 #[serde(rename_all = "lowercase")]
+#[derive(Default)]
 pub enum Status {
     /// Invalid, used as a place holder for when sending objects as contrary to account creation,
     /// the Acme RFC does not require the server to ignore unknown parts of the `Order` object.
+    #[default]
     New,
 
     /// Authorization failed and it is now invalid.
@@ -33,12 +35,6 @@ pub enum Status {
     Valid,
 }
 
-impl Default for Status {
-    fn default() -> Self {
-        Status::New
-    }
-}
-
 impl Status {
     /// Serde helper
     fn is_new(&self) -> bool {
-- 
2.39.2



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel




^ permalink raw reply	[flat|nested] 19+ messages in thread

* [pbs-devel] [PATCH proxmox v2 16/18] acl: directly return struct rather than a binding
  2024-06-26 12:43 [pbs-devel] [PATCH proxmox v2 01/18] use unwrap_or_default instead of unwrap_or(Vec::new) Maximiliano Sandoval
                   ` (13 preceding siblings ...)
  2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 15/18] acme: derive Default for Status Maximiliano Sandoval
@ 2024-06-26 12:43 ` Maximiliano Sandoval
  2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 17/18] acme-api: remove manual implementation of Option::map Maximiliano Sandoval
                   ` (2 subsequent siblings)
  17 siblings, 0 replies; 19+ messages in thread
From: Maximiliano Sandoval @ 2024-06-26 12:43 UTC (permalink / raw)
  To: pbs-devel

Fixes the following clippy warning:

warning: returning the result of a `let` binding from a block
   --> proxmox-access-control/src/acl.rs:687:13
    |
686 |             let config = TestAcmConfig { roles };
    |             ------------------------------------- unnecessary `let` binding
687 |             config
    |             ^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#let_and_return
    = note: `#[warn(clippy::let_and_return)]` on by default
help: return the expression directly
    |
686 ~
687 ~             TestAcmConfig { roles }
    |

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 proxmox-access-control/src/acl.rs | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/proxmox-access-control/src/acl.rs b/proxmox-access-control/src/acl.rs
index af68159c..80f71367 100644
--- a/proxmox-access-control/src/acl.rs
+++ b/proxmox-access-control/src/acl.rs
@@ -683,8 +683,7 @@ mod test {
             roles.insert("DatastoreBackup", 4);
             roles.insert("DatastoreReader", 8);
 
-            let config = TestAcmConfig { roles };
-            config
+            TestAcmConfig { roles }
         });
 
         // ignore errors here, we don't care if it's initialized already
-- 
2.39.2



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel




^ permalink raw reply	[flat|nested] 19+ messages in thread

* [pbs-devel] [PATCH proxmox v2 17/18] acme-api: remove manual implementation of Option::map
  2024-06-26 12:43 [pbs-devel] [PATCH proxmox v2 01/18] use unwrap_or_default instead of unwrap_or(Vec::new) Maximiliano Sandoval
                   ` (14 preceding siblings ...)
  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 ` 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
  17 siblings, 0 replies; 19+ messages in thread
From: Maximiliano Sandoval @ 2024-06-26 12:43 UTC (permalink / raw)
  To: pbs-devel

Fixes the clippy warning:

warning: manual implementation of `Option::map`
   --> proxmox-acme-api/src/certificate_helpers.rs:346:32
    |
346 |                           } else if let Some(uri) = name.uri() {
    |  ________________________________^
347 | |                             Some(format!("URI: {uri}"))
348 | |                         } else {
349 | |                             None
350 | |                         }
    | |_________________________^ help: try: `{ name.uri().map(|uri| format!("URI: {uri}")) }`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_map
    = note: `#[warn(clippy::manual_map)]` on by default

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 proxmox-acme-api/src/certificate_helpers.rs | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/proxmox-acme-api/src/certificate_helpers.rs b/proxmox-acme-api/src/certificate_helpers.rs
index dd8385e2..3af762b1 100644
--- a/proxmox-acme-api/src/certificate_helpers.rs
+++ b/proxmox-acme-api/src/certificate_helpers.rs
@@ -343,10 +343,8 @@ impl CertificateInfo {
                             Some(format!("IP: {ip:?}"))
                         } else if let Some(email) = name.email() {
                             Some(format!("EMAIL: {email}"))
-                        } else if let Some(uri) = name.uri() {
-                            Some(format!("URI: {uri}"))
                         } else {
-                            None
+                            name.uri().map(|uri| format!("URI: {uri}"))
                         }
                     })
                     .collect()
-- 
2.39.2



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel




^ permalink raw reply	[flat|nested] 19+ messages in thread

* [pbs-devel] [PATCH proxmox v2 18/18] auth-api: do not clone struct implementing Copy
  2024-06-26 12:43 [pbs-devel] [PATCH proxmox v2 01/18] use unwrap_or_default instead of unwrap_or(Vec::new) Maximiliano Sandoval
                   ` (15 preceding siblings ...)
  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 ` 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
  17 siblings, 0 replies; 19+ messages in thread
From: Maximiliano Sandoval @ 2024-06-26 12:43 UTC (permalink / raw)
  To: pbs-devel

Fixes the clippy warning:

warning: using `clone` on type `Option<&dyn AuthContext>` which implements the `Copy` trait
   --> proxmox-auth-api/src/api/mod.rs:111:5
    |
111 | /     AUTH_CONTEXT
112 | |         .lock()
113 | |         .unwrap()
114 | |         .clone()
    | |________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy
    = note: `#[warn(clippy::clone_on_copy)]` on by default
help: try dereferencing it
    |
111 ~     (*AUTH_CONTEXT
112 +         .lock()
113 +         .unwrap())
    |

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 proxmox-auth-api/src/api/mod.rs | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/proxmox-auth-api/src/api/mod.rs b/proxmox-auth-api/src/api/mod.rs
index c4e507c3..82b4d42a 100644
--- a/proxmox-auth-api/src/api/mod.rs
+++ b/proxmox-auth-api/src/api/mod.rs
@@ -108,11 +108,7 @@ pub fn set_auth_context(auth_context: &'static dyn AuthContext) {
 }
 
 fn auth_context() -> Result<&'static dyn AuthContext, Error> {
-    AUTH_CONTEXT
-        .lock()
-        .unwrap()
-        .clone()
-        .ok_or_else(|| format_err!("no realm access configured"))
+    (*AUTH_CONTEXT.lock().unwrap()).ok_or_else(|| format_err!("no realm access configured"))
 }
 
 struct UserAuthData {
-- 
2.39.2



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel




^ permalink raw reply	[flat|nested] 19+ messages in thread

* [pbs-devel] applied-series: [PATCH proxmox v2 01/18] use unwrap_or_default instead of unwrap_or(Vec::new)
  2024-06-26 12:43 [pbs-devel] [PATCH proxmox v2 01/18] use unwrap_or_default instead of unwrap_or(Vec::new) Maximiliano Sandoval
                   ` (16 preceding siblings ...)
  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 ` Wolfgang Bumiller
  17 siblings, 0 replies; 19+ messages in thread
From: Wolfgang Bumiller @ 2024-06-28  9:44 UTC (permalink / raw)
  To: Maximiliano Sandoval; +Cc: pbs-devel

applied series except for the acme-api one, this one gets an #[allow]
instead, since it follows a pattern that becomes less readable with the
suggested change


_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2024-06-28  9:45 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [pbs-devel] [PATCH proxmox v2 03/18] remove needless borrows Maximiliano Sandoval
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal