From 8c3557e9d1af753308743aceb2449ea114ba6c0f Mon Sep 17 00:00:00 2001 From: Frederick Zhang Date: Mon, 29 Dec 2025 16:10:44 +1100 Subject: [PATCH 1/2] style: Fix mismatched_lifetime_syntaxes [1] https://doc.rust-lang.org/beta/nightly-rustc/rustc_lint/lifetime_syntax/static.MISMATCHED_LIFETIME_SYNTAXES.html --- src/config.rs | 6 +++--- src/keepassxc/messages/structs.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/config.rs b/src/config.rs index c8b7cf8..8d329a1 100644 --- a/src/config.rs +++ b/src/config.rs @@ -435,13 +435,13 @@ impl Config { } #[cfg(not(feature = "encryption"))] - pub fn get_encryption_key(&self) -> Result>> { + pub fn get_encryption_key(&self) -> Result>> { error!("Enable encryption to use this feature"); Err(anyhow!("Encryption is not enabled in this build")) } #[cfg(feature = "encryption")] - pub fn get_encryption_key(&self) -> Result>> { + pub fn get_encryption_key(&self) -> Result>> { if self.encryption_key.borrow().is_some() { return Ok(self.encryption_key.borrow()); } @@ -631,7 +631,7 @@ impl Encryption { } #[cfg(feature = "encryption")] - fn get_response(&self) -> Result>> { + fn get_response(&self) -> Result>> { match self { #[cfg(not(feature = "yubikey"))] Encryption::ChallengeResponse { .. } => { diff --git a/src/keepassxc/messages/structs.rs b/src/keepassxc/messages/structs.rs index 35f66d9..fb77691 100644 --- a/src/keepassxc/messages/structs.rs +++ b/src/keepassxc/messages/structs.rs @@ -608,7 +608,7 @@ impl GetDatabaseGroupsResponse { &self.groups.groups } - pub fn get_flat_groups(&self) -> Vec { + pub fn get_flat_groups(&self) -> Vec> { self.get_groups() .iter() .map(|g| g.get_flat_groups(vec![])) From 66de8a98e62e032da5336c2e97e15a4016e46c31 Mon Sep 17 00:00:00 2001 From: Frederick Zhang Date: Mon, 29 Dec 2025 16:16:05 +1100 Subject: [PATCH 2/2] style: Fix unnecessary_unwrap [1] https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#unnecessary_unwrap --- src/keepassxc/messages/structs.rs | 19 ++++++++----------- src/utils/callers.rs | 7 ++----- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/src/keepassxc/messages/structs.rs b/src/keepassxc/messages/structs.rs index fb77691..c7ae9f8 100644 --- a/src/keepassxc/messages/structs.rs +++ b/src/keepassxc/messages/structs.rs @@ -74,20 +74,17 @@ where ); }; response_wrapper.log(); - if response_wrapper.message.is_some() && response_wrapper.nonce.is_some() { - let (message, nonce) = ( - response_wrapper.message.unwrap(), - response_wrapper.nonce.unwrap(), - ); - let decrypted_response_json = to_decrypted_json(message, nonce)?; - let response: R = serde_json::from_str(&decrypted_response_json)?; - Ok((response, decrypted_response_json)) - } else { - Err(KeePassError { + match (&response_wrapper.message, &response_wrapper.nonce) { + (Some(message), Some(nonce)) => { + let decrypted_response_json = to_decrypted_json(message, nonce)?; + let response: R = serde_json::from_str(&decrypted_response_json)?; + Ok((response, decrypted_response_json)) + } + _ => Err(KeePassError { message: response_wrapper.error_message(), response: response_wrapper, } - .into()) + .into()), } } diff --git a/src/utils/callers.rs b/src/utils/callers.rs index 0228366..7c3abbc 100644 --- a/src/utils/callers.rs +++ b/src/utils/callers.rs @@ -52,11 +52,8 @@ impl CurrentCaller { .ok_or_else(|| anyhow!("Failed to determine parent process path"))?; info!("Parent process path: {}", ppath.to_string_lossy()); let canonical_ppath = ppath.canonicalize(); - if canonical_ppath.is_ok() { - info!( - "Canonical parent process path: {}", - canonical_ppath.as_ref().unwrap().to_string_lossy() - ); + if let Ok(p) = &canonical_ppath { + info!("Canonical parent process path: {}", p.to_string_lossy()); } else { warn!("Failed to determine canonical parent process path"); }