public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH backup 0/2] More clippy fixes
@ 2024-02-14  9:04 Maximiliano Sandoval
  2024-02-14  9:04 ` [pbs-devel] [PATCH backup 1/2] restore-daemon: Module docs should use //! rather than ///! Maximiliano Sandoval
  2024-02-14  9:04 ` [pbs-devel] [PATCH backup 2/2] restore-daemon: Use first() when it makes sense Maximiliano Sandoval
  0 siblings, 2 replies; 3+ messages in thread
From: Maximiliano Sandoval @ 2024-02-14  9:04 UTC (permalink / raw)
  To: pbs-devel

Does more clippy fixes on the crates that were not covered by `cargo clippy`
without the `--all` flag.

Maximiliano Sandoval (2):
  restore-daemon: Module docs should use //! rather than ///!
  restore-daemon: Use first() when it makes sense

 proxmox-restore-daemon/src/main.rs                        | 2 +-
 proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs  | 2 +-
 proxmox-restore-daemon/src/proxmox_restore_daemon/disk.rs | 4 ++--
 proxmox-restore-daemon/src/proxmox_restore_daemon/mod.rs  | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

-- 
2.39.2





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

* [pbs-devel] [PATCH backup 1/2] restore-daemon: Module docs should use //! rather than ///!
  2024-02-14  9:04 [pbs-devel] [PATCH backup 0/2] More clippy fixes Maximiliano Sandoval
@ 2024-02-14  9:04 ` Maximiliano Sandoval
  2024-02-14  9:04 ` [pbs-devel] [PATCH backup 2/2] restore-daemon: Use first() when it makes sense Maximiliano Sandoval
  1 sibling, 0 replies; 3+ messages in thread
From: Maximiliano Sandoval @ 2024-02-14  9:04 UTC (permalink / raw)
  To: pbs-devel

Otherwise they apply to the next item only. The example in the link
of the following clippy lint:

```
warning: this is an outer doc comment and does not apply to the parent module or crate
 --> proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs:1:1
  |
1 | ///! File-restore API running inside the restore VM
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_doc_comments
help: use an inner doc comment to document the parent module or crate
  |
1 | //! File-restore API running inside the restore VM
```

suggests that

```
pub mod foo {
    ///! This docstring is attached to `bar` rather than `foo`.

    pub fn bar() {}
}
```

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 proxmox-restore-daemon/src/main.rs                       | 2 +-
 proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs | 2 +-
 proxmox-restore-daemon/src/proxmox_restore_daemon/mod.rs | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/proxmox-restore-daemon/src/main.rs b/proxmox-restore-daemon/src/main.rs
index f94b6c67..f9df2705 100644
--- a/proxmox-restore-daemon/src/main.rs
+++ b/proxmox-restore-daemon/src/main.rs
@@ -1,4 +1,4 @@
-///! Daemon binary to run inside a micro-VM for secure single file restore of disk images
+//! Daemon binary to run inside a micro-VM for secure single file restore of disk images
 use std::fs::File;
 use std::io::prelude::*;
 use std::os::unix::{
diff --git a/proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs b/proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs
index c4e97d33..f2a0cdab 100644
--- a/proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs
+++ b/proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs
@@ -1,4 +1,4 @@
-///! File-restore API running inside the restore VM
+//! File-restore API running inside the restore VM
 use std::ffi::OsStr;
 use std::fs;
 use std::os::unix::ffi::OsStrExt;
diff --git a/proxmox-restore-daemon/src/proxmox_restore_daemon/mod.rs b/proxmox-restore-daemon/src/proxmox_restore_daemon/mod.rs
index 58e2bb6e..d50c3287 100644
--- a/proxmox-restore-daemon/src/proxmox_restore_daemon/mod.rs
+++ b/proxmox-restore-daemon/src/proxmox_restore_daemon/mod.rs
@@ -1,4 +1,4 @@
-///! File restore VM related functionality
+//! File restore VM related functionality
 mod api;
 pub use api::*;
 
-- 
2.39.2





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

* [pbs-devel] [PATCH backup 2/2] restore-daemon: Use first() when it makes sense
  2024-02-14  9:04 [pbs-devel] [PATCH backup 0/2] More clippy fixes Maximiliano Sandoval
  2024-02-14  9:04 ` [pbs-devel] [PATCH backup 1/2] restore-daemon: Module docs should use //! rather than ///! Maximiliano Sandoval
@ 2024-02-14  9:04 ` Maximiliano Sandoval
  1 sibling, 0 replies; 3+ messages in thread
From: Maximiliano Sandoval @ 2024-02-14  9:04 UTC (permalink / raw)
  To: pbs-devel

Fixes the following Clippy lint

```
warning: accessing first element with `comp.get(0)`
   --> proxmox-restore-daemon/src/proxmox_restore_daemon/disk.rs:102:37
    |
102 |                 if let Some(comp) = comp.get(0) {
    |                                     ^^^^^^^^^^^ help: try: `comp.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
```

The lint

```
warning: accessing first element with `comp.get(0)`
   --> proxmox-restore-daemon/src/proxmox_restore_daemon/disk.rs:117:56
    |
117 |                 if let (Some(ref vg), Some(ref lv)) = (comp.get(0), comp.get(1)) {
    |                                                        ^^^^^^^^^^^ help: try: `comp.first()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#get_first
```

was not fixed (nor a clippy::allow was added) on purpose.

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

diff --git a/proxmox-restore-daemon/src/proxmox_restore_daemon/disk.rs b/proxmox-restore-daemon/src/proxmox_restore_daemon/disk.rs
index bde459dd..f651afea 100644
--- a/proxmox-restore-daemon/src/proxmox_restore_daemon/disk.rs
+++ b/proxmox-restore-daemon/src/proxmox_restore_daemon/disk.rs
@@ -99,7 +99,7 @@ impl Bucket {
         let ty = ty.as_ref();
         haystack.iter_mut().find(|b| match b {
             Bucket::Partition(data) => {
-                if let Some(comp) = comp.get(0) {
+                if let Some(comp) = comp.first() {
                     ty == "part" && comp.as_ref().parse::<i32>().unwrap() == data.number
                 } else {
                     false
@@ -107,7 +107,7 @@ impl Bucket {
             }
             Bucket::RawFs(_) => ty == "raw",
             Bucket::ZPool(data) => {
-                if let Some(ref comp) = comp.get(0) {
+                if let Some(ref comp) = comp.first() {
                     ty == "zpool" && comp.as_ref() == data.name
                 } else {
                     false
-- 
2.39.2





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

end of thread, other threads:[~2024-02-14  9:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-14  9:04 [pbs-devel] [PATCH backup 0/2] More clippy fixes Maximiliano Sandoval
2024-02-14  9:04 ` [pbs-devel] [PATCH backup 1/2] restore-daemon: Module docs should use //! rather than ///! Maximiliano Sandoval
2024-02-14  9:04 ` [pbs-devel] [PATCH backup 2/2] restore-daemon: Use first() when it makes sense Maximiliano Sandoval

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