* [pbs-devel] [PATCH proxmox 2/6] remove needless_borrow
2024-02-28 11:39 [pbs-devel] [PATCH proxmox 1/6] acme: Default `impl` can be derived Maximiliano Sandoval
@ 2024-02-28 11:39 ` Maximiliano Sandoval
2024-02-28 11:39 ` [pbs-devel] [PATCH proxmox 3/6] io: remove unnecesary cast to *mut u8 Maximiliano Sandoval
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Maximiliano Sandoval @ 2024-02-28 11:39 UTC (permalink / raw)
To: pbs-devel
Fixes the clippy lint
warning: this expression creates a reference which is immediately dereferenced by the compiler
--> proxmox-api-macro/src/util.rs:868:25
|
868 | duplicate(&*target, &path);
| ^^^^^ help: change this to: `path`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
= note: `#[warn(clippy::needless_borrow)]` on by default
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
proxmox-api-macro/src/util.rs | 2 +-
proxmox-rest-server/src/worker_task.rs | 2 +-
proxmox-schema/src/de/no_schema.rs | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/proxmox-api-macro/src/util.rs b/proxmox-api-macro/src/util.rs
index 324c460d..428b1e4d 100644
--- a/proxmox-api-macro/src/util.rs
+++ b/proxmox-api-macro/src/util.rs
@@ -865,7 +865,7 @@ pub fn parse_str_value_to_option<T: Parse>(
path: &syn::Path,
nv: syn::parse::ParseStream<'_>,
) {
- duplicate(&*target, &path);
+ duplicate(&*target, path);
match nv.parse().and_then(|lit| parse_lit_str(&lit)) {
Ok(value) => *target = Some(value),
Err(err) => crate::add_error(err),
diff --git a/proxmox-rest-server/src/worker_task.rs b/proxmox-rest-server/src/worker_task.rs
index 4cf24cc4..5bab4cdc 100644
--- a/proxmox-rest-server/src/worker_task.rs
+++ b/proxmox-rest-server/src/worker_task.rs
@@ -850,7 +850,7 @@ impl WorkerTask {
file_opts: setup.file_opts.clone(),
..Default::default()
};
- let logger = FileLogger::new(&path, logger_options)?;
+ let logger = FileLogger::new(path, logger_options)?;
let worker = Arc::new(Self {
setup,
diff --git a/proxmox-schema/src/de/no_schema.rs b/proxmox-schema/src/de/no_schema.rs
index 546e5001..45fe08cd 100644
--- a/proxmox-schema/src/de/no_schema.rs
+++ b/proxmox-schema/src/de/no_schema.rs
@@ -303,7 +303,7 @@ impl<'a> Iterator for SplitList<'a> {
type Item = &'a str;
fn next(&mut self) -> Option<&'a str> {
- let range = super::next_str_entry(&self.input, &mut self.at, self.has_null)?;
+ let range = super::next_str_entry(self.input, &mut self.at, self.has_null)?;
Some(&self.input[range])
}
}
--
2.39.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* [pbs-devel] [PATCH proxmox 3/6] io: remove unnecesary cast to *mut u8
2024-02-28 11:39 [pbs-devel] [PATCH proxmox 1/6] acme: Default `impl` can be derived Maximiliano Sandoval
2024-02-28 11:39 ` [pbs-devel] [PATCH proxmox 2/6] remove needless_borrow Maximiliano Sandoval
@ 2024-02-28 11:39 ` Maximiliano Sandoval
2024-02-28 11:39 ` [pbs-devel] [PATCH proxmox 4/6] schema: de: don't use while where we don't loop Maximiliano Sandoval
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Maximiliano Sandoval @ 2024-02-28 11:39 UTC (permalink / raw)
To: pbs-devel
Fixes the clippy lint:
warning: casting raw pointers to the same type and constness is unnecessary (`*mut u8` -> `*mut u8`)
--> proxmox-io/src/vec/mod.rs:57:29
|
57 | Vec::from_raw_parts(data as *mut u8, len, len)
| ^^^^^^^^^^^^^^^ help: try: `data`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast
= note: `#[warn(clippy::unnecessary_cast)]` on by default
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
proxmox-io/src/vec/mod.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/proxmox-io/src/vec/mod.rs b/proxmox-io/src/vec/mod.rs
index 8798025d..16d3a32e 100644
--- a/proxmox-io/src/vec/mod.rs
+++ b/proxmox-io/src/vec/mod.rs
@@ -54,7 +54,7 @@ pub use byte_vec::ByteVecExt;
pub unsafe fn uninitialized(len: usize) -> Vec<u8> {
unsafe {
let data = std::alloc::alloc(std::alloc::Layout::array::<u8>(len).unwrap());
- Vec::from_raw_parts(data as *mut u8, len, len)
+ Vec::from_raw_parts(data, len, len)
}
}
--
2.39.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* [pbs-devel] [PATCH proxmox 4/6] schema: de: don't use while where we don't loop
2024-02-28 11:39 [pbs-devel] [PATCH proxmox 1/6] acme: Default `impl` can be derived Maximiliano Sandoval
2024-02-28 11:39 ` [pbs-devel] [PATCH proxmox 2/6] remove needless_borrow Maximiliano Sandoval
2024-02-28 11:39 ` [pbs-devel] [PATCH proxmox 3/6] io: remove unnecesary cast to *mut u8 Maximiliano Sandoval
@ 2024-02-28 11:39 ` Maximiliano Sandoval
2024-02-28 11:39 ` [pbs-devel] [PATCH proxmox 5/6] rest: do not convert string to string Maximiliano Sandoval
2024-02-28 11:39 ` [pbs-devel] [PATCH proxmox 6/6] rrd: use unwrap_or_default when possible Maximiliano Sandoval
4 siblings, 0 replies; 6+ messages in thread
From: Maximiliano Sandoval @ 2024-02-28 11:39 UTC (permalink / raw)
To: pbs-devel
This code does not loop if-let is the correct pattern.
Fixes the clippy error:
error: this loop never actually loops
--> proxmox-schema/src/de/mod.rs:424:9
|
424 | / while let Some(el_range) = next_str_entry(&self.input, &mut self.at, self.has_null) {
425 | | if let Some(max) = self.schema.max_length {
426 | | if self.count == max {
427 | | return Err(Error::msg("too many elements"));
... |
438 | | .map(Some);
439 | | }
| |_________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#never_loop
= note: `#[deny(clippy::never_loop)]` on by default
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
proxmox-schema/src/de/mod.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/proxmox-schema/src/de/mod.rs b/proxmox-schema/src/de/mod.rs
index 75b500e5..09ccfeb3 100644
--- a/proxmox-schema/src/de/mod.rs
+++ b/proxmox-schema/src/de/mod.rs
@@ -421,7 +421,7 @@ impl<'de, 'i, 's> de::SeqAccess<'de> for SeqAccess<'de, 'i, 's> {
return Ok(None);
}
- while let Some(el_range) = next_str_entry(&self.input, &mut self.at, self.has_null) {
+ if let Some(el_range) = next_str_entry(&self.input, &mut self.at, self.has_null) {
if let Some(max) = self.schema.max_length {
if self.count == max {
return Err(Error::msg("too many elements"));
--
2.39.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* [pbs-devel] [PATCH proxmox 5/6] rest: do not convert string to string
2024-02-28 11:39 [pbs-devel] [PATCH proxmox 1/6] acme: Default `impl` can be derived Maximiliano Sandoval
` (2 preceding siblings ...)
2024-02-28 11:39 ` [pbs-devel] [PATCH proxmox 4/6] schema: de: don't use while where we don't loop Maximiliano Sandoval
@ 2024-02-28 11:39 ` Maximiliano Sandoval
2024-02-28 11:39 ` [pbs-devel] [PATCH proxmox 6/6] rrd: use unwrap_or_default when possible Maximiliano Sandoval
4 siblings, 0 replies; 6+ messages in thread
From: Maximiliano Sandoval @ 2024-02-28 11:39 UTC (permalink / raw)
To: pbs-devel
Fixes the clippy warning:
warning: useless conversion to the same type: `std::string::String`
--> proxmox-rest-server/src/rest.rs:158:41
|
158 | .header("Location", String::from(location_value))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `String::from()`: `location_value`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion
= note: `#[warn(clippy::useless_conversion)]` on by default
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
proxmox-rest-server/src/rest.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/proxmox-rest-server/src/rest.rs b/proxmox-rest-server/src/rest.rs
index 4900592d..39ae9a18 100644
--- a/proxmox-rest-server/src/rest.rs
+++ b/proxmox-rest-server/src/rest.rs
@@ -155,7 +155,7 @@ impl Service<Request<Body>> for RedirectService {
Response::builder()
.status(status_code)
- .header("Location", String::from(location_value))
+ .header("Location", location_value)
.body(Body::empty())?
} else {
Response::builder()
--
2.39.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* [pbs-devel] [PATCH proxmox 6/6] rrd: use unwrap_or_default when possible
2024-02-28 11:39 [pbs-devel] [PATCH proxmox 1/6] acme: Default `impl` can be derived Maximiliano Sandoval
` (3 preceding siblings ...)
2024-02-28 11:39 ` [pbs-devel] [PATCH proxmox 5/6] rest: do not convert string to string Maximiliano Sandoval
@ 2024-02-28 11:39 ` Maximiliano Sandoval
4 siblings, 0 replies; 6+ messages in thread
From: Maximiliano Sandoval @ 2024-02-28 11:39 UTC (permalink / raw)
To: pbs-devel
Fixes the Clippy warnings:
warning: use of `unwrap_or_else` to construct default value
--> proxmox-rrd/src/cache.rs:65:41
|
65 | let file_options = file_options.unwrap_or_else(CreateOptions::new);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_or_default
= note: `#[warn(clippy::unwrap_or_default)]` on by default
warning: use of `unwrap_or_else` to construct default value
--> proxmox-rrd/src/cache.rs:66:39
|
66 | let dir_options = dir_options.unwrap_or_else(CreateOptions::new);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_or_default
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
proxmox-rrd/src/cache.rs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/proxmox-rrd/src/cache.rs b/proxmox-rrd/src/cache.rs
index e3d2f8d5..5b123a6b 100644
--- a/proxmox-rrd/src/cache.rs
+++ b/proxmox-rrd/src/cache.rs
@@ -62,8 +62,8 @@ impl Cache {
) -> Result<Self, Error> {
let basedir = basedir.as_ref().to_owned();
- let file_options = file_options.unwrap_or_else(CreateOptions::new);
- let dir_options = dir_options.unwrap_or_else(CreateOptions::new);
+ let file_options = file_options.unwrap_or_default();
+ let dir_options = dir_options.unwrap_or_default();
create_path(
&basedir,
--
2.39.2
^ permalink raw reply [flat|nested] 6+ messages in thread