* [pbs-devel] [PATCH backup 02/13] remove redundant guards
2024-02-12 13:17 [pbs-devel] [PATCH backup 01/13] docs: remove redundant explicit link target Maximiliano Sandoval
@ 2024-02-12 13:17 ` Maximiliano Sandoval
2024-02-12 13:17 ` [pbs-devel] [PATCH backup 03/13] remove needless borrows Maximiliano Sandoval
` (7 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Maximiliano Sandoval @ 2024-02-12 13:17 UTC (permalink / raw)
To: pbs-devel
Fixes the clippy lint:
```
warning: redundant guard
--> pbs-datastore/src/chunk_store.rs:325:37
|
325 | Err(ref err) if err == &nix::errno::Errno::ENOENT => {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_guards
= note: `#[warn(clippy::redundant_guards)]` on by default
help: try
|
325 - Err(ref err) if err == &nix::errno::Errno::ENOENT => {
325 + Err(nix::errno::Errno::ENOENT) => {
|
```
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
pbs-client/src/pxar/extract.rs | 4 ++--
pbs-datastore/src/chunk_store.rs | 2 +-
src/bin/proxmox_backup_manager/user.rs | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/pbs-client/src/pxar/extract.rs b/pbs-client/src/pxar/extract.rs
index af18ecfc..5f5ac618 100644
--- a/pbs-client/src/pxar/extract.rs
+++ b/pbs-client/src/pxar/extract.rs
@@ -699,7 +699,7 @@ impl Extractor {
if result.seeked_last {
while match nix::unistd::ftruncate(file.as_raw_fd(), size as i64) {
Ok(_) => false,
- Err(errno) if errno == nix::errno::Errno::EINTR => true,
+ Err(nix::errno::Errno::EINTR) => true,
Err(err) => return Err(err).context("error setting file size"),
} {}
}
@@ -758,7 +758,7 @@ impl Extractor {
if result.seeked_last {
while match nix::unistd::ftruncate(file.as_raw_fd(), size as i64) {
Ok(_) => false,
- Err(errno) if errno == nix::errno::Errno::EINTR => true,
+ Err(nix::errno::Errno::EINTR) => true,
Err(err) => return Err(err).context("error setting file size"),
} {}
}
diff --git a/pbs-datastore/src/chunk_store.rs b/pbs-datastore/src/chunk_store.rs
index fb282749..9f6289c9 100644
--- a/pbs-datastore/src/chunk_store.rs
+++ b/pbs-datastore/src/chunk_store.rs
@@ -322,7 +322,7 @@ impl ChunkStore {
// start reading:
continue;
}
- Err(ref err) if err == &nix::errno::Errno::ENOENT => {
+ Err(nix::errno::Errno::ENOENT) => {
// non-existing directories are okay, just keep going:
continue;
}
diff --git a/src/bin/proxmox_backup_manager/user.rs b/src/bin/proxmox_backup_manager/user.rs
index 743c5d16..96b83fcc 100644
--- a/src/bin/proxmox_backup_manager/user.rs
+++ b/src/bin/proxmox_backup_manager/user.rs
@@ -16,7 +16,7 @@ fn render_expire(value: &Value, _record: &Value) -> Result<String, Error> {
return Ok(never);
}
let text = match value.as_i64() {
- Some(epoch) if epoch == 0 => never,
+ Some(0) => never,
Some(epoch) => {
if let Ok(epoch_string) = proxmox_time::strftime_local("%c", epoch) {
epoch_string
--
2.39.2
^ permalink raw reply [flat|nested] 12+ messages in thread
* [pbs-devel] [PATCH backup 03/13] remove needless borrows
2024-02-12 13:17 [pbs-devel] [PATCH backup 01/13] docs: remove redundant explicit link target Maximiliano Sandoval
2024-02-12 13:17 ` [pbs-devel] [PATCH backup 02/13] remove redundant guards Maximiliano Sandoval
@ 2024-02-12 13:17 ` Maximiliano Sandoval
2024-02-12 13:17 ` [pbs-devel] [PATCH backup 04/13] media_catalog: use stream_position Maximiliano Sandoval
` (6 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Maximiliano Sandoval @ 2024-02-12 13:17 UTC (permalink / raw)
To: pbs-devel
Fixes the clippy lint:
```
warning: the borrowed expression implements the required traits
--> src/server/report.rs:193:47
|
193 | get_directory_content(&path)
| ^^^^^ help: change this to: `path`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrows_for_generic_args
= note: `#[warn(clippy::needless_borrows_for_generic_args)]` on by default
```
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
src/server/pull.rs | 4 ++--
src/server/report.rs | 2 +-
src/tape/changer/online_status_map.rs | 2 +-
src/tools/disks/mod.rs | 2 +-
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/server/pull.rs b/src/server/pull.rs
index 5f235b0a..5a4ba806 100644
--- a/src/server/pull.rs
+++ b/src/server/pull.rs
@@ -199,7 +199,7 @@ impl PullSource for RemoteSource {
});
if !namespace.is_root() {
- args["ns"] = serde_json::to_value(&namespace)?;
+ args["ns"] = serde_json::to_value(namespace)?;
}
self.client.login().await?;
@@ -230,7 +230,7 @@ impl PullSource for RemoteSource {
}
fn get_store(&self) -> &str {
- &self.repo.store()
+ self.repo.store()
}
async fn reader(
diff --git a/src/server/report.rs b/src/server/report.rs
index 6b033832..d97efb14 100644
--- a/src/server/report.rs
+++ b/src/server/report.rs
@@ -190,7 +190,7 @@ pub fn generate_report() -> String {
.map(|file_name| {
let path = Path::new(file_name);
if path.is_dir() {
- get_directory_content(&path)
+ get_directory_content(path)
} else {
get_file_content(file_name)
}
diff --git a/src/tape/changer/online_status_map.rs b/src/tape/changer/online_status_map.rs
index c3da0415..d7f3ca7a 100644
--- a/src/tape/changer/online_status_map.rs
+++ b/src/tape/changer/online_status_map.rs
@@ -88,7 +88,7 @@ impl OnlineStatusMap {
}
fn insert_into_online_set(inventory: &Inventory, label_text: &str, online_set: &mut HashSet<Uuid>) {
- match inventory.find_media_by_label_text(&label_text) {
+ match inventory.find_media_by_label_text(label_text) {
Ok(Some(media_id)) => {
online_set.insert(media_id.label.uuid.clone());
}
diff --git a/src/tools/disks/mod.rs b/src/tools/disks/mod.rs
index 7a772356..78360b66 100644
--- a/src/tools/disks/mod.rs
+++ b/src/tools/disks/mod.rs
@@ -1167,7 +1167,7 @@ pub fn wipe_blockdev(disk: &Disk, worker: Arc<WorkerTask>) -> Result<(), Error>
if is_partition {
// set the partition type to 0x83 'Linux filesystem'
- change_parttype(&disk, "8300", worker)?;
+ change_parttype(disk, "8300", worker)?;
}
Ok(())
--
2.39.2
^ permalink raw reply [flat|nested] 12+ messages in thread
* [pbs-devel] [PATCH backup 04/13] media_catalog: use stream_position
2024-02-12 13:17 [pbs-devel] [PATCH backup 01/13] docs: remove redundant explicit link target Maximiliano Sandoval
2024-02-12 13:17 ` [pbs-devel] [PATCH backup 02/13] remove redundant guards Maximiliano Sandoval
2024-02-12 13:17 ` [pbs-devel] [PATCH backup 03/13] remove needless borrows Maximiliano Sandoval
@ 2024-02-12 13:17 ` Maximiliano Sandoval
2024-02-12 13:17 ` [pbs-devel] [PATCH backup 05/13] use or_default instead of or_insert_with(Default::default) Maximiliano Sandoval
` (5 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Maximiliano Sandoval @ 2024-02-12 13:17 UTC (permalink / raw)
To: pbs-devel
Fixes the following clippy lint:
```
warning: using `SeekFrom::Current` to start from current position
--> src/tape/media_catalog.rs:798:23
|
798 | let pos = file.seek(SeekFrom::Current(0))?; // get current pos
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `file.stream_position()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#seek_from_current
= note: `#[warn(clippy::seek_from_current)]` on by default
```
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
src/tape/media_catalog.rs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/tape/media_catalog.rs b/src/tape/media_catalog.rs
index 928d4701..9aae0aa1 100644
--- a/src/tape/media_catalog.rs
+++ b/src/tape/media_catalog.rs
@@ -1,6 +1,6 @@
use std::collections::{HashMap, HashSet};
use std::fs::File;
-use std::io::{BufReader, Read, Seek, SeekFrom, Write};
+use std::io::{BufReader, Read, Seek, Write};
use std::os::unix::io::AsRawFd;
use std::path::{Path, PathBuf};
@@ -795,7 +795,7 @@ impl MediaCatalog {
let mut media_set_uuid = None;
loop {
- let pos = file.seek(SeekFrom::Current(0))?; // get current pos
+ let pos = file.stream_position()?; // get current pos
if pos == 0 {
// read/check magic number
--
2.39.2
^ permalink raw reply [flat|nested] 12+ messages in thread
* [pbs-devel] [PATCH backup 05/13] use or_default instead of or_insert_with(Default::default)
2024-02-12 13:17 [pbs-devel] [PATCH backup 01/13] docs: remove redundant explicit link target Maximiliano Sandoval
` (2 preceding siblings ...)
2024-02-12 13:17 ` [pbs-devel] [PATCH backup 04/13] media_catalog: use stream_position Maximiliano Sandoval
@ 2024-02-12 13:17 ` Maximiliano Sandoval
2024-02-12 13:17 ` [pbs-devel] [PATCH backup 06/13] access first element with first() rather than get(0) Maximiliano Sandoval
` (4 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Maximiliano Sandoval @ 2024-02-12 13:17 UTC (permalink / raw)
To: pbs-devel
We need to annotate some cases to allow the compile to infer the types.
Fixes the clippy lint:
```
warning: use of `or_insert_with` to construct default value
--> src/api2/tape/restore.rs:750:18
|
750 | .or_insert_with(Vec::new);
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `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>
---
pbs-config/src/acl.rs | 28 ++++++++--------------------
src/api2/tape/restore.rs | 14 +++++---------
2 files changed, 13 insertions(+), 29 deletions(-)
diff --git a/pbs-config/src/acl.rs b/pbs-config/src/acl.rs
index cd9987fa..a0354a05 100644
--- a/pbs-config/src/acl.rs
+++ b/pbs-config/src/acl.rs
@@ -447,8 +447,8 @@ impl AclTree {
}
fn write_node_config(node: &AclTreeNode, path: &str, w: &mut dyn Write) -> Result<(), Error> {
- let mut role_ug_map0 = HashMap::new();
- let mut role_ug_map1 = HashMap::new();
+ let mut role_ug_map0: HashMap<_, BTreeSet<_>> = HashMap::new();
+ let mut role_ug_map1: HashMap<_, BTreeSet<_>> = HashMap::new();
for (auth_id, roles) in &node.users {
// no need to save, because root is always 'Administrator'
@@ -459,15 +459,9 @@ impl AclTree {
let role = role.as_str();
let auth_id = auth_id.to_string();
if *propagate {
- role_ug_map1
- .entry(role)
- .or_insert_with(BTreeSet::new)
- .insert(auth_id);
+ role_ug_map1.entry(role).or_default().insert(auth_id);
} else {
- role_ug_map0
- .entry(role)
- .or_insert_with(BTreeSet::new)
- .insert(auth_id);
+ role_ug_map0.entry(role).or_default().insert(auth_id);
}
}
}
@@ -476,15 +470,9 @@ impl AclTree {
for (role, propagate) in roles {
let group = format!("@{}", group);
if *propagate {
- role_ug_map1
- .entry(role)
- .or_insert_with(BTreeSet::new)
- .insert(group);
+ role_ug_map1.entry(role).or_default().insert(group);
} else {
- role_ug_map0
- .entry(role)
- .or_insert_with(BTreeSet::new)
- .insert(group);
+ role_ug_map0.entry(role).or_default().insert(group);
}
}
}
@@ -492,7 +480,7 @@ impl AclTree {
fn group_by_property_list(
item_property_map: &HashMap<&str, BTreeSet<String>>,
) -> BTreeMap<String, BTreeSet<String>> {
- let mut result_map = BTreeMap::new();
+ let mut result_map: BTreeMap<_, BTreeSet<_>> = BTreeMap::new();
for (item, property_map) in item_property_map {
let item_list = property_map.iter().fold(String::new(), |mut acc, v| {
if !acc.is_empty() {
@@ -503,7 +491,7 @@ impl AclTree {
});
result_map
.entry(item_list)
- .or_insert_with(BTreeSet::new)
+ .or_default()
.insert(item.to_string());
}
result_map
diff --git a/src/api2/tape/restore.rs b/src/api2/tape/restore.rs
index 47e0586b..8273c867 100644
--- a/src/api2/tape/restore.rs
+++ b/src/api2/tape/restore.rs
@@ -75,7 +75,7 @@ impl TryFrom<Vec<String>> for NamespaceMap {
let max_depth = mapping.max_depth.unwrap_or(MAX_NAMESPACE_DEPTH);
let ns_map: &mut HashMap<BackupNamespace, (BackupNamespace, usize)> =
- map.entry(mapping.store).or_insert_with(HashMap::new);
+ map.entry(mapping.store).or_default();
if ns_map.insert(source, (target, max_depth)).is_some() {
bail!("duplicate mapping found");
@@ -747,7 +747,7 @@ fn restore_list_worker(
let file_list = snapshot_file_hash
.entry(media_id.label.uuid.clone())
- .or_insert_with(Vec::new);
+ .or_default();
file_list.push(file_num);
task_log!(
@@ -808,10 +808,8 @@ fn restore_list_worker(
// we only want to restore chunks that we do not have yet
if !datastore.cond_touch_chunk(&digest, false)? {
if let Some((uuid, nr)) = catalog.lookup_chunk(&source_datastore, &digest) {
- let file = media_file_chunk_map
- .entry(uuid.clone())
- .or_insert_with(BTreeMap::new);
- let chunks = file.entry(nr).or_insert_with(HashSet::new);
+ let file = media_file_chunk_map.entry(uuid.clone()).or_default();
+ let chunks = file.entry(nr).or_default();
chunks.insert(digest);
}
}
@@ -1089,9 +1087,7 @@ fn restore_snapshots_to_tmpdir(
);
std::fs::create_dir_all(&tmp_path)?;
- let chunks = chunks_list
- .entry(source_datastore)
- .or_insert_with(HashSet::new);
+ let chunks = chunks_list.entry(source_datastore).or_default();
let manifest =
try_restore_snapshot_archive(worker.clone(), &mut decoder, &tmp_path)?;
--
2.39.2
^ permalink raw reply [flat|nested] 12+ messages in thread
* [pbs-devel] [PATCH backup 06/13] access first element with first() rather than get(0)
2024-02-12 13:17 [pbs-devel] [PATCH backup 01/13] docs: remove redundant explicit link target Maximiliano Sandoval
` (3 preceding siblings ...)
2024-02-12 13:17 ` [pbs-devel] [PATCH backup 05/13] use or_default instead of or_insert_with(Default::default) Maximiliano Sandoval
@ 2024-02-12 13:17 ` Maximiliano Sandoval
2024-02-12 13:17 ` [pbs-devel] [PATCH backup 07/13] datastore: use is_{err, some} rather than match {Ok, Some}(_) Maximiliano Sandoval
` (3 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Maximiliano Sandoval @ 2024-02-12 13:17 UTC (permalink / raw)
To: pbs-devel
Fixes the clippy lint
```
warning: accessing first element with `self.transports.get(0)`
--> pbs-tape/src/lib.rs:283:9
|
283 | / self.transports
284 | | .get(0)
| |___________________^ help: try: `self.transports.first()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#get_first
= note: `#[warn(clippy::get_first)]` on by default
```
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
pbs-tape/src/lib.rs | 2 +-
pbs-tape/src/sg_pt_changer.rs | 2 +-
src/server/realm_sync_job.rs | 4 ++--
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/pbs-tape/src/lib.rs b/pbs-tape/src/lib.rs
index 1de2bc54..8d408b70 100644
--- a/pbs-tape/src/lib.rs
+++ b/pbs-tape/src/lib.rs
@@ -281,7 +281,7 @@ impl MtxStatus {
// (are there changers exposing more than one?)
// defaults to 0 for changer that do not report transports
self.transports
- .get(0)
+ .first()
.map(|t| t.element_address)
.unwrap_or(0u16)
}
diff --git a/pbs-tape/src/sg_pt_changer.rs b/pbs-tape/src/sg_pt_changer.rs
index 5b8596f0..3945d18f 100644
--- a/pbs-tape/src/sg_pt_changer.rs
+++ b/pbs-tape/src/sg_pt_changer.rs
@@ -850,7 +850,7 @@ mod test {
.map(|desc| build_storage_descriptor(desc, trailing))
.collect();
- let (desc_len, address) = if let Some(el) = descs.get(0) {
+ let (desc_len, address) = if let Some(el) = descs.first() {
(el.len() as u16, descriptors[0].address)
} else {
(0u16, 0u16)
diff --git a/src/server/realm_sync_job.rs b/src/server/realm_sync_job.rs
index 9094c2fa..158c2c37 100644
--- a/src/server/realm_sync_job.rs
+++ b/src/server/realm_sync_job.rs
@@ -170,7 +170,7 @@ impl LdapRealmSyncJob {
"userid attribute `{user_id_attribute}` not in LDAP search result"
)
})?
- .get(0)
+ .first()
.context("userid attribute array is empty")?
.clone();
@@ -233,7 +233,7 @@ impl LdapRealmSyncJob {
existing_user: Option<&User>,
) -> User {
let lookup = |attribute: &str, ldap_attribute: Option<&String>, schema: &'static Schema| {
- let value = result.attributes.get(ldap_attribute?)?.get(0)?;
+ let value = result.attributes.get(ldap_attribute?)?.first()?;
let schema = schema.unwrap_string_schema();
if let Err(e) = schema.check_constraints(value) {
--
2.39.2
^ permalink raw reply [flat|nested] 12+ messages in thread
* [pbs-devel] [PATCH backup 07/13] datastore: use is_{err, some} rather than match {Ok, Some}(_)
2024-02-12 13:17 [pbs-devel] [PATCH backup 01/13] docs: remove redundant explicit link target Maximiliano Sandoval
` (4 preceding siblings ...)
2024-02-12 13:17 ` [pbs-devel] [PATCH backup 06/13] access first element with first() rather than get(0) Maximiliano Sandoval
@ 2024-02-12 13:17 ` Maximiliano Sandoval
2024-02-12 13:17 ` [pbs-devel] [PATCH backup 08/13] snapshot_reader: use Rc for structs that are not Send+Sync Maximiliano Sandoval
` (2 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Maximiliano Sandoval @ 2024-02-12 13:17 UTC (permalink / raw)
To: pbs-devel
Fixes the clippy lint:
```
warning: redundant pattern matching, consider using `is_ok()`
--> pbs-datastore/src/datastore.rs:1025:10
|
1025 | !matches!(self.inner.gc_mutex.try_lock(), Ok(_))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `self.inner.gc_mutex.try_lock().is_ok()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_pattern_matching
= note: `#[warn(clippy::redundant_pattern_matching)]` on by default
```
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
pbs-datastore/src/datastore.rs | 2 +-
src/api2/config/access/ldap.rs | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/pbs-datastore/src/datastore.rs b/pbs-datastore/src/datastore.rs
index de948821..2f0e5279 100644
--- a/pbs-datastore/src/datastore.rs
+++ b/pbs-datastore/src/datastore.rs
@@ -1022,7 +1022,7 @@ impl DataStore {
}
pub fn garbage_collection_running(&self) -> bool {
- !matches!(self.inner.gc_mutex.try_lock(), Ok(_))
+ self.inner.gc_mutex.try_lock().is_err()
}
pub fn garbage_collection(
diff --git a/src/api2/config/access/ldap.rs b/src/api2/config/access/ldap.rs
index 911142a0..e60dc9c1 100644
--- a/src/api2/config/access/ldap.rs
+++ b/src/api2/config/access/ldap.rs
@@ -337,7 +337,7 @@ pub fn update_ldap_realm(
config.user_classes = Some(user_classes);
}
- let ldap_config = if let Some(_) = password {
+ let ldap_config = if password.is_some() {
LdapAuthenticator::api_type_to_config_with_password(&config, password.clone())?
} else {
LdapAuthenticator::api_type_to_config(&config)?
--
2.39.2
^ permalink raw reply [flat|nested] 12+ messages in thread
* [pbs-devel] [PATCH backup 08/13] snapshot_reader: use Rc for structs that are not Send+Sync
2024-02-12 13:17 [pbs-devel] [PATCH backup 01/13] docs: remove redundant explicit link target Maximiliano Sandoval
` (5 preceding siblings ...)
2024-02-12 13:17 ` [pbs-devel] [PATCH backup 07/13] datastore: use is_{err, some} rather than match {Ok, Some}(_) Maximiliano Sandoval
@ 2024-02-12 13:17 ` Maximiliano Sandoval
2024-02-13 9:20 ` Fabian Grünbichler
2024-02-12 13:17 ` [pbs-devel] [PATCH backup 09/13] pxar: elide explicit lifetime Maximiliano Sandoval
2024-02-13 9:04 ` [pbs-devel] [PATCH backup 01/13] docs: remove redundant explicit link target Maximiliano Sandoval
8 siblings, 1 reply; 12+ messages in thread
From: Maximiliano Sandoval @ 2024-02-12 13:17 UTC (permalink / raw)
To: pbs-devel
Fixes the clippy lint:
```
warning: usage of an `Arc` that is not `Send` and `Sync`
--> pbs-datastore/src/snapshot_reader.rs:156:52
|
156 | self.current_index = Some((Arc::new(index), 0, order));
| ^^^^^^^^^^^^^^^
|
= note: `Arc<Box<dyn IndexFile + Send>>` is not `Send` and `Sync` as:
= note: - the trait `Sync` is not implemented for `Box<dyn IndexFile + Send>`
= help: consider using an `Rc` instead. `Arc` does not provide benefits for non `Send` and `Sync` types
= note: if you intend to use `Arc` with `Send` and `Sync` traits
= note: wrap the inner type with a `Mutex` or implement `Send` and `Sync` for `Box<dyn IndexFile + Send>`
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#arc_with_non_send_sync
= note: `#[warn(clippy::arc_with_non_send_sync)]` on by default
```
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
pbs-datastore/src/snapshot_reader.rs | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/pbs-datastore/src/snapshot_reader.rs b/pbs-datastore/src/snapshot_reader.rs
index ec7a48e5..816df310 100644
--- a/pbs-datastore/src/snapshot_reader.rs
+++ b/pbs-datastore/src/snapshot_reader.rs
@@ -1,6 +1,7 @@
use std::fs::File;
use std::os::unix::io::{AsRawFd, FromRawFd};
use std::path::Path;
+use std::rc::Rc;
use std::sync::Arc;
use anyhow::{bail, Error};
@@ -126,7 +127,7 @@ pub struct SnapshotChunkIterator<'a, F: Fn(&[u8; 32]) -> bool> {
todo_list: Vec<String>,
skip_fn: F,
#[allow(clippy::type_complexity)]
- current_index: Option<(Arc<Box<dyn IndexFile + Send>>, usize, Vec<(usize, u64)>)>,
+ current_index: Option<(Rc<Box<dyn IndexFile + Send>>, usize, Vec<(usize, u64)>)>,
}
impl<'a, F: Fn(&[u8; 32]) -> bool> Iterator for SnapshotChunkIterator<'a, F> {
@@ -153,7 +154,7 @@ impl<'a, F: Fn(&[u8; 32]) -> bool> Iterator for SnapshotChunkIterator<'a, F> {
let order =
datastore.get_chunks_in_order(&*index, &self.skip_fn, |_| Ok(()))?;
- self.current_index = Some((Arc::new(index), 0, order));
+ self.current_index = Some((Rc::new(index), 0, order));
} else {
return Ok(None);
}
--
2.39.2
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [pbs-devel] [PATCH backup 08/13] snapshot_reader: use Rc for structs that are not Send+Sync
2024-02-12 13:17 ` [pbs-devel] [PATCH backup 08/13] snapshot_reader: use Rc for structs that are not Send+Sync Maximiliano Sandoval
@ 2024-02-13 9:20 ` Fabian Grünbichler
0 siblings, 0 replies; 12+ messages in thread
From: Fabian Grünbichler @ 2024-02-13 9:20 UTC (permalink / raw)
To: Proxmox Backup Server development discussion
On February 12, 2024 2:17 pm, Maximiliano Sandoval wrote:
> Fixes the clippy lint:
>
> ```
> warning: usage of an `Arc` that is not `Send` and `Sync`
> --> pbs-datastore/src/snapshot_reader.rs:156:52
> |
> 156 | self.current_index = Some((Arc::new(index), 0, order));
> | ^^^^^^^^^^^^^^^
> |
> = note: `Arc<Box<dyn IndexFile + Send>>` is not `Send` and `Sync` as:
> = note: - the trait `Sync` is not implemented for `Box<dyn IndexFile + Send>`
> = help: consider using an `Rc` instead. `Arc` does not provide benefits for non `Send` and `Sync` types
> = note: if you intend to use `Arc` with `Send` and `Sync` traits
> = note: wrap the inner type with a `Mutex` or implement `Send` and `Sync` for `Box<dyn IndexFile + Send>`
> = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#arc_with_non_send_sync
> = note: `#[warn(clippy::arc_with_non_send_sync)]` on by default
> ```
while this fixes the lint, isn't Rc also unneeded here? or am I missing
something..
>
> Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
> ---
> pbs-datastore/src/snapshot_reader.rs | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/pbs-datastore/src/snapshot_reader.rs b/pbs-datastore/src/snapshot_reader.rs
> index ec7a48e5..816df310 100644
> --- a/pbs-datastore/src/snapshot_reader.rs
> +++ b/pbs-datastore/src/snapshot_reader.rs
> @@ -1,6 +1,7 @@
> use std::fs::File;
> use std::os::unix::io::{AsRawFd, FromRawFd};
> use std::path::Path;
> +use std::rc::Rc;
> use std::sync::Arc;
>
> use anyhow::{bail, Error};
> @@ -126,7 +127,7 @@ pub struct SnapshotChunkIterator<'a, F: Fn(&[u8; 32]) -> bool> {
> todo_list: Vec<String>,
> skip_fn: F,
> #[allow(clippy::type_complexity)]
> - current_index: Option<(Arc<Box<dyn IndexFile + Send>>, usize, Vec<(usize, u64)>)>,
> + current_index: Option<(Rc<Box<dyn IndexFile + Send>>, usize, Vec<(usize, u64)>)>,
> }
>
> impl<'a, F: Fn(&[u8; 32]) -> bool> Iterator for SnapshotChunkIterator<'a, F> {
> @@ -153,7 +154,7 @@ impl<'a, F: Fn(&[u8; 32]) -> bool> Iterator for SnapshotChunkIterator<'a, F> {
> let order =
> datastore.get_chunks_in_order(&*index, &self.skip_fn, |_| Ok(()))?;
>
> - self.current_index = Some((Arc::new(index), 0, order));
> + self.current_index = Some((Rc::new(index), 0, order));
> } else {
> return Ok(None);
> }
> --
> 2.39.2
^ permalink raw reply [flat|nested] 12+ messages in thread
* [pbs-devel] [PATCH backup 09/13] pxar: elide explicit lifetime
2024-02-12 13:17 [pbs-devel] [PATCH backup 01/13] docs: remove redundant explicit link target Maximiliano Sandoval
` (6 preceding siblings ...)
2024-02-12 13:17 ` [pbs-devel] [PATCH backup 08/13] snapshot_reader: use Rc for structs that are not Send+Sync Maximiliano Sandoval
@ 2024-02-12 13:17 ` Maximiliano Sandoval
2024-02-13 9:04 ` [pbs-devel] [PATCH backup 01/13] docs: remove redundant explicit link target Maximiliano Sandoval
8 siblings, 0 replies; 12+ messages in thread
From: Maximiliano Sandoval @ 2024-02-12 13:17 UTC (permalink / raw)
To: pbs-devel
Fixes the clippy lint
```
warning: the following explicit lifetimes could be elided: 'b
--> pbs-client/src/pxar/create.rs:225:33
|
225 | fn archive_dir_contents<'a, 'b, T: SeqWrite + Send>(
| ^^
226 | &'a mut self,
227 | encoder: &'a mut Encoder<'b, T>,
| ^^
|
= 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
help: elide the lifetimes
|
225 ~ fn archive_dir_contents<'a, T: SeqWrite + Send>(
226 | &'a mut self,
227 ~ encoder: &'a mut Encoder<'_, T>,
|
```
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
pbs-client/src/pxar/create.rs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pbs-client/src/pxar/create.rs b/pbs-client/src/pxar/create.rs
index e7053d9e..3cf2b35a 100644
--- a/pbs-client/src/pxar/create.rs
+++ b/pbs-client/src/pxar/create.rs
@@ -222,9 +222,9 @@ impl Archiver {
}
}
- fn archive_dir_contents<'a, 'b, T: SeqWrite + Send>(
+ fn archive_dir_contents<'a, T: SeqWrite + Send>(
&'a mut self,
- encoder: &'a mut Encoder<'b, T>,
+ encoder: &'a mut Encoder<'_, T>,
mut dir: Dir,
is_root: bool,
) -> BoxFuture<'a, Result<(), Error>> {
--
2.39.2
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [pbs-devel] [PATCH backup 01/13] docs: remove redundant explicit link target
2024-02-12 13:17 [pbs-devel] [PATCH backup 01/13] docs: remove redundant explicit link target Maximiliano Sandoval
` (7 preceding siblings ...)
2024-02-12 13:17 ` [pbs-devel] [PATCH backup 09/13] pxar: elide explicit lifetime Maximiliano Sandoval
@ 2024-02-13 9:04 ` Maximiliano Sandoval
2024-02-13 9:28 ` [pbs-devel] partially-applied: " Fabian Grünbichler
8 siblings, 1 reply; 12+ messages in thread
From: Maximiliano Sandoval @ 2024-02-13 9:04 UTC (permalink / raw)
To: Maximiliano Sandoval; +Cc: pbs-devel
I somehow managed to not send the entire series, I'll send a new one 🙊.
Days since last email incident: 0.
Maximiliano Sandoval <m.sandoval@proxmox.com> writes:
> Fixes:
>
> ```
> warning: redundant explicit link target
> --> src/tools/mod.rs:47:42
> |
> 47 | /// Returns a new instance of [`Client`](proxmox_http::client::Client) configured for PBS usage.
> | -------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ explicit target is redundant
> | |
> | because label contains path that resolves to same destination
> |
> = note: when a link's destination is not specified,
> the label is used to resolve intra-doc links
> = note: `#[warn(rustdoc::redundant_explicit_links)]` on by default
> help: remove explicit link target
> |
> 47 | /// Returns a new instance of [`Client`] configured for PBS usage.
> | ~~~~~~~~~~
> ```
>
> Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
> ---
> pbs-config/src/acl.rs | 2 +-
> src/tools/mod.rs | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/pbs-config/src/acl.rs b/pbs-config/src/acl.rs
> index 20269f5d..cd9987fa 100644
> --- a/pbs-config/src/acl.rs
> +++ b/pbs-config/src/acl.rs
> @@ -198,7 +198,7 @@ impl AclTreeNode {
> }
>
> /// Returns applicable [Role] and their propagation status for a given
> - /// [Authid](pbs_api_types::Authid).
> + /// [Authid].
> ///
> /// If the `Authid` is a [User](pbs_api_types::User) that has no specific `Roles` configured on
> /// this node, applicable `Group` roles will be returned instead.
> diff --git a/src/tools/mod.rs b/src/tools/mod.rs
> index b6cc5448..f8c4f2d5 100644
> --- a/src/tools/mod.rs
> +++ b/src/tools/mod.rs
> @@ -44,7 +44,7 @@ pub fn detect_modified_configuration_file(
> pub const PROXMOX_BACKUP_TCP_KEEPALIVE_TIME: u32 = 120;
> pub const DEFAULT_USER_AGENT_STRING: &str = "proxmox-backup-client/1.0";
>
> -/// Returns a new instance of [`Client`](proxmox_http::client::Client) configured for PBS usage.
> +/// Returns a new instance of [`Client`] configured for PBS usage.
> pub fn pbs_simple_http(proxy_config: Option<ProxyConfig>) -> Client {
> let options = HttpOptions {
> proxy_config,
--
Maximiliano
^ permalink raw reply [flat|nested] 12+ messages in thread
* [pbs-devel] partially-applied: [PATCH backup 01/13] docs: remove redundant explicit link target
2024-02-13 9:04 ` [pbs-devel] [PATCH backup 01/13] docs: remove redundant explicit link target Maximiliano Sandoval
@ 2024-02-13 9:28 ` Fabian Grünbichler
0 siblings, 0 replies; 12+ messages in thread
From: Fabian Grünbichler @ 2024-02-13 9:28 UTC (permalink / raw)
To: Maximiliano Sandoval, Proxmox Backup Server development discussion
applied all (sent ;)) patches except #8, see comment there.
On February 13, 2024 10:04 am, Maximiliano Sandoval wrote:
>
> I somehow managed to not send the entire series, I'll send a new one 🙊.
>
> Days since last email incident: 0.
>
> Maximiliano Sandoval <m.sandoval@proxmox.com> writes:
>
>> Fixes:
>>
>> ```
>> warning: redundant explicit link target
>> --> src/tools/mod.rs:47:42
>> |
>> 47 | /// Returns a new instance of [`Client`](proxmox_http::client::Client) configured for PBS usage.
>> | -------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ explicit target is redundant
>> | |
>> | because label contains path that resolves to same destination
>> |
>> = note: when a link's destination is not specified,
>> the label is used to resolve intra-doc links
>> = note: `#[warn(rustdoc::redundant_explicit_links)]` on by default
>> help: remove explicit link target
>> |
>> 47 | /// Returns a new instance of [`Client`] configured for PBS usage.
>> | ~~~~~~~~~~
>> ```
>>
>> Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
>> ---
>> pbs-config/src/acl.rs | 2 +-
>> src/tools/mod.rs | 2 +-
>> 2 files changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/pbs-config/src/acl.rs b/pbs-config/src/acl.rs
>> index 20269f5d..cd9987fa 100644
>> --- a/pbs-config/src/acl.rs
>> +++ b/pbs-config/src/acl.rs
>> @@ -198,7 +198,7 @@ impl AclTreeNode {
>> }
>>
>> /// Returns applicable [Role] and their propagation status for a given
>> - /// [Authid](pbs_api_types::Authid).
>> + /// [Authid].
>> ///
>> /// If the `Authid` is a [User](pbs_api_types::User) that has no specific `Roles` configured on
>> /// this node, applicable `Group` roles will be returned instead.
>> diff --git a/src/tools/mod.rs b/src/tools/mod.rs
>> index b6cc5448..f8c4f2d5 100644
>> --- a/src/tools/mod.rs
>> +++ b/src/tools/mod.rs
>> @@ -44,7 +44,7 @@ pub fn detect_modified_configuration_file(
>> pub const PROXMOX_BACKUP_TCP_KEEPALIVE_TIME: u32 = 120;
>> pub const DEFAULT_USER_AGENT_STRING: &str = "proxmox-backup-client/1.0";
>>
>> -/// Returns a new instance of [`Client`](proxmox_http::client::Client) configured for PBS usage.
>> +/// Returns a new instance of [`Client`] configured for PBS usage.
>> pub fn pbs_simple_http(proxy_config: Option<ProxyConfig>) -> Client {
>> let options = HttpOptions {
>> proxy_config,
>
>
> --
> Maximiliano
>
>
> _______________________________________________
> pbs-devel mailing list
> pbs-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
>
^ permalink raw reply [flat|nested] 12+ messages in thread