public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH backup v2 1/6] replace get(key).is_some() with contains_key()
@ 2024-06-26 13:05 Maximiliano Sandoval
  2024-06-26 13:05 ` [pbs-devel] [PATCH backup v2 2/6] replace get(key).is_none() with !contains_key() Maximiliano Sandoval
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Maximiliano Sandoval @ 2024-06-26 13:05 UTC (permalink / raw)
  To: pbs-devel

Fixes the clippy warning:

warning: unnecessary use of `get(realm).is_some()`
  --> pbs-config/src/domains.rs:68:58
   |
68 |     realm == "pbs" || realm == "pam" || domains.sections.get(realm).is_some()
   |                                                          ^^^^^^^^^^^^^^^^^^^^ help: replace it with: `contains_key(realm)`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_get_then_check

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 pbs-config/src/acl.rs                   |  2 +-
 pbs-config/src/domains.rs               |  2 +-
 pbs-datastore/src/prune.rs              |  2 +-
 src/api2/access/user.rs                 | 28 ++++++++++---------------
 src/api2/config/changer.rs              |  2 +-
 src/api2/config/datastore.rs            |  2 +-
 src/api2/config/drive.rs                |  2 +-
 src/api2/config/media_pool.rs           | 11 +++++-----
 src/api2/config/metrics/influxdbhttp.rs |  2 +-
 src/api2/config/metrics/influxdbudp.rs  |  2 +-
 src/api2/config/prune.rs                |  2 +-
 src/api2/config/remote.rs               | 11 +++++-----
 src/api2/config/sync.rs                 |  2 +-
 src/api2/config/tape_backup_job.rs      |  2 +-
 src/api2/config/traffic_control.rs      | 11 +++++-----
 src/api2/config/verify.rs               |  2 +-
 src/api2/node/disks/directory.rs        |  2 +-
 src/api2/node/disks/zfs.rs              |  2 +-
 src/api2/tape/media.rs                  |  2 +-
 src/tape/encryption_keys.rs             |  2 +-
 src/tape/media_catalog.rs               |  2 +-
 21 files changed, 43 insertions(+), 52 deletions(-)

diff --git a/pbs-config/src/acl.rs b/pbs-config/src/acl.rs
index f78d69cd..8a1423cc 100644
--- a/pbs-config/src/acl.rs
+++ b/pbs-config/src/acl.rs
@@ -1054,7 +1054,7 @@ acl:1:/storage/store1:user1@pbs:DatastoreBackup
             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));
             }
         }
 
diff --git a/pbs-config/src/domains.rs b/pbs-config/src/domains.rs
index 4a9beec3..5b6ce480 100644
--- a/pbs-config/src/domains.rs
+++ b/pbs-config/src/domains.rs
@@ -65,7 +65,7 @@ pub fn save_config(config: &SectionConfigData) -> Result<(), Error> {
 
 /// Check if a realm with the given name exists
 pub fn exists(domains: &SectionConfigData, realm: &str) -> bool {
-    realm == "pbs" || realm == "pam" || domains.sections.get(realm).is_some()
+    realm == "pbs" || realm == "pam" || domains.sections.contains_key(realm)
 }
 
 // shell completion helper
diff --git a/pbs-datastore/src/prune.rs b/pbs-datastore/src/prune.rs
index 96da5826..ad1493bf 100644
--- a/pbs-datastore/src/prune.rs
+++ b/pbs-datastore/src/prune.rs
@@ -55,7 +55,7 @@ fn mark_selections<F: Fn(&BackupInfo) -> Result<String, Error>>(
 
     for info in list {
         let backup_id = info.backup_dir.relative_path();
-        if mark.get(&backup_id).is_some() {
+        if mark.contains_key(&backup_id) {
             continue;
         }
         if info.protected {
diff --git a/src/api2/access/user.rs b/src/api2/access/user.rs
index e2b74237..97cf520a 100644
--- a/src/api2/access/user.rs
+++ b/src/api2/access/user.rs
@@ -147,11 +147,7 @@ pub fn create_user(
 
     let (mut section_config, _digest) = pbs_config::user::config()?;
 
-    if section_config
-        .sections
-        .get(config.userid.as_str())
-        .is_some()
-    {
+    if section_config.sections.contains_key(config.userid.as_str()) {
         bail!("user '{}' already exists.", config.userid);
     }
 
@@ -375,11 +371,10 @@ pub fn delete_user(userid: Userid, digest: Option<String>) -> Result<(), Error>
         crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
     }
 
-    match config.sections.get(userid.as_str()) {
-        Some(_) => {
-            config.sections.remove(userid.as_str());
-        }
-        None => bail!("user '{}' does not exist.", userid),
+    if config.sections.contains_key(userid.as_str()) {
+        config.sections.remove(userid.as_str());
+    } else {
+        bail!("user '{}' does not exist.", userid);
     }
 
     pbs_config::user::save_config(&config)?;
@@ -503,7 +498,7 @@ pub fn generate_token(
     let tokenid = Authid::from((userid.clone(), Some(token_name.clone())));
     let tokenid_string = tokenid.to_string();
 
-    if config.sections.get(&tokenid_string).is_some() {
+    if config.sections.contains_key(&tokenid_string) {
         bail!(
             "token '{}' for user '{}' already exists.",
             token_name.as_str(),
@@ -654,15 +649,14 @@ pub fn delete_token(
     let tokenid = Authid::from((userid.clone(), Some(token_name.clone())));
     let tokenid_string = tokenid.to_string();
 
-    match config.sections.get(&tokenid_string) {
-        Some(_) => {
-            config.sections.remove(&tokenid_string);
-        }
-        None => bail!(
+    if config.sections.contains_key(&tokenid_string) {
+        config.sections.remove(&tokenid_string);
+    } else {
+        bail!(
             "token '{}' of user '{}' does not exist.",
             token_name.as_str(),
             userid
-        ),
+        );
     }
 
     token_shadow::delete_secret(&tokenid)?;
diff --git a/src/api2/config/changer.rs b/src/api2/config/changer.rs
index 91286697..31a15aba 100644
--- a/src/api2/config/changer.rs
+++ b/src/api2/config/changer.rs
@@ -33,7 +33,7 @@ pub fn create_changer(config: ScsiTapeChanger) -> Result<(), Error> {
 
     let (mut section_config, _digest) = pbs_config::drive::config()?;
 
-    if section_config.sections.get(&config.name).is_some() {
+    if section_config.sections.contains_key(&config.name) {
         param_bail!("name", "Entry '{}' already exists", config.name);
     }
 
diff --git a/src/api2/config/datastore.rs b/src/api2/config/datastore.rs
index 6b742acb..02887b86 100644
--- a/src/api2/config/datastore.rs
+++ b/src/api2/config/datastore.rs
@@ -118,7 +118,7 @@ pub fn create_datastore(
 
     let (section_config, _digest) = pbs_config::datastore::config()?;
 
-    if section_config.sections.get(&config.name).is_some() {
+    if section_config.sections.contains_key(&config.name) {
         param_bail!("name", "datastore '{}' already exists.", config.name);
     }
 
diff --git a/src/api2/config/drive.rs b/src/api2/config/drive.rs
index cf620aaf..1222ab20 100644
--- a/src/api2/config/drive.rs
+++ b/src/api2/config/drive.rs
@@ -34,7 +34,7 @@ pub fn create_drive(config: LtoTapeDrive) -> Result<(), Error> {
 
     let (mut section_config, _digest) = pbs_config::drive::config()?;
 
-    if section_config.sections.get(&config.name).is_some() {
+    if section_config.sections.contains_key(&config.name) {
         param_bail!("name", "Entry '{}' already exists", config.name);
     }
 
diff --git a/src/api2/config/media_pool.rs b/src/api2/config/media_pool.rs
index 4a4cec56..9b6080be 100644
--- a/src/api2/config/media_pool.rs
+++ b/src/api2/config/media_pool.rs
@@ -31,7 +31,7 @@ pub fn create_pool(config: MediaPoolConfig) -> Result<(), Error> {
 
     let (mut section_config, _digest) = pbs_config::media_pool::config()?;
 
-    if section_config.sections.get(&config.name).is_some() {
+    if section_config.sections.contains_key(&config.name) {
         param_bail!("name", "Media pool '{}' already exists", config.name);
     }
 
@@ -225,11 +225,10 @@ pub fn delete_pool(name: String) -> Result<(), Error> {
 
     let (mut config, _digest) = pbs_config::media_pool::config()?;
 
-    match config.sections.get(&name) {
-        Some(_) => {
-            config.sections.remove(&name);
-        }
-        None => http_bail!(NOT_FOUND, "delete pool '{}' failed - no such pool", name),
+    if config.sections.contains_key(&name) {
+        config.sections.remove(&name);
+    } else {
+        http_bail!(NOT_FOUND, "delete pool '{}' failed - no such pool", name);
     }
 
     pbs_config::media_pool::save_config(&config)?;
diff --git a/src/api2/config/metrics/influxdbhttp.rs b/src/api2/config/metrics/influxdbhttp.rs
index 2b7811ff..bed29260 100644
--- a/src/api2/config/metrics/influxdbhttp.rs
+++ b/src/api2/config/metrics/influxdbhttp.rs
@@ -82,7 +82,7 @@ pub async fn create_influxdb_http_server(config: InfluxDbHttp) -> Result<(), Err
 
     let (mut metrics, _digest) = metrics::config()?;
 
-    if metrics.sections.get(&config.name).is_some() {
+    if metrics.sections.contains_key(&config.name) {
         bail!("metric server '{}' already exists.", config.name);
     }
 
diff --git a/src/api2/config/metrics/influxdbudp.rs b/src/api2/config/metrics/influxdbudp.rs
index c6efd5e2..c47a4e19 100644
--- a/src/api2/config/metrics/influxdbudp.rs
+++ b/src/api2/config/metrics/influxdbudp.rs
@@ -67,7 +67,7 @@ pub async fn create_influxdb_udp_server(config: InfluxDbUdp) -> Result<(), Error
 
     let (mut metrics, _digest) = metrics::config()?;
 
-    if metrics.sections.get(&config.name).is_some() {
+    if metrics.sections.contains_key(&config.name) {
         bail!("metric server '{}' already exists.", config.name);
     }
 
diff --git a/src/api2/config/prune.rs b/src/api2/config/prune.rs
index 4f7ce39c..7e946dd2 100644
--- a/src/api2/config/prune.rs
+++ b/src/api2/config/prune.rs
@@ -66,7 +66,7 @@ pub fn do_create_prune_job(
 
     let (mut section_config, _digest) = prune::config()?;
 
-    if section_config.sections.get(&config.id).is_some() {
+    if section_config.sections.contains_key(&config.id) {
         param_bail!("id", "job '{}' already exists.", config.id);
     }
 
diff --git a/src/api2/config/remote.rs b/src/api2/config/remote.rs
index 2511c5d5..8325dbce 100644
--- a/src/api2/config/remote.rs
+++ b/src/api2/config/remote.rs
@@ -89,7 +89,7 @@ pub fn create_remote(name: String, config: RemoteConfig, password: String) -> Re
 
     let (mut section_config, _digest) = pbs_config::remote::config()?;
 
-    if section_config.sections.get(&name).is_some() {
+    if section_config.sections.contains_key(&name) {
         param_bail!("name", "remote '{}' already exists.", name);
     }
 
@@ -288,11 +288,10 @@ pub fn delete_remote(name: String, digest: Option<String>) -> Result<(), Error>
         crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
     }
 
-    match config.sections.get(&name) {
-        Some(_) => {
-            config.sections.remove(&name);
-        }
-        None => http_bail!(NOT_FOUND, "remote '{}' does not exist.", name),
+    if config.sections.contains_key(&name) {
+        config.sections.remove(&name);
+    } else {
+        http_bail!(NOT_FOUND, "remote '{}' does not exist.", name);
     }
 
     pbs_config::remote::save_config(&config)?;
diff --git a/src/api2/config/sync.rs b/src/api2/config/sync.rs
index 8809465c..6fdc69a9 100644
--- a/src/api2/config/sync.rs
+++ b/src/api2/config/sync.rs
@@ -154,7 +154,7 @@ pub fn create_sync_job(
 
     let (mut section_config, _digest) = sync::config()?;
 
-    if section_config.sections.get(&config.id).is_some() {
+    if section_config.sections.contains_key(&config.id) {
         param_bail!("id", "job '{}' already exists.", config.id);
     }
 
diff --git a/src/api2/config/tape_backup_job.rs b/src/api2/config/tape_backup_job.rs
index e425cbb5..b6db9299 100644
--- a/src/api2/config/tape_backup_job.rs
+++ b/src/api2/config/tape_backup_job.rs
@@ -75,7 +75,7 @@ pub fn create_tape_backup_job(
 
     let (mut config, _digest) = pbs_config::tape_job::config()?;
 
-    if config.sections.get(&job.id).is_some() {
+    if config.sections.contains_key(&job.id) {
         param_bail!("id", "job '{}' already exists.", job.id);
     }
 
diff --git a/src/api2/config/traffic_control.rs b/src/api2/config/traffic_control.rs
index 30ea40ec..674a7404 100644
--- a/src/api2/config/traffic_control.rs
+++ b/src/api2/config/traffic_control.rs
@@ -59,7 +59,7 @@ pub fn create_traffic_control(config: TrafficControlRule) -> Result<(), Error> {
 
     let (mut section_config, _digest) = pbs_config::traffic_control::config()?;
 
-    if section_config.sections.get(&config.name).is_some() {
+    if section_config.sections.contains_key(&config.name) {
         param_bail!(
             "name",
             "traffic control rule '{}' already exists.",
@@ -258,11 +258,10 @@ pub fn delete_traffic_control(name: String, digest: Option<String>) -> Result<()
         crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
     }
 
-    match config.sections.get(&name) {
-        Some(_) => {
-            config.sections.remove(&name);
-        }
-        None => http_bail!(NOT_FOUND, "traffic control rule '{}' does not exist.", name),
+    if config.sections.contains_key(&name) {
+        config.sections.remove(&name);
+    } else {
+        http_bail!(NOT_FOUND, "traffic control rule '{}' does not exist.", name);
     }
 
     pbs_config::traffic_control::save_config(&config)?;
diff --git a/src/api2/config/verify.rs b/src/api2/config/verify.rs
index 82dbe43b..e71e0c2e 100644
--- a/src/api2/config/verify.rs
+++ b/src/api2/config/verify.rs
@@ -85,7 +85,7 @@ pub fn create_verification_job(
 
     let (mut section_config, _digest) = verify::config()?;
 
-    if section_config.sections.get(&config.id).is_some() {
+    if section_config.sections.contains_key(&config.id) {
         param_bail!("id", "job '{}' already exists.", config.id);
     }
 
diff --git a/src/api2/node/disks/directory.rs b/src/api2/node/disks/directory.rs
index 9f1112a9..03c0053e 100644
--- a/src/api2/node/disks/directory.rs
+++ b/src/api2/node/disks/directory.rs
@@ -209,7 +209,7 @@ pub fn create_datastore_disk(
 
                 let (config, _digest) = pbs_config::datastore::config()?;
 
-                if config.sections.get(&datastore.name).is_some() {
+                if config.sections.contains_key(&datastore.name) {
                     bail!("datastore '{}' already exists.", datastore.name);
                 }
 
diff --git a/src/api2/node/disks/zfs.rs b/src/api2/node/disks/zfs.rs
index 673dc1bf..7caeb4bb 100644
--- a/src/api2/node/disks/zfs.rs
+++ b/src/api2/node/disks/zfs.rs
@@ -315,7 +315,7 @@ pub fn create_zpool(
 
                 let (config, _digest) = pbs_config::datastore::config()?;
 
-                if config.sections.get(&datastore.name).is_some() {
+                if config.sections.contains_key(&datastore.name) {
                     bail!("datastore '{}' already exists.", datastore.name);
                 }
 
diff --git a/src/api2/tape/media.rs b/src/api2/tape/media.rs
index 159906ba..a7c8483a 100644
--- a/src/api2/tape/media.rs
+++ b/src/api2/tape/media.rs
@@ -244,7 +244,7 @@ pub async fn list_media(
         let media_id = inventory.lookup_media(uuid).unwrap();
 
         if let Some(pool) = media_id.pool() {
-            if config.sections.get(&pool).is_some() {
+            if config.sections.contains_key(&pool) {
                 continue;
             }
 
diff --git a/src/tape/encryption_keys.rs b/src/tape/encryption_keys.rs
index 1f60c1c6..5f9f6d18 100644
--- a/src/tape/encryption_keys.rs
+++ b/src/tape/encryption_keys.rs
@@ -165,7 +165,7 @@ pub fn insert_key(key: [u8; 32], key_config: KeyConfig, force: bool) -> Result<(
         None => bail!("missing encryption key fingerprint - internal error"),
     };
 
-    if !force && config_map.get(&fingerprint).is_some() {
+    if !force && config_map.contains_key(&fingerprint) {
         bail!("encryption key '{}' already exists.", fingerprint);
     }
 
diff --git a/src/tape/media_catalog.rs b/src/tape/media_catalog.rs
index 9aae0aa1..fa8ff405 100644
--- a/src/tape/media_catalog.rs
+++ b/src/tape/media_catalog.rs
@@ -946,7 +946,7 @@ impl MediaSetCatalog {
 
     /// Add a catalog
     pub fn append_catalog(&mut self, catalog: MediaCatalog) -> Result<(), Error> {
-        if self.catalog_list.get(&catalog.uuid).is_some() {
+        if self.catalog_list.contains_key(&catalog.uuid) {
             bail!("MediaSetCatalog already contains media '{}'", catalog.uuid);
         }
 
-- 
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] 7+ messages in thread

* [pbs-devel] [PATCH backup v2 2/6] replace get(key).is_none() with !contains_key()
  2024-06-26 13:05 [pbs-devel] [PATCH backup v2 1/6] replace get(key).is_some() with contains_key() Maximiliano Sandoval
@ 2024-06-26 13:05 ` Maximiliano Sandoval
  2024-06-26 13:06 ` [pbs-devel] [PATCH backup v2 3/6] api: remove use of unnecessary pub(self) Maximiliano Sandoval
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Maximiliano Sandoval @ 2024-06-26 13:05 UTC (permalink / raw)
  To: pbs-devel

Fixes the clippy warning:

warning: unnecessary use of `get(&user2).is_none()`
    --> pbs-config/src/acl.rs:1067:36
     |
1067 |                 assert!(node.users.get(&user2).is_none());
     |                         -----------^^^^^^^^^^^^^^^^^^^^^
     |                         |
     |                         help: replace it with: `!node.users.contains_key(&user2)`
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_get_then_check

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 pbs-config/src/acl.rs            | 4 ++--
 pbs-config/src/network/parser.rs | 2 +-
 pbs-config/src/user.rs           | 2 +-
 src/api2/access/acl.rs           | 2 +-
 src/api2/tape/drive.rs           | 4 ++--
 src/config/acme/plugin.rs        | 2 +-
 6 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/pbs-config/src/acl.rs b/pbs-config/src/acl.rs
index 8a1423cc..8b6215ef 100644
--- a/pbs-config/src/acl.rs
+++ b/pbs-config/src/acl.rs
@@ -1047,7 +1047,7 @@ acl:1:/storage/store1:user1@pbs:DatastoreBackup
             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 {
@@ -1064,7 +1064,7 @@ acl:1:/storage/store1:user1@pbs:DatastoreBackup
             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/pbs-config/src/network/parser.rs b/pbs-config/src/network/parser.rs
index 2158a04f..7498dd35 100644
--- a/pbs-config/src/network/parser.rs
+++ b/pbs-config/src/network/parser.rs
@@ -585,7 +585,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/pbs-config/src/user.rs b/pbs-config/src/user.rs
index 8e10a778..f5ea03db 100644
--- a/pbs-config/src/user.rs
+++ b/pbs-config/src/user.rs
@@ -57,7 +57,7 @@ pub fn config() -> Result<(SectionConfigData, [u8; 32]), Error> {
     let digest = openssl::sha::sha256(content.as_bytes());
     let mut data = CONFIG.parse(USER_CFG_FILENAME, &content)?;
 
-    if data.sections.get("root@pam").is_none() {
+    if !data.sections.contains_key("root@pam") {
         let user: User = User {
             userid: Userid::root_userid().clone(),
             comment: Some("Superuser".to_string()),
diff --git a/src/api2/access/acl.rs b/src/api2/access/acl.rs
index 1ec4bd3d..6fde99fd 100644
--- a/src/api2/access/acl.rs
+++ b/src/api2/access/acl.rs
@@ -233,7 +233,7 @@ pub fn update_acl(
         if !delete {
             // Note: we allow to delete non-existent users
             let user_cfg = pbs_config::user::cached_config()?;
-            if user_cfg.sections.get(&auth_id.to_string()).is_none() {
+            if !user_cfg.sections.contains_key(&auth_id.to_string()) {
                 bail!(format!(
                     "no such {}.",
                     if auth_id.is_token() {
diff --git a/src/api2/tape/drive.rs b/src/api2/tape/drive.rs
index c6fc9f9c..ca76c6bf 100644
--- a/src/api2/tape/drive.rs
+++ b/src/api2/tape/drive.rs
@@ -495,7 +495,7 @@ pub fn label_media(
     if let Some(ref pool) = pool {
         let (pool_config, _digest) = pbs_config::media_pool::config()?;
 
-        if pool_config.sections.get(pool).is_none() {
+        if !pool_config.sections.contains_key(pool) {
             bail!("no such pool ('{}')", pool);
         }
     }
@@ -1056,7 +1056,7 @@ pub fn barcode_label_media(
     if let Some(ref pool) = pool {
         let (pool_config, _digest) = pbs_config::media_pool::config()?;
 
-        if pool_config.sections.get(pool).is_none() {
+        if !pool_config.sections.contains_key(pool) {
             bail!("no such pool ('{}')", pool);
         }
     }
diff --git a/src/config/acme/plugin.rs b/src/config/acme/plugin.rs
index d3b2189d..ff66dec3 100644
--- a/src/config/acme/plugin.rs
+++ b/src/config/acme/plugin.rs
@@ -147,7 +147,7 @@ pub fn config() -> Result<(PluginData, [u8; 32]), Error> {
     let digest = openssl::sha::sha256(content.as_bytes());
     let mut data = CONFIG.parse(ACME_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();
-- 
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] 7+ messages in thread

* [pbs-devel] [PATCH backup v2 3/6] api: remove use of unnecessary pub(self)
  2024-06-26 13:05 [pbs-devel] [PATCH backup v2 1/6] replace get(key).is_some() with contains_key() Maximiliano Sandoval
  2024-06-26 13:05 ` [pbs-devel] [PATCH backup v2 2/6] replace get(key).is_none() with !contains_key() Maximiliano Sandoval
@ 2024-06-26 13:06 ` Maximiliano Sandoval
  2024-06-26 13:06 ` [pbs-devel] [PATCH backup v2 4/6] tools: write multiplication by 01 succinctly Maximiliano Sandoval
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Maximiliano Sandoval @ 2024-06-26 13:06 UTC (permalink / raw)
  To: pbs-devel

Fixes the clippy warning:

warning: unnecessary `pub(self)`
  --> src/api2/access/mod.rs:35:1
   |
35 | pub(self) async fn user_update_auth<S: AsRef<str>>(
   | ^^^^^^^^^ help: remove it
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pub_self
   = note: `#[warn(clippy::needless_pub_self)]` on by default

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

diff --git a/src/api2/access/mod.rs b/src/api2/access/mod.rs
index 15509fd9..a60f0f86 100644
--- a/src/api2/access/mod.rs
+++ b/src/api2/access/mod.rs
@@ -32,7 +32,7 @@ pub mod user;
 /// This means that user admins need to type in their own password while editing a user, and
 /// regular users, which can only change their own settings (checked at the API level), can change
 /// their own settings using their own password.
-pub(self) async fn user_update_auth<S: AsRef<str>>(
+async fn user_update_auth<S: AsRef<str>>(
     rpcenv: &mut dyn RpcEnvironment,
     userid: &Userid,
     password: Option<S>,
-- 
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] 7+ messages in thread

* [pbs-devel] [PATCH backup v2 4/6] tools: write multiplication by 01 succinctly
  2024-06-26 13:05 [pbs-devel] [PATCH backup v2 1/6] replace get(key).is_some() with contains_key() Maximiliano Sandoval
  2024-06-26 13:05 ` [pbs-devel] [PATCH backup v2 2/6] replace get(key).is_none() with !contains_key() Maximiliano Sandoval
  2024-06-26 13:06 ` [pbs-devel] [PATCH backup v2 3/6] api: remove use of unnecessary pub(self) Maximiliano Sandoval
@ 2024-06-26 13:06 ` Maximiliano Sandoval
  2024-06-26 13:06 ` [pbs-devel] [PATCH backup v2 5/6] chunk_store: do not explicitly write implied trait Maximiliano Sandoval
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Maximiliano Sandoval @ 2024-06-26 13:06 UTC (permalink / raw)
  To: pbs-devel

Fixes the clippy warning:

warning: this multiplication by -1 can be written more succinctly
   --> pbs-client/src/tools/mod.rs:700:58
    |
700 |                         SignedDuration::Negative(val) => -1 * i64::try_from(val.as_secs())?,
    |                                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `-i64::try_from(val.as_secs())?`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#neg_multiply
    = note: `#[warn(clippy::neg_multiply)]` on by default

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

diff --git a/pbs-client/src/tools/mod.rs b/pbs-client/src/tools/mod.rs
index 782e0578..90fac696 100644
--- a/pbs-client/src/tools/mod.rs
+++ b/pbs-client/src/tools/mod.rs
@@ -697,7 +697,7 @@ pub async fn pxar_metadata_catalog_lookup<T: Clone + ReadAt>(
                 EntryKind::File { size, .. } => {
                     let mtime = match entry.metadata().mtime_as_duration() {
                         SignedDuration::Positive(val) => i64::try_from(val.as_secs())?,
-                        SignedDuration::Negative(val) => -1 * i64::try_from(val.as_secs())?,
+                        SignedDuration::Negative(val) => -i64::try_from(val.as_secs())?,
                     };
                     DirEntryAttribute::File { size: *size, mtime }
                 }
-- 
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] 7+ messages in thread

* [pbs-devel] [PATCH backup v2 5/6] chunk_store: do not explicitly write implied trait
  2024-06-26 13:05 [pbs-devel] [PATCH backup v2 1/6] replace get(key).is_some() with contains_key() Maximiliano Sandoval
                   ` (2 preceding siblings ...)
  2024-06-26 13:06 ` [pbs-devel] [PATCH backup v2 4/6] tools: write multiplication by 01 succinctly Maximiliano Sandoval
@ 2024-06-26 13:06 ` Maximiliano Sandoval
  2024-06-26 13:06 ` [pbs-devel] [PATCH backup v2 6/6] tools: add missing cfg(test) macro Maximiliano Sandoval
  2024-06-28  7:36 ` [pbs-devel] applied-series: [PATCH backup v2 1/6] replace get(key).is_some() with contains_key() Wolfgang Bumiller
  5 siblings, 0 replies; 7+ messages in thread
From: Maximiliano Sandoval @ 2024-06-26 13:06 UTC (permalink / raw)
  To: pbs-devel

Fixes the clippy warning:

warning: this bound is already specified as the supertrait of `std::iter::FusedIterator`
   --> pbs-datastore/src/chunk_store.rs:254:14
    |
254 |         impl Iterator<Item = (Result<proxmox_sys::fs::ReadDirEntry, Error>, usize, bool)>
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#implied_bounds_in_impls
    = note: `#[warn(clippy::implied_bounds_in_impls)]` on by default
help: try removing this bound
    |
254 -         impl Iterator<Item = (Result<proxmox_sys::fs::ReadDirEntry, Error>, usize, bool)>
255 -             + std::iter::FusedIterator,
254 +         impl std::iter::FusedIterator<Item = (Result<proxmox_sys::fs::ReadDirEntry, Error>, usize, bool)>,

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 pbs-datastore/src/chunk_store.rs | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/pbs-datastore/src/chunk_store.rs b/pbs-datastore/src/chunk_store.rs
index 9f6289c9..0217be84 100644
--- a/pbs-datastore/src/chunk_store.rs
+++ b/pbs-datastore/src/chunk_store.rs
@@ -251,8 +251,9 @@ impl ChunkStore {
     pub fn get_chunk_iterator(
         &self,
     ) -> Result<
-        impl Iterator<Item = (Result<proxmox_sys::fs::ReadDirEntry, Error>, usize, bool)>
-            + std::iter::FusedIterator,
+        impl std::iter::FusedIterator<
+            Item = (Result<proxmox_sys::fs::ReadDirEntry, Error>, usize, bool),
+        >,
         Error,
     > {
         // unwrap: only `None` in unit tests
-- 
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] 7+ messages in thread

* [pbs-devel] [PATCH backup v2 6/6] tools: add missing cfg(test) macro
  2024-06-26 13:05 [pbs-devel] [PATCH backup v2 1/6] replace get(key).is_some() with contains_key() Maximiliano Sandoval
                   ` (3 preceding siblings ...)
  2024-06-26 13:06 ` [pbs-devel] [PATCH backup v2 5/6] chunk_store: do not explicitly write implied trait Maximiliano Sandoval
@ 2024-06-26 13:06 ` Maximiliano Sandoval
  2024-06-28  7:36 ` [pbs-devel] applied-series: [PATCH backup v2 1/6] replace get(key).is_some() with contains_key() Wolfgang Bumiller
  5 siblings, 0 replies; 7+ messages in thread
From: Maximiliano Sandoval @ 2024-06-26 13:06 UTC (permalink / raw)
  To: pbs-devel

Fixes the rustc warning:

warning: struct `TestAsyncCacher` is never constructed
  --> pbs-tools/src/async_lru_cache.rs:86:12
   |
86 |     struct TestAsyncCacher {
   |            ^^^^^^^^^^^^^^^
   |
   = note: `#[warn(dead_code)]` on by default

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 pbs-tools/src/async_lru_cache.rs | 1 +
 1 file changed, 1 insertion(+)

diff --git a/pbs-tools/src/async_lru_cache.rs b/pbs-tools/src/async_lru_cache.rs
index 1f023d34..c43b8771 100644
--- a/pbs-tools/src/async_lru_cache.rs
+++ b/pbs-tools/src/async_lru_cache.rs
@@ -80,6 +80,7 @@ impl<K: std::cmp::Eq + std::hash::Hash + Copy, V: Clone + Send + 'static> AsyncL
     }
 }
 
+#[cfg(test)]
 mod test {
     use super::*;
 
-- 
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] 7+ messages in thread

* [pbs-devel] applied-series: [PATCH backup v2 1/6] replace get(key).is_some() with contains_key()
  2024-06-26 13:05 [pbs-devel] [PATCH backup v2 1/6] replace get(key).is_some() with contains_key() Maximiliano Sandoval
                   ` (4 preceding siblings ...)
  2024-06-26 13:06 ` [pbs-devel] [PATCH backup v2 6/6] tools: add missing cfg(test) macro Maximiliano Sandoval
@ 2024-06-28  7:36 ` Wolfgang Bumiller
  5 siblings, 0 replies; 7+ messages in thread
From: Wolfgang Bumiller @ 2024-06-28  7:36 UTC (permalink / raw)
  To: Maximiliano Sandoval; +Cc: pbs-devel

applied series, thanks

also followed up with a removing `if .contains_key() .remove() else
bail!()` code pieces with directly calling .remove() and checking for
.is_none() -> bail!()


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




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

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

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-26 13:05 [pbs-devel] [PATCH backup v2 1/6] replace get(key).is_some() with contains_key() Maximiliano Sandoval
2024-06-26 13:05 ` [pbs-devel] [PATCH backup v2 2/6] replace get(key).is_none() with !contains_key() Maximiliano Sandoval
2024-06-26 13:06 ` [pbs-devel] [PATCH backup v2 3/6] api: remove use of unnecessary pub(self) Maximiliano Sandoval
2024-06-26 13:06 ` [pbs-devel] [PATCH backup v2 4/6] tools: write multiplication by 01 succinctly Maximiliano Sandoval
2024-06-26 13:06 ` [pbs-devel] [PATCH backup v2 5/6] chunk_store: do not explicitly write implied trait Maximiliano Sandoval
2024-06-26 13:06 ` [pbs-devel] [PATCH backup v2 6/6] tools: add missing cfg(test) macro Maximiliano Sandoval
2024-06-28  7:36 ` [pbs-devel] applied-series: [PATCH backup v2 1/6] replace get(key).is_some() with contains_key() 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