* [pbs-devel] [PATCH proxmox 00/19] clippy, test and doc clean up
@ 2025-03-06 12:43 Shannon Sterz
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 01/19] io: clippy fix: replace `map()` followed by `any()` with just `any()` Shannon Sterz
` (19 more replies)
0 siblings, 20 replies; 21+ messages in thread
From: Shannon Sterz @ 2025-03-06 12:43 UTC (permalink / raw)
To: pbs-devel
this series intends to clean up all clippy lints for all crates in the
proxmox repo. it also makes sure all non-ignored test cases work again
(some recent changes broke some test cases) and cleans up all warnings
that were produced when running `cargo doc`.
Shannon Sterz (19):
io: clippy fix: replace `map()` followed by `any()` with just `any()`
tree-wide: add parantheses to clarify precedence
tree-wide: remove clone calls on types that are `Copy`
tfa: don't use block in conditions
tfa: remove needless `as_bytes` call
access-control/tfa: use `?` instead of unnecessary match statements
sys: add truncate option to `OpenOptions` in test case
router: allow `from_str` on Confirmation that is not for `FromStr`
auth-api/tfa: prefer `Display` over `ToString`/an inherent function
acme/auth-api: add `Default` for types with un-parameterized `new()`
shared-memory: specify generic types for transmute
router: ignore clippy lint `missing_transmute_annotations`
rest-server/router: ignore type complexity clippy lint
apt: ignore clippy lint about using a slice reference instead of
`&Vec`
apt: ignore clippy lint about new having to return `Self`
network-api: ignore clippy lint about upper case acronyms
router: fix nested doc test cases to match inteded output
api-macro: re-order ObjectSchema fields to be sorted
tree-wide: fix intra doc links
proxmox-access-control/src/acl.rs | 25 +++++++------------
proxmox-acme-api/src/challenge_schemas.rs | 1 +
proxmox-acme/src/async_client.rs | 2 +-
proxmox-acme/src/types.rs | 6 +++++
proxmox-api-macro/src/lib.rs | 13 +++++-----
proxmox-apt/src/cache.rs | 1 +
proxmox-apt/src/repositories/file.rs | 1 +
proxmox-auth-api/src/auth_key.rs | 6 +++++
proxmox-auth-api/src/ticket.rs | 9 ++++---
proxmox-client/src/client.rs | 2 +-
proxmox-compression/src/zip.rs | 2 +-
proxmox-io/src/sparse_copy.rs | 3 +--
proxmox-log/src/file_logger.rs | 3 +--
proxmox-network-api/src/config/lexer.rs | 1 +
.../examples/minimal-rest-server.rs | 1 +
proxmox-rest-server/src/api_config.rs | 4 +--
proxmox-rest-server/src/worker_task.rs | 14 +++--------
proxmox-router/src/cli/mod.rs | 1 +
proxmox-router/src/router.rs | 1 +
proxmox-router/src/stream/parsing.rs | 1 +
proxmox-router/tests/docs.rs | 3 +++
proxmox-rrd/src/cache.rs | 8 ++----
proxmox-rrd/src/cache/journal.rs | 18 +++----------
proxmox-rrd/src/cache/rrd_map.rs | 6 ++---
proxmox-schema/src/upid.rs | 2 +-
proxmox-shared-cache/src/lib.rs | 18 +++----------
proxmox-shared-memory/src/lib.rs | 2 +-
proxmox-sys/src/logrotate.rs | 2 +-
proxmox-sys/src/systemd.rs | 2 +-
proxmox-sys/tests/xattr.rs | 1 +
proxmox-systemd/src/escape.rs | 2 +-
proxmox-tfa/src/api/methods.rs | 23 +++++++++--------
proxmox-tfa/src/api/webauthn.rs | 10 +++++---
proxmox-tfa/src/totp.rs | 2 +-
proxmox-uuid/src/lib.rs | 12 ++++-----
35 files changed, 99 insertions(+), 109 deletions(-)
--
2.39.5
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
^ permalink raw reply [flat|nested] 21+ messages in thread
* [pbs-devel] [PATCH proxmox 01/19] io: clippy fix: replace `map()` followed by `any()` with just `any()`
2025-03-06 12:43 [pbs-devel] [PATCH proxmox 00/19] clippy, test and doc clean up Shannon Sterz
@ 2025-03-06 12:43 ` Shannon Sterz
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 02/19] tree-wide: add parantheses to clarify precedence Shannon Sterz
` (18 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Shannon Sterz @ 2025-03-06 12:43 UTC (permalink / raw)
To: pbs-devel
this fixes a clippy lint that complains about map invocations followed
by any invocations that are just checking for identity as this can be
replaced by just the any invocation alone [1].
[1]:
https://rust-lang.github.io/rust-clippy/master/index.html#map_all_any_identity
Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
---
proxmox-io/src/sparse_copy.rs | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/proxmox-io/src/sparse_copy.rs b/proxmox-io/src/sparse_copy.rs
index 9d09e6ad..fad1a51a 100644
--- a/proxmox-io/src/sparse_copy.rs
+++ b/proxmox-io/src/sparse_copy.rs
@@ -14,8 +14,7 @@ const BUF_SIZE: usize = 8192;
/// This is implemented in a way which allows the compiler to utilize SIMD instructions.
pub fn buffer_is_zero(buf: &[u8]) -> bool {
!buf.chunks(128)
- .map(|aa| aa.iter().fold(0, |a, b| a | b) != 0)
- .any(|a| a)
+ .any(|aa| aa.iter().fold(0, |a, b| a | b) != 0)
}
/// Result of a sparse copy call.
--
2.39.5
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
^ permalink raw reply [flat|nested] 21+ messages in thread
* [pbs-devel] [PATCH proxmox 02/19] tree-wide: add parantheses to clarify precedence
2025-03-06 12:43 [pbs-devel] [PATCH proxmox 00/19] clippy, test and doc clean up Shannon Sterz
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 01/19] io: clippy fix: replace `map()` followed by `any()` with just `any()` Shannon Sterz
@ 2025-03-06 12:43 ` Shannon Sterz
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 03/19] tree-wide: remove clone calls on types that are `Copy` Shannon Sterz
` (17 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Shannon Sterz @ 2025-03-06 12:43 UTC (permalink / raw)
To: pbs-devel
this resolves a clippy lint that aims to improve legibility for people
unaware of rust's precendence rules [1].
[1]:
https://rust-lang.github.io/rust-clippy/master/index.html#precedence
Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
---
proxmox-compression/src/zip.rs | 2 +-
proxmox-schema/src/upid.rs | 2 +-
proxmox-sys/src/systemd.rs | 2 +-
proxmox-systemd/src/escape.rs | 2 +-
proxmox-uuid/src/lib.rs | 12 ++++++------
5 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/proxmox-compression/src/zip.rs b/proxmox-compression/src/zip.rs
index 3ccece9b..11b29de4 100644
--- a/proxmox-compression/src/zip.rs
+++ b/proxmox-compression/src/zip.rs
@@ -360,7 +360,7 @@ impl ZipEntry {
comment_len: 0,
start_disk: 0,
internal_flags: 0,
- external_flags: (self.mode as u32) << 16 | (!self.is_file as u32) << 4,
+ external_flags: ((self.mode as u32) << 16) | ((!self.is_file as u32) << 4),
offset,
},
)
diff --git a/proxmox-schema/src/upid.rs b/proxmox-schema/src/upid.rs
index 9bbb66a1..897fa76a 100644
--- a/proxmox-schema/src/upid.rs
+++ b/proxmox-schema/src/upid.rs
@@ -191,7 +191,7 @@ fn unescape_id(text: &str) -> Result<String, Error> {
}
let h1 = hex_digit(i[2])?;
let h0 = hex_digit(i[3])?;
- data.push(h1 << 4 | h0);
+ data.push((h1 << 4) | h0);
i = &i[4..]
} else if next == b'-' {
data.push(b'/');
diff --git a/proxmox-sys/src/systemd.rs b/proxmox-sys/src/systemd.rs
index 43dc5185..d57f5816 100644
--- a/proxmox-sys/src/systemd.rs
+++ b/proxmox-sys/src/systemd.rs
@@ -90,7 +90,7 @@ fn unescape_unit_do(text: &str) -> Result<Vec<u8>, Error> {
}
let h1 = parse_hex_digit(i[2])?;
let h0 = parse_hex_digit(i[3])?;
- data.push(h1 << 4 | h0);
+ data.push((h1 << 4) | h0);
i = &i[4..]
} else if next == b'-' {
data.push(b'/');
diff --git a/proxmox-systemd/src/escape.rs b/proxmox-systemd/src/escape.rs
index f73beed3..392907bc 100644
--- a/proxmox-systemd/src/escape.rs
+++ b/proxmox-systemd/src/escape.rs
@@ -97,7 +97,7 @@ fn unescape_unit_do(text: &str) -> Result<Vec<u8>, UnescapeError> {
}
let h1 = parse_hex_digit(i[2])?;
let h0 = parse_hex_digit(i[3])?;
- data.push(h1 << 4 | h0);
+ data.push((h1 << 4) | h0);
i = &i[4..]
} else if next == b'-' {
data.push(b'/');
diff --git a/proxmox-uuid/src/lib.rs b/proxmox-uuid/src/lib.rs
index 09a70b49..800a8563 100644
--- a/proxmox-uuid/src/lib.rs
+++ b/proxmox-uuid/src/lib.rs
@@ -103,25 +103,25 @@ impl Uuid {
return Err(UuidError);
}
for i in 0..4 {
- uuid[i] = hex_digit(src[2 * i])? << 4 | hex_digit(src[2 * i + 1])?;
+ uuid[i] = (hex_digit(src[2 * i])? << 4) | hex_digit(src[2 * i + 1])?;
}
for i in 4..6 {
- uuid[i] = hex_digit(src[2 * i + 1])? << 4 | hex_digit(src[2 * i + 2])?;
+ uuid[i] = (hex_digit(src[2 * i + 1])? << 4) | hex_digit(src[2 * i + 2])?;
}
for i in 6..8 {
- uuid[i] = hex_digit(src[2 * i + 2])? << 4 | hex_digit(src[2 * i + 3])?;
+ uuid[i] = (hex_digit(src[2 * i + 2])? << 4) | hex_digit(src[2 * i + 3])?;
}
for i in 8..10 {
- uuid[i] = hex_digit(src[2 * i + 3])? << 4 | hex_digit(src[2 * i + 4])?;
+ uuid[i] = (hex_digit(src[2 * i + 3])? << 4) | hex_digit(src[2 * i + 4])?;
}
for i in 10..16 {
- uuid[i] = hex_digit(src[2 * i + 4])? << 4 | hex_digit(src[2 * i + 5])?;
+ uuid[i] = (hex_digit(src[2 * i + 4])? << 4) | hex_digit(src[2 * i + 5])?;
}
} else if src.len() == 32 {
let uuid: &mut [u8] = unsafe { &mut (*uuid)[..] };
let src = src.as_bytes();
for i in 0..16 {
- uuid[i] = hex_digit(src[2 * i])? << 4 | hex_digit(src[2 * i + 1])?;
+ uuid[i] = (hex_digit(src[2 * i])? << 4) | hex_digit(src[2 * i + 1])?;
}
} else {
return Err(UuidError);
--
2.39.5
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
^ permalink raw reply [flat|nested] 21+ messages in thread
* [pbs-devel] [PATCH proxmox 03/19] tree-wide: remove clone calls on types that are `Copy`
2025-03-06 12:43 [pbs-devel] [PATCH proxmox 00/19] clippy, test and doc clean up Shannon Sterz
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 01/19] io: clippy fix: replace `map()` followed by `any()` with just `any()` Shannon Sterz
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 02/19] tree-wide: add parantheses to clarify precedence Shannon Sterz
@ 2025-03-06 12:43 ` Shannon Sterz
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 04/19] tfa: don't use block in conditions Shannon Sterz
` (16 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Shannon Sterz @ 2025-03-06 12:43 UTC (permalink / raw)
To: pbs-devel
this resolves a clippy lint that checks that `clone()` isn't called on
`Copy` types as that is unnecessary [1].
[1]:
https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy
Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
---
proxmox-log/src/file_logger.rs | 3 +--
proxmox-rest-server/src/worker_task.rs | 9 ++-------
proxmox-rrd/src/cache.rs | 8 ++------
proxmox-rrd/src/cache/journal.rs | 18 ++++--------------
proxmox-rrd/src/cache/rrd_map.rs | 6 +++---
proxmox-shared-cache/src/lib.rs | 18 ++++--------------
proxmox-sys/src/logrotate.rs | 2 +-
7 files changed, 17 insertions(+), 47 deletions(-)
diff --git a/proxmox-log/src/file_logger.rs b/proxmox-log/src/file_logger.rs
index 1e67b450..39d16857 100644
--- a/proxmox-log/src/file_logger.rs
+++ b/proxmox-log/src/file_logger.rs
@@ -93,8 +93,7 @@ impl FileLogger {
flags |= OFlag::O_EXCL;
}
- let file =
- atomic_open_or_create_file(&file_name, flags, &[], options.file_opts.clone(), false)?;
+ let file = atomic_open_or_create_file(&file_name, flags, &[], options.file_opts, false)?;
Ok(file)
}
diff --git a/proxmox-rest-server/src/worker_task.rs b/proxmox-rest-server/src/worker_task.rs
index 24e2676e..9351bbee 100644
--- a/proxmox-rest-server/src/worker_task.rs
+++ b/proxmox-rest-server/src/worker_task.rs
@@ -136,7 +136,6 @@ impl WorkerTaskSetup {
fn lock_task_list_files(&self, exclusive: bool) -> Result<TaskListLockGuard, Error> {
let options = self
.file_opts
- .clone()
.perm(nix::sys::stat::Mode::from_bits_truncate(0o660));
let timeout = std::time::Duration::new(15, 0);
@@ -163,7 +162,6 @@ impl WorkerTaskSetup {
let mut path = self.log_directory(upid);
let dir_opts = self
.file_opts
- .clone()
.perm(nix::sys::stat::Mode::from_bits_truncate(0o755));
create_path(&path, None, Some(dir_opts))?;
@@ -222,7 +220,6 @@ impl WorkerTaskSetup {
let options = self
.file_opts
- .clone()
.perm(nix::sys::stat::Mode::from_bits_truncate(0o660));
replace_file(&self.active_tasks_fn, active_raw.as_bytes(), options, false)?;
@@ -237,7 +234,6 @@ impl WorkerTaskSetup {
if !finish_list.is_empty() {
let options = self
.file_opts
- .clone()
.perm(nix::sys::stat::Mode::from_bits_truncate(0o660));
let mut writer = atomic_open_or_create_file(
@@ -268,10 +264,9 @@ impl WorkerTaskSetup {
try_block!({
let dir_opts = self
.file_opts
- .clone()
.perm(nix::sys::stat::Mode::from_bits_truncate(0o755));
- create_path(&self.taskdir, Some(dir_opts.clone()), Some(dir_opts))?;
+ create_path(&self.taskdir, Some(dir_opts), Some(dir_opts))?;
// fixme:??? create_path(pbs_buildcfg::PROXMOX_BACKUP_RUN_DIR, None, Some(opts))?;
Ok(())
})
@@ -901,7 +896,7 @@ impl WorkerTask {
exclusive: true,
prefix_time: true,
read: true,
- file_opts: setup.file_opts.clone(),
+ file_opts: setup.file_opts,
..Default::default()
};
let logger = FileLogger::new(path, logger_options)?;
diff --git a/proxmox-rrd/src/cache.rs b/proxmox-rrd/src/cache.rs
index 9dd85a16..29d46ed5 100644
--- a/proxmox-rrd/src/cache.rs
+++ b/proxmox-rrd/src/cache.rs
@@ -66,12 +66,8 @@ impl Cache {
let file_options = file_options.unwrap_or_default();
let dir_options = dir_options.unwrap_or_default();
- create_path(
- &basedir,
- Some(dir_options.clone()),
- Some(dir_options.clone()),
- )
- .map_err(|err: Error| format_err!("unable to create rrdb stat dir - {}", err))?;
+ create_path(&basedir, Some(dir_options), Some(dir_options))
+ .map_err(|err: Error| format_err!("unable to create rrdb stat dir - {}", err))?;
let config = Arc::new(CacheConfig {
basedir,
diff --git a/proxmox-rrd/src/cache/journal.rs b/proxmox-rrd/src/cache/journal.rs
index c196b342..fe48f23b 100644
--- a/proxmox-rrd/src/cache/journal.rs
+++ b/proxmox-rrd/src/cache/journal.rs
@@ -112,13 +112,8 @@ impl JournalState {
journal_path.push(RRD_JOURNAL_NAME);
let flags = OFlag::O_CLOEXEC | OFlag::O_RDONLY;
- let journal = atomic_open_or_create_file(
- &journal_path,
- flags,
- &[],
- self.config.file_options.clone(),
- false,
- )?;
+ let journal =
+ atomic_open_or_create_file(&journal_path, flags, &[], self.config.file_options, false)?;
Ok(BufReader::new(journal))
}
@@ -127,13 +122,8 @@ impl JournalState {
journal_path.push(RRD_JOURNAL_NAME);
let flags = OFlag::O_CLOEXEC | OFlag::O_WRONLY | OFlag::O_APPEND;
- let journal = atomic_open_or_create_file(
- &journal_path,
- flags,
- &[],
- config.file_options.clone(),
- false,
- )?;
+ let journal =
+ atomic_open_or_create_file(&journal_path, flags, &[], config.file_options, false)?;
Ok(journal)
}
diff --git a/proxmox-rrd/src/cache/rrd_map.rs b/proxmox-rrd/src/cache/rrd_map.rs
index 0ef61cfa..27ea8e6e 100644
--- a/proxmox-rrd/src/cache/rrd_map.rs
+++ b/proxmox-rrd/src/cache/rrd_map.rs
@@ -51,8 +51,8 @@ impl RRDMap {
None => {
create_path(
path.parent().unwrap(),
- Some(self.config.dir_options.clone()),
- Some(self.config.dir_options.clone()),
+ Some(self.config.dir_options),
+ Some(self.config.dir_options),
)?;
(self.create_rrd_cb)(dst)
@@ -82,7 +82,7 @@ impl RRDMap {
if let Some(rrd) = self.map.get(rel_path) {
let mut path = self.config.basedir.clone();
path.push(rel_path);
- rrd.save(&path, self.config.file_options.clone(), true)
+ rrd.save(&path, self.config.file_options, true)
} else {
bail!("rrd file {} not loaded", rel_path);
}
diff --git a/proxmox-shared-cache/src/lib.rs b/proxmox-shared-cache/src/lib.rs
index d0b2148a..65abc1ac 100644
--- a/proxmox-shared-cache/src/lib.rs
+++ b/proxmox-shared-cache/src/lib.rs
@@ -127,7 +127,7 @@ impl SharedCache {
proxmox_sys::fs::replace_file(
&self.path,
new_content.as_bytes(),
- self.create_options.clone(),
+ self.create_options,
true,
)?;
@@ -137,7 +137,7 @@ impl SharedCache {
/// Removes all items from the cache.
pub fn delete(&self, lock_timeout: Duration) -> Result<(), Error> {
let _lock = self.lock(lock_timeout)?;
- proxmox_sys::fs::replace_file(&self.path, &[], self.create_options.clone(), true)?;
+ proxmox_sys::fs::replace_file(&self.path, &[], self.create_options, true)?;
Ok(())
}
@@ -145,12 +145,7 @@ impl SharedCache {
fn lock(&self, lock_timeout: Duration) -> Result<File, Error> {
let mut lockfile_path = self.path.clone();
lockfile_path.set_extension("lock");
- proxmox_sys::fs::open_file_locked(
- lockfile_path,
- lock_timeout,
- true,
- self.create_options.clone(),
- )
+ proxmox_sys::fs::open_file_locked(lockfile_path, lock_timeout, true, self.create_options)
}
}
@@ -178,12 +173,7 @@ mod tests {
.group(nix::unistd::Gid::effective())
.perm(nix::sys::stat::Mode::from_bits_truncate(0o700));
- proxmox_sys::fs::create_path(
- &path,
- Some(dir_options.clone()),
- Some(dir_options.clone()),
- )
- .unwrap();
+ proxmox_sys::fs::create_path(&path, Some(dir_options), Some(dir_options)).unwrap();
let cache = SharedCache::new(path.join("somekey"), options, keep_old).unwrap();
Self {
diff --git a/proxmox-sys/src/logrotate.rs b/proxmox-sys/src/logrotate.rs
index 704a18ce..cb96974a 100644
--- a/proxmox-sys/src/logrotate.rs
+++ b/proxmox-sys/src/logrotate.rs
@@ -64,7 +64,7 @@ impl LogRotate {
options: &CreateOptions,
) -> Result<(), Error> {
let mut source = File::open(source_path)?;
- let (fd, tmp_path) = make_tmp_file(target_path, options.clone())?;
+ let (fd, tmp_path) = make_tmp_file(target_path, *options)?;
let target = unsafe { File::from_raw_fd(fd.into_raw_fd()) };
let mut encoder = match zstd::stream::write::Encoder::new(target, 0) {
Ok(encoder) => encoder,
--
2.39.5
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
^ permalink raw reply [flat|nested] 21+ messages in thread
* [pbs-devel] [PATCH proxmox 04/19] tfa: don't use block in conditions
2025-03-06 12:43 [pbs-devel] [PATCH proxmox 00/19] clippy, test and doc clean up Shannon Sterz
` (2 preceding siblings ...)
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 03/19] tree-wide: remove clone calls on types that are `Copy` Shannon Sterz
@ 2025-03-06 12:43 ` Shannon Sterz
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 05/19] tfa: remove needless `as_bytes` call Shannon Sterz
` (15 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Shannon Sterz @ 2025-03-06 12:43 UTC (permalink / raw)
To: pbs-devel
this fixes a clippy style lint that does not allow blocks in
conditionals. moving the block out and the result into a temporary
variable should make this more legible [1].
[1]:
https://rust-lang.github.io/rust-clippy/master/index.html#blocks_in_conditions
Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
---
proxmox-tfa/src/api/methods.rs | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/proxmox-tfa/src/api/methods.rs b/proxmox-tfa/src/api/methods.rs
index 03dd8b4b..3c6dac40 100644
--- a/proxmox-tfa/src/api/methods.rs
+++ b/proxmox-tfa/src/api/methods.rs
@@ -103,12 +103,14 @@ pub fn get_tfa_entry(config: &TfaConfig, userid: &str, id: &str) -> Option<Typed
None => return None,
};
- Some(
- match {
+ Some({
+ let res = {
// scope to prevent the temporary iter from borrowing across the whole match
let entry = tfa_id_iter(user_data).find(|(_ty, _index, entry_id)| id == *entry_id);
entry.map(|(ty, index, _)| (ty, index))
- } {
+ };
+
+ match res {
Some((TfaType::Recovery, _)) => match &user_data.recovery {
Some(recovery) => TypedTfaInfo {
ty: TfaType::Recovery,
@@ -133,8 +135,8 @@ pub fn get_tfa_entry(config: &TfaConfig, userid: &str, id: &str) -> Option<Typed
info: user_data.yubico.get(index).unwrap().info.clone(),
},
None => return None,
- },
- )
+ }
+ })
}
pub struct EntryNotFound;
@@ -154,11 +156,13 @@ pub struct EntryNotFound;
pub fn delete_tfa(config: &mut TfaConfig, userid: &str, id: &str) -> Result<bool, EntryNotFound> {
let user_data = config.users.get_mut(userid).ok_or(EntryNotFound)?;
- match {
+ let res = {
// scope to prevent the temporary iter from borrowing across the whole match
let entry = tfa_id_iter(user_data).find(|(_, _, entry_id)| id == *entry_id);
entry.map(|(ty, index, _)| (ty, index))
- } {
+ };
+
+ match res {
Some((TfaType::Recovery, _)) => user_data.recovery = None,
Some((TfaType::Totp, index)) => drop(user_data.totp.remove(index)),
Some((TfaType::Webauthn, index)) => drop(user_data.webauthn.remove(index)),
--
2.39.5
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
^ permalink raw reply [flat|nested] 21+ messages in thread
* [pbs-devel] [PATCH proxmox 05/19] tfa: remove needless `as_bytes` call
2025-03-06 12:43 [pbs-devel] [PATCH proxmox 00/19] clippy, test and doc clean up Shannon Sterz
` (3 preceding siblings ...)
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 04/19] tfa: don't use block in conditions Shannon Sterz
@ 2025-03-06 12:43 ` Shannon Sterz
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 06/19] access-control/tfa: use `?` instead of unnecessary match statements Shannon Sterz
` (14 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Shannon Sterz @ 2025-03-06 12:43 UTC (permalink / raw)
To: pbs-devel
len() already returns the length in bytes, no need to call `as_bytes`
first. this fixes a clippy lint [1].
[1]:
https://rust-lang.github.io/rust-clippy/master/index.html#needless_as_bytes
Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
---
proxmox-tfa/src/totp.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/proxmox-tfa/src/totp.rs b/proxmox-tfa/src/totp.rs
index 940af542..6be340c7 100644
--- a/proxmox-tfa/src/totp.rs
+++ b/proxmox-tfa/src/totp.rs
@@ -546,7 +546,7 @@ impl PartialEq<&str> for TotpValue {
fn eq(&self, other: &&str) -> bool {
// Since we use `from_str_radix` with a radix of 10 explicitly, we can check the number of
// bytes against the number of digits.
- if other.as_bytes().len() != (self.digits as usize) {
+ if other.len() != (self.digits as usize) {
return false;
}
--
2.39.5
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
^ permalink raw reply [flat|nested] 21+ messages in thread
* [pbs-devel] [PATCH proxmox 06/19] access-control/tfa: use `?` instead of unnecessary match statements
2025-03-06 12:43 [pbs-devel] [PATCH proxmox 00/19] clippy, test and doc clean up Shannon Sterz
` (4 preceding siblings ...)
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 05/19] tfa: remove needless `as_bytes` call Shannon Sterz
@ 2025-03-06 12:43 ` Shannon Sterz
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 07/19] sys: add truncate option to `OpenOptions` in test case Shannon Sterz
` (13 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Shannon Sterz @ 2025-03-06 12:43 UTC (permalink / raw)
To: pbs-devel
this makes the code more concise and legible. fixes a clippy lint [1].
[1]:
https://rust-lang.github.io/rust-clippy/master/index.html#question_mark
Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
---
proxmox-access-control/src/acl.rs | 10 ++--------
proxmox-tfa/src/api/methods.rs | 5 +----
2 files changed, 3 insertions(+), 12 deletions(-)
diff --git a/proxmox-access-control/src/acl.rs b/proxmox-access-control/src/acl.rs
index 1964abe2..5a676d3d 100644
--- a/proxmox-access-control/src/acl.rs
+++ b/proxmox-access-control/src/acl.rs
@@ -208,10 +208,7 @@ impl AclTree {
let mut node = &self.root;
for outer in path {
for comp in outer.split('/') {
- node = match node.children.get(comp) {
- Some(n) => n,
- None => return None,
- };
+ node = node.children.get(comp)?;
}
}
Some(node)
@@ -221,10 +218,7 @@ impl AclTree {
let mut node = &mut self.root;
for outer in path {
for comp in outer.split('/') {
- node = match node.children.get_mut(comp) {
- Some(n) => n,
- None => return None,
- };
+ node = node.children.get_mut(comp)?;
}
}
Some(node)
diff --git a/proxmox-tfa/src/api/methods.rs b/proxmox-tfa/src/api/methods.rs
index 3c6dac40..a165400a 100644
--- a/proxmox-tfa/src/api/methods.rs
+++ b/proxmox-tfa/src/api/methods.rs
@@ -98,10 +98,7 @@ pub fn list_user_tfa(config: &TfaConfig, userid: &str) -> Result<Vec<TypedTfaInf
///
/// In case this returns `None` a `NOT_FOUND` http error should be returned.
pub fn get_tfa_entry(config: &TfaConfig, userid: &str, id: &str) -> Option<TypedTfaInfo> {
- let user_data = match config.users.get(userid) {
- Some(u) => u,
- None => return None,
- };
+ let user_data = config.users.get(userid)?;
Some({
let res = {
--
2.39.5
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
^ permalink raw reply [flat|nested] 21+ messages in thread
* [pbs-devel] [PATCH proxmox 07/19] sys: add truncate option to `OpenOptions` in test case
2025-03-06 12:43 [pbs-devel] [PATCH proxmox 00/19] clippy, test and doc clean up Shannon Sterz
` (5 preceding siblings ...)
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 06/19] access-control/tfa: use `?` instead of unnecessary match statements Shannon Sterz
@ 2025-03-06 12:43 ` Shannon Sterz
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 08/19] router: allow `from_str` on Confirmation that is not for `FromStr` Shannon Sterz
` (12 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Shannon Sterz @ 2025-03-06 12:43 UTC (permalink / raw)
To: pbs-devel
this resolves a clippy lint that checks for uses of `create()` without
`truncate()` [1].
[1]:
https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_open_options
Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
---
proxmox-sys/tests/xattr.rs | 1 +
1 file changed, 1 insertion(+)
diff --git a/proxmox-sys/tests/xattr.rs b/proxmox-sys/tests/xattr.rs
index 02d43934..42d7cdd5 100644
--- a/proxmox-sys/tests/xattr.rs
+++ b/proxmox-sys/tests/xattr.rs
@@ -14,6 +14,7 @@ fn test_fsetxattr_fgetxattr() {
let file = OpenOptions::new()
.write(true)
.create(true)
+ .truncate(true)
.open(&path)
.unwrap();
--
2.39.5
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
^ permalink raw reply [flat|nested] 21+ messages in thread
* [pbs-devel] [PATCH proxmox 08/19] router: allow `from_str` on Confirmation that is not for `FromStr`
2025-03-06 12:43 [pbs-devel] [PATCH proxmox 00/19] clippy, test and doc clean up Shannon Sterz
` (6 preceding siblings ...)
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 07/19] sys: add truncate option to `OpenOptions` in test case Shannon Sterz
@ 2025-03-06 12:43 ` Shannon Sterz
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 09/19] auth-api/tfa: prefer `Display` over `ToString`/an inherent function Shannon Sterz
` (11 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Shannon Sterz @ 2025-03-06 12:43 UTC (permalink / raw)
To: pbs-devel
while usually this would improve ergonomics, in this case it isn't
clear whether all uses of `FromStr` would be considered valid here.
renaming the function would also make the type more confusing to use
as `from_str_with_default` also exists, so keep this for consistency.
this ignores a clippy lint [1].
[1]:
https://rust-lang.github.io/rust-clippy/master/index.html#should_implement_trait
Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
---
proxmox-router/src/cli/mod.rs | 1 +
1 file changed, 1 insertion(+)
diff --git a/proxmox-router/src/cli/mod.rs b/proxmox-router/src/cli/mod.rs
index 2393da31..7c409f06 100644
--- a/proxmox-router/src/cli/mod.rs
+++ b/proxmox-router/src/cli/mod.rs
@@ -117,6 +117,7 @@ impl Confirmation {
/// let answer = Confirmation::from_str("bogus");
/// assert!(answer.is_err());
/// ```
+ #[allow(clippy::should_implement_trait)]
pub fn from_str(input: &str) -> Result<Self, Error> {
match input.trim() {
"y" | "Y" => Ok(Self::Yes),
--
2.39.5
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
^ permalink raw reply [flat|nested] 21+ messages in thread
* [pbs-devel] [PATCH proxmox 09/19] auth-api/tfa: prefer `Display` over `ToString`/an inherent function
2025-03-06 12:43 [pbs-devel] [PATCH proxmox 00/19] clippy, test and doc clean up Shannon Sterz
` (7 preceding siblings ...)
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 08/19] router: allow `from_str` on Confirmation that is not for `FromStr` Shannon Sterz
@ 2025-03-06 12:43 ` Shannon Sterz
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 10/19] acme/auth-api: add `Default` for types with un-parameterized `new()` Shannon Sterz
` (10 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Shannon Sterz @ 2025-03-06 12:43 UTC (permalink / raw)
To: pbs-devel
this fixes two clippy lints that check if either `ToString` or an
inherent `to_string()` function is implement [1, 2]. `Display`
provides `ToString` for free and, thus, is preferable.
[1]:
https://rust-lang.github.io/rust-clippy/master/index.html#/inherent_to_string
[2]:
https://rust-lang.github.io/rust-clippy/master/index.html#to_string_trait_impl
Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
---
proxmox-auth-api/src/ticket.rs | 9 +++++----
proxmox-tfa/src/api/webauthn.rs | 10 ++++++----
2 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/proxmox-auth-api/src/ticket.rs b/proxmox-auth-api/src/ticket.rs
index 59293492..df6c4eb6 100644
--- a/proxmox-auth-api/src/ticket.rs
+++ b/proxmox-auth-api/src/ticket.rs
@@ -1,6 +1,7 @@
//! Generate and verify Authentication tickets
use std::borrow::Cow;
+use std::fmt::Display;
use std::marker::PhantomData;
use anyhow::{bail, format_err, Error};
@@ -14,13 +15,13 @@ use crate::TICKET_LIFETIME;
/// Stringified ticket data must not contain colons...
const TICKET_ASCIISET: &AsciiSet = &percent_encoding::CONTROLS.add(b':');
-/// An empty type implementing [`ToString`] and [`FromStr`](std::str::FromStr), used for tickets
+/// An empty type implementing [`Display`] and [`FromStr`](std::str::FromStr), used for tickets
/// with no data.
pub struct Empty;
-impl ToString for Empty {
- fn to_string(&self) -> String {
- String::new()
+impl Display for Empty {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ write!(f, "")
}
}
diff --git a/proxmox-tfa/src/api/webauthn.rs b/proxmox-tfa/src/api/webauthn.rs
index 1793df97..7e04c328 100644
--- a/proxmox-tfa/src/api/webauthn.rs
+++ b/proxmox-tfa/src/api/webauthn.rs
@@ -1,5 +1,7 @@
//! Webauthn configuration and challenge data.
+use std::fmt::Display;
+
use anyhow::{format_err, Error};
use serde::{Deserialize, Serialize};
use url::Url;
@@ -42,9 +44,9 @@ impl From<OriginUrl> for String {
}
}
-impl OriginUrl {
- fn to_string(&self) -> String {
- self.0.origin().ascii_serialization()
+impl Display for OriginUrl {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ write!(f, "{}", self.0.origin().ascii_serialization())
}
}
@@ -91,7 +93,7 @@ impl WebauthnConfig {
pub fn digest(&self) -> [u8; 32] {
let mut data = format!("rp={:?}\nid={:?}\n", self.rp, self.id,);
if let Some(origin) = &self.origin {
- data.push_str(&format!("origin={}\n", origin.to_string()));
+ data.push_str(&format!("origin={}\n", origin));
}
openssl::sha::sha256(data.as_bytes())
}
--
2.39.5
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
^ permalink raw reply [flat|nested] 21+ messages in thread
* [pbs-devel] [PATCH proxmox 10/19] acme/auth-api: add `Default` for types with un-parameterized `new()`
2025-03-06 12:43 [pbs-devel] [PATCH proxmox 00/19] clippy, test and doc clean up Shannon Sterz
` (8 preceding siblings ...)
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 09/19] auth-api/tfa: prefer `Display` over `ToString`/an inherent function Shannon Sterz
@ 2025-03-06 12:43 ` Shannon Sterz
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 11/19] shared-memory: specify generic types for transmute Shannon Sterz
` (9 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Shannon Sterz @ 2025-03-06 12:43 UTC (permalink / raw)
To: pbs-devel
this fixes a clippy lint for types that have a `new()` function that
has no parameters [1]. this should allow using these types with
functions such as `unwrap_or_default()`.
[1]:
https://rust-lang.github.io/rust-clippy/master/index.html#new_without_default
Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
---
proxmox-acme/src/types.rs | 6 ++++++
proxmox-auth-api/src/auth_key.rs | 6 ++++++
2 files changed, 12 insertions(+)
diff --git a/proxmox-acme/src/types.rs b/proxmox-acme/src/types.rs
index e5a6b34d..0ec2deeb 100644
--- a/proxmox-acme/src/types.rs
+++ b/proxmox-acme/src/types.rs
@@ -38,6 +38,12 @@ pub enum AccountStatus {
Revoked,
}
+impl Default for AccountStatus {
+ fn default() -> Self {
+ Self::new()
+ }
+}
+
impl AccountStatus {
/// Create a new instance with state New.
#[inline]
diff --git a/proxmox-auth-api/src/auth_key.rs b/proxmox-auth-api/src/auth_key.rs
index 9873d935..500725d3 100644
--- a/proxmox-auth-api/src/auth_key.rs
+++ b/proxmox-auth-api/src/auth_key.rs
@@ -237,6 +237,12 @@ pub struct Keyring {
public_keys: Vec<VerificationKey>,
}
+impl Default for Keyring {
+ fn default() -> Self {
+ Self::new()
+ }
+}
+
impl Keyring {
pub fn generate_new_rsa() -> Result<Self, Error> {
PrivateKey::generate_rsa().map(Self::with_private_key)
--
2.39.5
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
^ permalink raw reply [flat|nested] 21+ messages in thread
* [pbs-devel] [PATCH proxmox 11/19] shared-memory: specify generic types for transmute
2025-03-06 12:43 [pbs-devel] [PATCH proxmox 00/19] clippy, test and doc clean up Shannon Sterz
` (9 preceding siblings ...)
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 10/19] acme/auth-api: add `Default` for types with un-parameterized `new()` Shannon Sterz
@ 2025-03-06 12:43 ` Shannon Sterz
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 12/19] router: ignore clippy lint `missing_transmute_annotations` Shannon Sterz
` (8 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Shannon Sterz @ 2025-03-06 12:43 UTC (permalink / raw)
To: pbs-devel
this annotates a `transmute` call with proper types to avoid possible
undefined behaviour, as suggested by clippy [1].
[1]:
https://rust-lang.github.io/rust-clippy/master/index.html#missing_transmute_annotations
Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
---
proxmox-shared-memory/src/lib.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/proxmox-shared-memory/src/lib.rs b/proxmox-shared-memory/src/lib.rs
index defe678d..cffea598 100644
--- a/proxmox-shared-memory/src/lib.rs
+++ b/proxmox-shared-memory/src/lib.rs
@@ -75,7 +75,7 @@ fn mmap_file<T: Init>(file: &mut File, initialize: bool) -> Result<Mmap<T>, Erro
Err(err) => bail!("detected wrong types in mmaped files: {}", err),
}
- Ok(unsafe { std::mem::transmute(mmap) })
+ Ok(unsafe { std::mem::transmute::<Mmap<MaybeUninit<T>>, Mmap<T>>(mmap) })
}
impl<T: Sized + Init> SharedMemory<T> {
--
2.39.5
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
^ permalink raw reply [flat|nested] 21+ messages in thread
* [pbs-devel] [PATCH proxmox 12/19] router: ignore clippy lint `missing_transmute_annotations`
2025-03-06 12:43 [pbs-devel] [PATCH proxmox 00/19] clippy, test and doc clean up Shannon Sterz
` (10 preceding siblings ...)
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 11/19] shared-memory: specify generic types for transmute Shannon Sterz
@ 2025-03-06 12:43 ` Shannon Sterz
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 13/19] rest-server/router: ignore type complexity clippy lint Shannon Sterz
` (7 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Shannon Sterz @ 2025-03-06 12:43 UTC (permalink / raw)
To: pbs-devel
the `ApiHandler`'s `PartialEq` implementation makes heavy use of
`transmute`. clippy wants the types to be explicitly stated here and
not inferred, to avoid potential undefined behaviour if an unexpected
type is inferred. however, the types that would be inferred here are
so complex, that the code would become illegible anyway, so ignore
this lint for now.
[1]:
https://rust-lang.github.io/rust-clippy/master/index.html#missing_transmute_annotations
Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
---
proxmox-router/src/router.rs | 1 +
1 file changed, 1 insertion(+)
diff --git a/proxmox-router/src/router.rs b/proxmox-router/src/router.rs
index 0c4e78d4..49593508 100644
--- a/proxmox-router/src/router.rs
+++ b/proxmox-router/src/router.rs
@@ -495,6 +495,7 @@ impl Eq for ApiHandler {}
impl PartialEq for ApiHandler {
fn eq(&self, rhs: &Self) -> bool {
unsafe {
+ #[allow(clippy::missing_transmute_annotations)]
match (self, rhs) {
(ApiHandler::Sync(l), ApiHandler::Sync(r)) => {
core::mem::transmute::<_, usize>(l) == core::mem::transmute::<_, usize>(r)
--
2.39.5
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
^ permalink raw reply [flat|nested] 21+ messages in thread
* [pbs-devel] [PATCH proxmox 13/19] rest-server/router: ignore type complexity clippy lint
2025-03-06 12:43 [pbs-devel] [PATCH proxmox 00/19] clippy, test and doc clean up Shannon Sterz
` (11 preceding siblings ...)
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 12/19] router: ignore clippy lint `missing_transmute_annotations` Shannon Sterz
@ 2025-03-06 12:43 ` Shannon Sterz
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 14/19] apt: ignore clippy lint about using a slice reference instead of `&Vec` Shannon Sterz
` (6 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Shannon Sterz @ 2025-03-06 12:43 UTC (permalink / raw)
To: pbs-devel
the `type_complexity` clippy lint [1] is intended to make the code
more legible in most cases. however, the lint triggers on a member of
a private enum, an example minimal rest server and a private static
variable here. so the benefits of declaring a new type that would
encapsulate this complexity is minimal. hence, ignore the warnings for
now.
[1]:
https://rust-lang.github.io/rust-clippy/master/index.html#type_complexity
Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
---
proxmox-acme-api/src/challenge_schemas.rs | 1 +
proxmox-rest-server/examples/minimal-rest-server.rs | 1 +
proxmox-router/src/stream/parsing.rs | 1 +
3 files changed, 3 insertions(+)
diff --git a/proxmox-acme-api/src/challenge_schemas.rs b/proxmox-acme-api/src/challenge_schemas.rs
index 40a6a6af..e66e327e 100644
--- a/proxmox-acme-api/src/challenge_schemas.rs
+++ b/proxmox-acme-api/src/challenge_schemas.rs
@@ -49,6 +49,7 @@ fn load_dns_challenge_schema() -> Result<Vec<AcmeChallengeSchema>, Error> {
}
pub fn get_cached_challenge_schemas() -> Result<ChallengeSchemaWrapper, Error> {
+ #[allow(clippy::type_complexity)]
static CACHE: LazyLock<Mutex<Option<(Arc<Vec<AcmeChallengeSchema>>, SystemTime)>>> =
LazyLock::new(|| Mutex::new(None));
diff --git a/proxmox-rest-server/examples/minimal-rest-server.rs b/proxmox-rest-server/examples/minimal-rest-server.rs
index d6a5f2eb..23be586c 100644
--- a/proxmox-rest-server/examples/minimal-rest-server.rs
+++ b/proxmox-rest-server/examples/minimal-rest-server.rs
@@ -31,6 +31,7 @@ impl UserInformation for DummyUserInfo {
}
}
+#[allow(clippy::type_complexity)]
fn check_auth<'a>(
_headers: &'a HeaderMap,
_method: &'a Method,
diff --git a/proxmox-router/src/stream/parsing.rs b/proxmox-router/src/stream/parsing.rs
index 69ae1994..1726d2f8 100644
--- a/proxmox-router/src/stream/parsing.rs
+++ b/proxmox-router/src/stream/parsing.rs
@@ -60,6 +60,7 @@ where
enum RecordsInner<R: Send + Sync> {
New(R),
+ #[allow(clippy::type_complexity)]
Reading(Pin<Box<dyn Future<Output = io::Result<Option<(Vec<u8>, R)>>> + Send + Sync>>),
Done,
}
--
2.39.5
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
^ permalink raw reply [flat|nested] 21+ messages in thread
* [pbs-devel] [PATCH proxmox 14/19] apt: ignore clippy lint about using a slice reference instead of `&Vec`
2025-03-06 12:43 [pbs-devel] [PATCH proxmox 00/19] clippy, test and doc clean up Shannon Sterz
` (12 preceding siblings ...)
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 13/19] rest-server/router: ignore type complexity clippy lint Shannon Sterz
@ 2025-03-06 12:43 ` Shannon Sterz
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 15/19] apt: ignore clippy lint about new having to return `Self` Shannon Sterz
` (5 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Shannon Sterz @ 2025-03-06 12:43 UTC (permalink / raw)
To: pbs-devel
while the function would be more useful as pointed out by the clippy
lint, it i currently `pub` and users of the function would need to
adapt to the change here. so ignore the lint for now.
[1]: https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg
Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
---
proxmox-apt/src/cache.rs | 1 +
1 file changed, 1 insertion(+)
diff --git a/proxmox-apt/src/cache.rs b/proxmox-apt/src/cache.rs
index 03315013..e95250e1 100644
--- a/proxmox-apt/src/cache.rs
+++ b/proxmox-apt/src/cache.rs
@@ -291,6 +291,7 @@ where
None
}
+#[allow(clippy::ptr_arg)]
pub fn sort_package_list(packages: &mut Vec<APTUpdateInfo>) {
let cache = apt_pkg_native::Cache::get_singleton();
packages.sort_by(|left, right| {
--
2.39.5
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
^ permalink raw reply [flat|nested] 21+ messages in thread
* [pbs-devel] [PATCH proxmox 15/19] apt: ignore clippy lint about new having to return `Self`
2025-03-06 12:43 [pbs-devel] [PATCH proxmox 00/19] clippy, test and doc clean up Shannon Sterz
` (13 preceding siblings ...)
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 14/19] apt: ignore clippy lint about using a slice reference instead of `&Vec` Shannon Sterz
@ 2025-03-06 12:43 ` Shannon Sterz
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 16/19] network-api: ignore clippy lint about upper case acronyms Shannon Sterz
` (4 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Shannon Sterz @ 2025-03-06 12:43 UTC (permalink / raw)
To: pbs-devel
while this is a reasonable convention to follow, in this case the new
function is part of a public trait and changing the signature would
force all users to adapt. so ignore the lint for now [1].
[1]:
https://rust-lang.github.io/rust-clippy/master/index.html#new_ret_no_self
Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
---
proxmox-apt/src/repositories/file.rs | 1 +
1 file changed, 1 insertion(+)
diff --git a/proxmox-apt/src/repositories/file.rs b/proxmox-apt/src/repositories/file.rs
index e34e84e0..9f4beafd 100644
--- a/proxmox-apt/src/repositories/file.rs
+++ b/proxmox-apt/src/repositories/file.rs
@@ -30,6 +30,7 @@ pub trait APTRepositoryFileImpl {
/// If the file is hidden, the path points to a directory, or the extension
/// is usually ignored by APT (e.g. `.orig`), `Ok(None)` is returned, while
/// invalid file names yield an error.
+ #[allow(clippy::new_ret_no_self)]
fn new<P: AsRef<Path>>(path: P) -> Result<Option<APTRepositoryFile>, APTRepositoryFileError>;
fn with_content(content: String, content_type: APTRepositoryFileType) -> Self;
--
2.39.5
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
^ permalink raw reply [flat|nested] 21+ messages in thread
* [pbs-devel] [PATCH proxmox 16/19] network-api: ignore clippy lint about upper case acronyms
2025-03-06 12:43 [pbs-devel] [PATCH proxmox 00/19] clippy, test and doc clean up Shannon Sterz
` (14 preceding siblings ...)
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 15/19] apt: ignore clippy lint about new having to return `Self` Shannon Sterz
@ 2025-03-06 12:43 ` Shannon Sterz
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 17/19] router: fix nested doc test cases to match inteded output Shannon Sterz
` (3 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Shannon Sterz @ 2025-03-06 12:43 UTC (permalink / raw)
To: pbs-devel
while the lint is correct about how these enum members should be
capitalized, the enum is marked as `pub` and all users of it would
need to adapt. so ignore the lint for now [1].
[1]:
https://rust-lang.github.io/rust-clippy/master/index.html#upper_case_acronyms
Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
---
proxmox-network-api/src/config/lexer.rs | 1 +
1 file changed, 1 insertion(+)
diff --git a/proxmox-network-api/src/config/lexer.rs b/proxmox-network-api/src/config/lexer.rs
index 6a20f009..bc0392cf 100644
--- a/proxmox-network-api/src/config/lexer.rs
+++ b/proxmox-network-api/src/config/lexer.rs
@@ -4,6 +4,7 @@ use std::iter::Iterator;
use std::sync::LazyLock;
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
+#[allow(clippy::upper_case_acronyms)]
pub enum Token {
Text,
Comment,
--
2.39.5
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
^ permalink raw reply [flat|nested] 21+ messages in thread
* [pbs-devel] [PATCH proxmox 17/19] router: fix nested doc test cases to match inteded output
2025-03-06 12:43 [pbs-devel] [PATCH proxmox 00/19] clippy, test and doc clean up Shannon Sterz
` (15 preceding siblings ...)
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 16/19] network-api: ignore clippy lint about upper case acronyms Shannon Sterz
@ 2025-03-06 12:43 ` Shannon Sterz
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 18/19] api-macro: re-order ObjectSchema fields to be sorted Shannon Sterz
` (2 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Shannon Sterz @ 2025-03-06 12:43 UTC (permalink / raw)
To: pbs-devel
commit 68b13965 (router: docs: add horizontal line before nested
command docs) broke the nested command group test case. this commit
adapts the expected output accordingly.
Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
---
proxmox-router/tests/docs.rs | 3 +++
1 file changed, 3 insertions(+)
diff --git a/proxmox-router/tests/docs.rs b/proxmox-router/tests/docs.rs
index 0405df77..f7a89493 100644
--- a/proxmox-router/tests/docs.rs
+++ b/proxmox-router/tests/docs.rs
@@ -193,6 +193,9 @@ Optional parameters:
``--optional-arg`` ``<boolean> (default=false)``
Optional boolean argument.
+
+----
+
----
Options available for command group ``clicmd l0sub``:
--
2.39.5
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
^ permalink raw reply [flat|nested] 21+ messages in thread
* [pbs-devel] [PATCH proxmox 18/19] api-macro: re-order ObjectSchema fields to be sorted
2025-03-06 12:43 [pbs-devel] [PATCH proxmox 00/19] clippy, test and doc clean up Shannon Sterz
` (16 preceding siblings ...)
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 17/19] router: fix nested doc test cases to match inteded output Shannon Sterz
@ 2025-03-06 12:43 ` Shannon Sterz
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 19/19] tree-wide: fix intra doc links Shannon Sterz
2025-03-06 14:26 ` [pbs-devel] applied-series: [PATCH proxmox 00/19] clippy, test and doc clean up Wolfgang Bumiller
19 siblings, 0 replies; 21+ messages in thread
From: Shannon Sterz @ 2025-03-06 12:43 UTC (permalink / raw)
To: pbs-devel
this panics when running `cargo test` otherwise, as the api macro
requires fields in `ObjectSchema`s to be sorted now.
Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
---
proxmox-api-macro/src/lib.rs | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/proxmox-api-macro/src/lib.rs b/proxmox-api-macro/src/lib.rs
index bc05c74f..e4a0ea98 100644
--- a/proxmox-api-macro/src/lib.rs
+++ b/proxmox-api-macro/src/lib.rs
@@ -183,12 +183,7 @@ fn router_do(item: TokenStream) -> Result<TokenStream, Error> {
&::proxmox_schema::ObjectSchema::new(
"An example of a struct with renamed fields.",
&[
- (
- "test-string",
- false,
- &::proxmox_schema::StringSchema::new("A test string.").schema(),
- ),
- (
+ (
"SomeOther",
true,
&::proxmox_schema::StringSchema::new(
@@ -196,6 +191,12 @@ fn router_do(item: TokenStream) -> Result<TokenStream, Error> {
)
.schema(),
),
+ (
+ "test-string",
+ false,
+ &::proxmox_schema::StringSchema::new("A test string.").schema(),
+ ),
+
],
)
.schema();
--
2.39.5
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
^ permalink raw reply [flat|nested] 21+ messages in thread
* [pbs-devel] [PATCH proxmox 19/19] tree-wide: fix intra doc links
2025-03-06 12:43 [pbs-devel] [PATCH proxmox 00/19] clippy, test and doc clean up Shannon Sterz
` (17 preceding siblings ...)
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 18/19] api-macro: re-order ObjectSchema fields to be sorted Shannon Sterz
@ 2025-03-06 12:43 ` Shannon Sterz
2025-03-06 14:26 ` [pbs-devel] applied-series: [PATCH proxmox 00/19] clippy, test and doc clean up Wolfgang Bumiller
19 siblings, 0 replies; 21+ messages in thread
From: Shannon Sterz @ 2025-03-06 12:43 UTC (permalink / raw)
To: pbs-devel
this fixes intra document links or rephrases the documentation in a
more appropriate way to remove all `broken_intra_doc_links` warnings.
Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
---
proxmox-access-control/src/acl.rs | 15 +++++++--------
proxmox-acme/src/async_client.rs | 2 +-
proxmox-client/src/client.rs | 2 +-
proxmox-rest-server/src/api_config.rs | 4 ++--
proxmox-rest-server/src/worker_task.rs | 5 ++---
5 files changed, 13 insertions(+), 15 deletions(-)
diff --git a/proxmox-access-control/src/acl.rs b/proxmox-access-control/src/acl.rs
index 5a676d3d..b8041688 100644
--- a/proxmox-access-control/src/acl.rs
+++ b/proxmox-access-control/src/acl.rs
@@ -39,8 +39,7 @@ pub struct AclTree {
/// Node representing ACLs for a certain ACL path.
#[derive(Default)]
pub struct AclTreeNode {
- /// [User](pbs_api_types::User) or
- /// [Token](pbs_api_types::ApiToken) ACLs for this node.
+ /// `User` or `Token` ACLs for this node.
pub users: HashMap<Authid, HashMap<String, bool>>,
/// `Group` ACLs for this node (not yet implemented)
pub groups: HashMap<String, HashMap<String, bool>>,
@@ -60,8 +59,8 @@ impl AclTreeNode {
/// Returns applicable role and their propagation status for a given [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.
+ /// If the `Authid` is a `User` that has no specific `Roles` configured on this node,
+ /// applicable `Group` roles will be returned instead.
///
/// If `leaf` is `false`, only those roles where the propagate flag in the ACL is set to `true`
/// are returned. Otherwise, all roles will be returned.
@@ -558,14 +557,14 @@ pub fn lock_config() -> Result<ApiLockGuard, Error> {
open_api_lockfile(acl_config_lock(), None, true)
}
-/// Reads the [`AclTree`] from the [default path](ACL_CFG_FILENAME).
+/// Reads the [`AclTree`] from `acl.cfg` in the configuration directory.
pub fn config() -> Result<(AclTree, ConfigDigest), Error> {
let path = acl_config();
AclTree::load(&path)
}
-/// Returns a cached [`AclTree`] or fresh copy read directly from the [default
-/// path](ACL_CFG_FILENAME)
+/// Returns a cached [`AclTree`] or a fresh copy read directly from `acl.cfg` in the configuration
+/// directory.
///
/// Since the AclTree is used for every API request's permission check, this caching mechanism
/// allows to skip reading and parsing the file again if it is unchanged.
@@ -620,7 +619,7 @@ pub fn cached_config() -> Result<Arc<AclTree>, Error> {
Ok(config)
}
-/// Saves an [`AclTree`] to the [default path](ACL_CFG_FILENAME), ensuring proper ownership and
+/// Saves an [`AclTree`] to `acl.cfg` in the configuration directory, ensuring proper ownership and
/// file permissions.
pub fn save_config(acl: &AclTree) -> Result<(), Error> {
let mut raw: Vec<u8> = Vec::new();
diff --git a/proxmox-acme/src/async_client.rs b/proxmox-acme/src/async_client.rs
index ce5a6c79..6e38570f 100644
--- a/proxmox-acme/src/async_client.rs
+++ b/proxmox-acme/src/async_client.rs
@@ -342,7 +342,7 @@ impl AcmeClient {
/// Get the directory URL without querying the `Directory` structure.
///
- /// The difference to [`directory`](Client::directory()) is that this does not
+ /// The difference to [`directory`](AcmeClient::directory()) is that this does not
/// attempt to fetch the directory data from the ACME server.
pub fn directory_url(&self) -> &str {
&self.directory_url
diff --git a/proxmox-client/src/client.rs b/proxmox-client/src/client.rs
index a1b4eee2..6f1c9ef1 100644
--- a/proxmox-client/src/client.rs
+++ b/proxmox-client/src/client.rs
@@ -62,7 +62,7 @@ impl TlsOptions {
}
}
-/// A Proxmox API client base backed by a [`proxmox_http::Client`].
+/// A Proxmox API client base backed by a [`proxmox_http::client::Client`].
pub struct Client {
api_url: Uri,
auth: Mutex<Option<Arc<AuthenticationKind>>>,
diff --git a/proxmox-rest-server/src/api_config.rs b/proxmox-rest-server/src/api_config.rs
index 7dbcad52..b20b2da0 100644
--- a/proxmox-rest-server/src/api_config.rs
+++ b/proxmox-rest-server/src/api_config.rs
@@ -47,7 +47,7 @@ impl ApiConfig {
///
/// `get_index_fn` - callback to generate the root page
/// (index). Please note that this functions gets a reference to
- /// the [ApiConfig], so it can use [Handlebars] templates
+ /// the [ApiConfig], so it can use [handlebars::Handlebars] templates
/// ([render_template](Self::render_template) to generate pages.
pub fn new<B: Into<PathBuf>>(basedir: B, env_type: RpcEnvironmentType) -> Self {
Self {
@@ -175,7 +175,7 @@ impl ApiConfig {
self.env_type
}
- /// Register a [Handlebars] template file
+ /// Register a [handlebars::Handlebars] template file
///
/// Those templates cane be use with [render_template](Self::render_template) to generate pages.
#[cfg(feature = "templates")]
diff --git a/proxmox-rest-server/src/worker_task.rs b/proxmox-rest-server/src/worker_task.rs
index 9351bbee..6368206c 100644
--- a/proxmox-rest-server/src/worker_task.rs
+++ b/proxmox-rest-server/src/worker_task.rs
@@ -38,9 +38,8 @@ pub async fn last_worker_future() {
let _ = last_worker_listeners().subscribe().wait_for(|&v| v).await;
}
-/// This drives the [`last_worker_listener()`] futures: if a shutdown is requested and no workers
-/// and no internal tasks are running, the [`last_worker_listener()`] futures are triggered to
-/// finish.
+/// This drives the worker listener futures: if a shutdown is requested and no workers and no
+/// internal tasks are running, the last worker listener futures are triggered to finish.
pub fn check_last_worker() {
if proxmox_daemon::is_shutdown_requested()
&& WORKER_COUNT.load(Ordering::Acquire) == 0
--
2.39.5
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
^ permalink raw reply [flat|nested] 21+ messages in thread
* [pbs-devel] applied-series: [PATCH proxmox 00/19] clippy, test and doc clean up
2025-03-06 12:43 [pbs-devel] [PATCH proxmox 00/19] clippy, test and doc clean up Shannon Sterz
` (18 preceding siblings ...)
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 19/19] tree-wide: fix intra doc links Shannon Sterz
@ 2025-03-06 14:26 ` Wolfgang Bumiller
19 siblings, 0 replies; 21+ messages in thread
From: Wolfgang Bumiller @ 2025-03-06 14:26 UTC (permalink / raw)
To: Shannon Sterz; +Cc: pbs-devel
applied series, thanks
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2025-03-06 14:26 UTC | newest]
Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-06 12:43 [pbs-devel] [PATCH proxmox 00/19] clippy, test and doc clean up Shannon Sterz
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 01/19] io: clippy fix: replace `map()` followed by `any()` with just `any()` Shannon Sterz
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 02/19] tree-wide: add parantheses to clarify precedence Shannon Sterz
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 03/19] tree-wide: remove clone calls on types that are `Copy` Shannon Sterz
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 04/19] tfa: don't use block in conditions Shannon Sterz
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 05/19] tfa: remove needless `as_bytes` call Shannon Sterz
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 06/19] access-control/tfa: use `?` instead of unnecessary match statements Shannon Sterz
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 07/19] sys: add truncate option to `OpenOptions` in test case Shannon Sterz
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 08/19] router: allow `from_str` on Confirmation that is not for `FromStr` Shannon Sterz
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 09/19] auth-api/tfa: prefer `Display` over `ToString`/an inherent function Shannon Sterz
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 10/19] acme/auth-api: add `Default` for types with un-parameterized `new()` Shannon Sterz
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 11/19] shared-memory: specify generic types for transmute Shannon Sterz
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 12/19] router: ignore clippy lint `missing_transmute_annotations` Shannon Sterz
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 13/19] rest-server/router: ignore type complexity clippy lint Shannon Sterz
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 14/19] apt: ignore clippy lint about using a slice reference instead of `&Vec` Shannon Sterz
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 15/19] apt: ignore clippy lint about new having to return `Self` Shannon Sterz
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 16/19] network-api: ignore clippy lint about upper case acronyms Shannon Sterz
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 17/19] router: fix nested doc test cases to match inteded output Shannon Sterz
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 18/19] api-macro: re-order ObjectSchema fields to be sorted Shannon Sterz
2025-03-06 12:43 ` [pbs-devel] [PATCH proxmox 19/19] tree-wide: fix intra doc links Shannon Sterz
2025-03-06 14:26 ` [pbs-devel] applied-series: [PATCH proxmox 00/19] clippy, test and doc clean up 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