* [pbs-devel] [PATCH pbs 1/6] quemu_helper: run rustfmt @ 2023-06-16 7:35 Maximiliano Sandoval 2023-06-16 7:35 ` [pbs-devel] [PATCH pbs 2/6] clippy fixes: the borrowed expression implements the required traits Maximiliano Sandoval ` (5 more replies) 0 siblings, 6 replies; 8+ messages in thread From: Maximiliano Sandoval @ 2023-06-16 7:35 UTC (permalink / raw) To: pbs-devel Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com> --- proxmox-file-restore/src/qemu_helper.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/proxmox-file-restore/src/qemu_helper.rs b/proxmox-file-restore/src/qemu_helper.rs index 17784c28..6112822a 100644 --- a/proxmox-file-restore/src/qemu_helper.rs +++ b/proxmox-file-restore/src/qemu_helper.rs @@ -195,7 +195,9 @@ pub(crate) async fn hotplug_memory(cid: i32, dimm_mb: usize) -> Result<(), Error } pub fn debug_mode() -> bool { - std::env::var("PBS_QEMU_DEBUG").map(|s| !s.is_empty()).unwrap_or(false) + std::env::var("PBS_QEMU_DEBUG") + .map(|s| !s.is_empty()) + .unwrap_or(false) } pub async fn start_vm( -- 2.39.2 ^ permalink raw reply [flat|nested] 8+ messages in thread
* [pbs-devel] [PATCH pbs 2/6] clippy fixes: the borrowed expression implements the required traits 2023-06-16 7:35 [pbs-devel] [PATCH pbs 1/6] quemu_helper: run rustfmt Maximiliano Sandoval @ 2023-06-16 7:35 ` Maximiliano Sandoval 2023-06-16 7:56 ` Thomas Lamprecht 2023-06-16 7:35 ` [pbs-devel] [PATCH pbs 3/6] clippy fixes: use of ok_or followed by a function call Maximiliano Sandoval ` (4 subsequent siblings) 5 siblings, 1 reply; 8+ messages in thread From: Maximiliano Sandoval @ 2023-06-16 7:35 UTC (permalink / raw) To: pbs-devel https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com> --- src/api2/admin/datastore.rs | 2 +- src/api2/config/acme.rs | 4 ++-- src/api2/tape/restore.rs | 2 +- src/auth.rs | 2 +- src/config/mod.rs | 4 ++-- src/config/tfa.rs | 2 +- src/server/jobstate.rs | 2 +- src/tape/drive/virtual_tape.rs | 8 ++++---- src/tape/encryption_keys.rs | 2 +- src/tape/media_catalog.rs | 2 +- src/tools/disks/mod.rs | 2 +- src/tools/disks/zfs.rs | 2 +- 12 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs index 3551e2f0..a95031e7 100644 --- a/src/api2/admin/datastore.rs +++ b/src/api2/admin/datastore.rs @@ -237,7 +237,7 @@ pub fn list_groups( .to_owned(); let note_path = get_group_note_path(&datastore, &ns, group.as_ref()); - let comment = file_read_firstline(¬e_path).ok(); + let comment = file_read_firstline(note_path).ok(); group_info.push(GroupListItem { backup: group.into(), diff --git a/src/api2/config/acme.rs b/src/api2/config/acme.rs index 3ea18493..1954318b 100644 --- a/src/api2/config/acme.rs +++ b/src/api2/config/acme.rs @@ -585,7 +585,7 @@ pub fn add_plugin(r#type: String, core: DnsPluginCore, data: String) -> Result<( param_bail!("type", "invalid ACME plugin type: {:?}", r#type); } - let data = String::from_utf8(base64::decode(&data)?) + let data = String::from_utf8(base64::decode(data)?) .map_err(|_| format_err!("data must be valid UTF-8"))?; let id = core.id.clone(); @@ -695,7 +695,7 @@ pub fn update_plugin( let (mut plugins, expected_digest) = plugin::config()?; if let Some(digest) = digest { - let digest = <[u8; 32]>::from_hex(&digest)?; + let digest = <[u8; 32]>::from_hex(digest)?; crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?; } diff --git a/src/api2/tape/restore.rs b/src/api2/tape/restore.rs index 7b4fee9c..19df4a12 100644 --- a/src/api2/tape/restore.rs +++ b/src/api2/tape/restore.rs @@ -949,7 +949,7 @@ fn restore_list_worker( for (datastore, _) in store_map.used_datastores().values() { let tmp_path = media_set_tmpdir(datastore, &media_set_uuid); - match std::fs::remove_dir_all(&tmp_path) { + match std::fs::remove_dir_all(tmp_path) { Ok(()) => {} Err(err) if err.kind() == std::io::ErrorKind::NotFound => {} Err(err) => task_warn!(worker, "error cleaning up: {}", err), diff --git a/src/auth.rs b/src/auth.rs index 3c2654b9..432bdb2c 100644 --- a/src/auth.rs +++ b/src/auth.rs @@ -341,7 +341,7 @@ impl proxmox_auth_api::api::AuthContext for PbsAuthContext { if let Ok(Empty) = Ticket::parse(password).and_then(|ticket| { ticket.verify( - &self.keyring, + self.keyring, TERM_PREFIX, Some(&crate::tools::ticket::term_aad(userid, &path, port)), ) diff --git a/src/config/mod.rs b/src/config/mod.rs index e86802ab..00e42dac 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -187,9 +187,9 @@ pub(crate) fn set_proxy_certificate(cert_pem: &[u8], key_pem: &[u8]) -> Result<( let cert_path = PathBuf::from(configdir!("/proxy.pem")); create_configdir()?; - pbs_config::replace_backup_config(&key_path, key_pem) + pbs_config::replace_backup_config(key_path, key_pem) .map_err(|err| format_err!("error writing certificate private key - {}", err))?; - pbs_config::replace_backup_config(&cert_path, cert_pem) + pbs_config::replace_backup_config(cert_path, cert_pem) .map_err(|err| format_err!("error writing certificate file - {}", err))?; Ok(()) diff --git a/src/config/tfa.rs b/src/config/tfa.rs index 6b1312bb..9c322abd 100644 --- a/src/config/tfa.rs +++ b/src/config/tfa.rs @@ -280,7 +280,7 @@ impl proxmox_tfa::api::OpenUserChallengeData for UserAccess { /// `remove` user data if it exists. fn remove(&self, userid: &str) -> Result<bool, Error> { let path = challenge_data_path_str(userid); - match std::fs::remove_file(&path) { + match std::fs::remove_file(path) { Ok(()) => Ok(true), Err(err) if err.not_found() => Ok(false), Err(err) => Err(err.into()), diff --git a/src/server/jobstate.rs b/src/server/jobstate.rs index 3f0acb8c..a13d768b 100644 --- a/src/server/jobstate.rs +++ b/src/server/jobstate.rs @@ -229,7 +229,7 @@ impl Job { pub fn new(jobtype: &str, jobname: &str) -> Result<Self, Error> { let path = get_path(jobtype, jobname); - let _lock = get_lock(&path)?; + let _lock = get_lock(path)?; Ok(Self { jobtype: jobtype.to_string(), diff --git a/src/tape/drive/virtual_tape.rs b/src/tape/drive/virtual_tape.rs index d3b7b0f3..b13c58c4 100644 --- a/src/tape/drive/virtual_tape.rs +++ b/src/tape/drive/virtual_tape.rs @@ -90,7 +90,7 @@ impl VirtualTapeHandle { fn load_tape_index(&self, tape_name: &str) -> Result<TapeIndex, Error> { let path = self.tape_index_path(tape_name); - let raw = proxmox_sys::fs::file_get_contents(&path)?; + let raw = proxmox_sys::fs::file_get_contents(path)?; if raw.is_empty() { return Ok(TapeIndex { files: 0 }); } @@ -103,7 +103,7 @@ impl VirtualTapeHandle { let raw = serde_json::to_string_pretty(&serde_json::to_value(index)?)?; let options = CreateOptions::new(); - replace_file(&path, raw.as_bytes(), options, false)?; + replace_file(path, raw.as_bytes(), options, false)?; Ok(()) } @@ -131,7 +131,7 @@ impl VirtualTapeHandle { let default = serde_json::to_value(VirtualDriveStatus { current_tape: None })?; - let data = proxmox_sys::fs::file_get_json(&path, Some(default))?; + let data = proxmox_sys::fs::file_get_json(path, Some(default))?; let status: VirtualDriveStatus = serde_json::from_value(data)?; Ok(status) } @@ -141,7 +141,7 @@ impl VirtualTapeHandle { let raw = serde_json::to_string_pretty(&serde_json::to_value(status)?)?; let options = CreateOptions::new(); - replace_file(&path, raw.as_bytes(), options, false)?; + replace_file(path, raw.as_bytes(), options, false)?; Ok(()) } diff --git a/src/tape/encryption_keys.rs b/src/tape/encryption_keys.rs index f9fdccd4..bc6dee3b 100644 --- a/src/tape/encryption_keys.rs +++ b/src/tape/encryption_keys.rs @@ -38,7 +38,7 @@ mod hex_key { D: Deserializer<'de>, { let s = String::deserialize(deserializer)?; - <[u8; 32]>::from_hex(&s).map_err(serde::de::Error::custom) + <[u8; 32]>::from_hex(s).map_err(serde::de::Error::custom) } } diff --git a/src/tape/media_catalog.rs b/src/tape/media_catalog.rs index 3b182a8d..928d4701 100644 --- a/src/tape/media_catalog.rs +++ b/src/tape/media_catalog.rs @@ -254,7 +254,7 @@ impl MediaCatalog { .write(true) .create(true) .truncate(true) - .open(&tmp_path)?; + .open(tmp_path)?; if cfg!(test) { // We cannot use chown inside test environment (no permissions) diff --git a/src/tools/disks/mod.rs b/src/tools/disks/mod.rs index 31ce5acb..72e374ca 100644 --- a/src/tools/disks/mod.rs +++ b/src/tools/disks/mod.rs @@ -108,7 +108,7 @@ impl DiskManage { /// Get a `Disk` for a name in `/sys/block/<name>`. pub fn disk_by_name(self: Arc<Self>, name: &str) -> io::Result<Disk> { let syspath = format!("/sys/block/{}", name); - self.disk_by_sys_path(&syspath) + self.disk_by_sys_path(syspath) } /// Gather information about mounted disks: diff --git a/src/tools/disks/zfs.rs b/src/tools/disks/zfs.rs index 45df81d9..b12a948b 100644 --- a/src/tools/disks/zfs.rs +++ b/src/tools/disks/zfs.rs @@ -122,7 +122,7 @@ lazy_static::lazy_static! { fn parse_objset_stat(pool: &str, objset_id: &str) -> Result<(String, BlockDevStat), Error> { let path = PathBuf::from(format!("{}/{}/{}", ZFS_KSTAT_BASE_PATH, pool, objset_id)); - let text = match proxmox_sys::fs::file_read_optional_string(&path)? { + let text = match proxmox_sys::fs::file_read_optional_string(path)? { Some(text) => text, None => bail!("could not parse '{}' stat file", objset_id), }; -- 2.39.2 ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [pbs-devel] [PATCH pbs 2/6] clippy fixes: the borrowed expression implements the required traits 2023-06-16 7:35 ` [pbs-devel] [PATCH pbs 2/6] clippy fixes: the borrowed expression implements the required traits Maximiliano Sandoval @ 2023-06-16 7:56 ` Thomas Lamprecht 0 siblings, 0 replies; 8+ messages in thread From: Thomas Lamprecht @ 2023-06-16 7:56 UTC (permalink / raw) To: Proxmox Backup Server development discussion, Maximiliano Sandoval Am 16/06/2023 um 09:35 schrieb Maximiliano Sandoval: > https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow missing newline here before S-o-b line While at it, and no hard feelings here, but it could be good to have the core information of the lint here directly, I don't like to chase links, especially for minor things, and a lot go dead after a while, E.g., as quote above the link, like: > Why is this bad? > Suggests that the receiver of the expression borrows the expression. > Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com> > --- > src/api2/admin/datastore.rs | 2 +- > src/api2/config/acme.rs | 4 ++-- > src/api2/tape/restore.rs | 2 +- > src/auth.rs | 2 +- > src/config/mod.rs | 4 ++-- > src/config/tfa.rs | 2 +- > src/server/jobstate.rs | 2 +- > src/tape/drive/virtual_tape.rs | 8 ++++---- > src/tape/encryption_keys.rs | 2 +- > src/tape/media_catalog.rs | 2 +- > src/tools/disks/mod.rs | 2 +- > src/tools/disks/zfs.rs | 2 +- > 12 files changed, 17 insertions(+), 17 deletions(-) > ^ permalink raw reply [flat|nested] 8+ messages in thread
* [pbs-devel] [PATCH pbs 3/6] clippy fixes: use of ok_or followed by a function call 2023-06-16 7:35 [pbs-devel] [PATCH pbs 1/6] quemu_helper: run rustfmt Maximiliano Sandoval 2023-06-16 7:35 ` [pbs-devel] [PATCH pbs 2/6] clippy fixes: the borrowed expression implements the required traits Maximiliano Sandoval @ 2023-06-16 7:35 ` Maximiliano Sandoval 2023-06-16 7:35 ` [pbs-devel] [PATCH pbs 4/6] clippy fixes: casting to the same type is unnecessary Maximiliano Sandoval ` (3 subsequent siblings) 5 siblings, 0 replies; 8+ messages in thread From: Maximiliano Sandoval @ 2023-06-16 7:35 UTC (permalink / raw) To: pbs-devel https://rust-lang.github.io/rust-clippy/master/index.html#or_fun_call Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com> --- src/api2/node/services.rs | 4 +++- src/api2/tape/drive.rs | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/api2/node/services.rs b/src/api2/node/services.rs index 4a73b42d..2786d620 100644 --- a/src/api2/node/services.rs +++ b/src/api2/node/services.rs @@ -78,7 +78,9 @@ fn json_service_state(service: &str, status: Value) -> Value { let name = status["Name"].as_str().unwrap_or(service); let state = if status["Type"] == "oneshot" && status["SubState"] == "dead" { - status["Result"].as_str().or(status["SubState"].as_str()) + status["Result"] + .as_str() + .or_else(|| status["SubState"].as_str()) } else { status["SubState"].as_str() } diff --git a/src/api2/tape/drive.rs b/src/api2/tape/drive.rs index 020dd492..5306e605 100644 --- a/src/api2/tape/drive.rs +++ b/src/api2/tape/drive.rs @@ -652,7 +652,7 @@ pub async fn read_label(drive: String, inventorize: Option<bool>) -> Result<Medi let mut drive = open_drive(&config, &drive)?; let (media_id, _key_config) = drive.read_label()?; - let media_id = media_id.ok_or(format_err!("Media is empty (no label)."))?; + let media_id = media_id.ok_or_else(|| format_err!("Media is empty (no label)."))?; let label = if let Some(ref set) = media_id.media_set_label { let key = &set.encryption_key_fingerprint; -- 2.39.2 ^ permalink raw reply [flat|nested] 8+ messages in thread
* [pbs-devel] [PATCH pbs 4/6] clippy fixes: casting to the same type is unnecessary 2023-06-16 7:35 [pbs-devel] [PATCH pbs 1/6] quemu_helper: run rustfmt Maximiliano Sandoval 2023-06-16 7:35 ` [pbs-devel] [PATCH pbs 2/6] clippy fixes: the borrowed expression implements the required traits Maximiliano Sandoval 2023-06-16 7:35 ` [pbs-devel] [PATCH pbs 3/6] clippy fixes: use of ok_or followed by a function call Maximiliano Sandoval @ 2023-06-16 7:35 ` Maximiliano Sandoval 2023-06-16 7:35 ` [pbs-devel] [PATCH pbs 5/6] clippy fixes: Box::new(_) of default value Maximiliano Sandoval ` (2 subsequent siblings) 5 siblings, 0 replies; 8+ messages in thread From: Maximiliano Sandoval @ 2023-06-16 7:35 UTC (permalink / raw) To: pbs-devel https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com> --- src/tape/media_pool.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/tape/media_pool.rs b/src/tape/media_pool.rs index afb27cab..8f2b0add 100644 --- a/src/tape/media_pool.rs +++ b/src/tape/media_pool.rs @@ -279,9 +279,7 @@ impl MediaPool { .inventory .media_set_start_time(self.current_media_set.uuid()) { - if let Ok(Some(alloc_time)) = - event.compute_next_event(set_start_time as i64) - { + if let Ok(Some(alloc_time)) = event.compute_next_event(set_start_time) { if current_time >= alloc_time { create_new_set = Some(String::from("policy CreateAt event triggered")); -- 2.39.2 ^ permalink raw reply [flat|nested] 8+ messages in thread
* [pbs-devel] [PATCH pbs 5/6] clippy fixes: Box::new(_) of default value 2023-06-16 7:35 [pbs-devel] [PATCH pbs 1/6] quemu_helper: run rustfmt Maximiliano Sandoval ` (2 preceding siblings ...) 2023-06-16 7:35 ` [pbs-devel] [PATCH pbs 4/6] clippy fixes: casting to the same type is unnecessary Maximiliano Sandoval @ 2023-06-16 7:35 ` Maximiliano Sandoval 2023-06-16 7:35 ` [pbs-devel] [PATCH pbs 6/6] clippy fixes: deref which would be done by auto-deref Maximiliano Sandoval 2023-06-16 8:02 ` [pbs-devel] applied: [PATCH pbs 1/6] quemu_helper: run rustfmt Thomas Lamprecht 5 siblings, 0 replies; 8+ messages in thread From: Maximiliano Sandoval @ 2023-06-16 7:35 UTC (permalink / raw) To: pbs-devel https://rust-lang.github.io/rust-clippy/master/index.html#box_default Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com> --- src/acme/plugin.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/acme/plugin.rs b/src/acme/plugin.rs index 478d0666..5fe8993d 100644 --- a/src/acme/plugin.rs +++ b/src/acme/plugin.rs @@ -35,7 +35,7 @@ pub(crate) fn get_acme_plugin( } "standalone" => { // this one has no config - Box::new(StandaloneServer::default()) + Box::<StandaloneServer>::default() } other => bail!("missing implementation for plugin type '{}'", other), })) -- 2.39.2 ^ permalink raw reply [flat|nested] 8+ messages in thread
* [pbs-devel] [PATCH pbs 6/6] clippy fixes: deref which would be done by auto-deref 2023-06-16 7:35 [pbs-devel] [PATCH pbs 1/6] quemu_helper: run rustfmt Maximiliano Sandoval ` (3 preceding siblings ...) 2023-06-16 7:35 ` [pbs-devel] [PATCH pbs 5/6] clippy fixes: Box::new(_) of default value Maximiliano Sandoval @ 2023-06-16 7:35 ` Maximiliano Sandoval 2023-06-16 8:02 ` [pbs-devel] applied: [PATCH pbs 1/6] quemu_helper: run rustfmt Thomas Lamprecht 5 siblings, 0 replies; 8+ messages in thread From: Maximiliano Sandoval @ 2023-06-16 7:35 UTC (permalink / raw) To: pbs-devel https://rust-lang.github.io/rust-clippy/master/index.html#explicit_auto_deref Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com> --- src/auth.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/auth.rs b/src/auth.rs index 432bdb2c..e8d8d2da 100644 --- a/src/auth.rs +++ b/src/auth.rs @@ -266,11 +266,11 @@ pub fn setup_auth_context(use_private_key: bool) { } pub(crate) fn private_auth_keyring() -> &'static Keyring { - &*PRIVATE_KEYRING + &PRIVATE_KEYRING } pub(crate) fn public_auth_keyring() -> &'static Keyring { - &*PUBLIC_KEYRING + &PUBLIC_KEYRING } struct PbsAuthContext { -- 2.39.2 ^ permalink raw reply [flat|nested] 8+ messages in thread
* [pbs-devel] applied: [PATCH pbs 1/6] quemu_helper: run rustfmt 2023-06-16 7:35 [pbs-devel] [PATCH pbs 1/6] quemu_helper: run rustfmt Maximiliano Sandoval ` (4 preceding siblings ...) 2023-06-16 7:35 ` [pbs-devel] [PATCH pbs 6/6] clippy fixes: deref which would be done by auto-deref Maximiliano Sandoval @ 2023-06-16 8:02 ` Thomas Lamprecht 5 siblings, 0 replies; 8+ messages in thread From: Thomas Lamprecht @ 2023-06-16 8:02 UTC (permalink / raw) To: Proxmox Backup Server development discussion, Maximiliano Sandoval Am 16/06/2023 um 09:35 schrieb Maximiliano Sandoval: > Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com> > --- > proxmox-file-restore/src/qemu_helper.rs | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > applied, thanks! I fixed the typo in the commit subject on applying, and added the "file restore" sub-crate as prefix: file restore: qemu helper: run rustfmt ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2023-06-16 8:02 UTC | newest] Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-06-16 7:35 [pbs-devel] [PATCH pbs 1/6] quemu_helper: run rustfmt Maximiliano Sandoval 2023-06-16 7:35 ` [pbs-devel] [PATCH pbs 2/6] clippy fixes: the borrowed expression implements the required traits Maximiliano Sandoval 2023-06-16 7:56 ` Thomas Lamprecht 2023-06-16 7:35 ` [pbs-devel] [PATCH pbs 3/6] clippy fixes: use of ok_or followed by a function call Maximiliano Sandoval 2023-06-16 7:35 ` [pbs-devel] [PATCH pbs 4/6] clippy fixes: casting to the same type is unnecessary Maximiliano Sandoval 2023-06-16 7:35 ` [pbs-devel] [PATCH pbs 5/6] clippy fixes: Box::new(_) of default value Maximiliano Sandoval 2023-06-16 7:35 ` [pbs-devel] [PATCH pbs 6/6] clippy fixes: deref which would be done by auto-deref Maximiliano Sandoval 2023-06-16 8:02 ` [pbs-devel] applied: [PATCH pbs 1/6] quemu_helper: run rustfmt Thomas Lamprecht
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox