From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 1D5B21FF136 for ; Mon, 26 Jan 2026 16:14:06 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 4842E11501; Mon, 26 Jan 2026 16:14:29 +0100 (CET) From: Maximiliano Sandoval To: pbs-devel@lists.proxmox.com Date: Mon, 26 Jan 2026 16:13:43 +0100 Message-ID: <20260126151349.627829-7-m.sandoval@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260126151349.627829-1-m.sandoval@proxmox.com> References: <20260126151349.627829-1-m.sandoval@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1769440366715 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.912 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment KAM_MAILER 2 Automated Mailer Tag Left in Email SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pbs-devel] [PATCH proxmox 06/10] cargo: run --fix X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Backup Server development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" It mostly fixes the lippy::collapsible_if lint. Signed-off-by: Maximiliano Sandoval --- pbs-api-types/src/maintenance.rs | 5 ++-- proxmox-api-macro/src/api/enums.rs | 5 ++-- proxmox-api-macro/src/api/method.rs | 21 ++++++-------- proxmox-api-macro/src/serde.rs | 5 ++-- proxmox-api-macro/src/util.rs | 28 ++++++++----------- proxmox-apt/src/cache.rs | 5 ++-- proxmox-apt/src/cache_api.rs | 5 ++-- proxmox-apt/src/deb822/release_file.rs | 5 ++-- proxmox-apt/src/repositories/file.rs | 5 ++-- .../src/repositories/file/list_parser.rs | 5 ++-- proxmox-apt/src/repositories/repository.rs | 5 ++-- proxmox-config-digest/src/lib.rs | 5 ++-- proxmox-ldap/src/sync.rs | 5 ++-- proxmox-rrd/src/cache/journal.rs | 11 +++----- proxmox-section-config/src/lib.rs | 5 ++-- proxmox-section-config/src/typed.rs | 5 ++-- proxmox-tfa/src/api/mod.rs | 14 ++++------ proxmox-tfa/src/api/webauthn.rs | 5 ++-- pve-api-types/src/types/array.rs | 5 ++-- pve-api-types/src/types/verifiers.rs | 9 +++--- 20 files changed, 62 insertions(+), 96 deletions(-) diff --git a/pbs-api-types/src/maintenance.rs b/pbs-api-types/src/maintenance.rs index 6b97ff10..404d2c32 100644 --- a/pbs-api-types/src/maintenance.rs +++ b/pbs-api-types/src/maintenance.rs @@ -110,11 +110,10 @@ impl MaintenanceMode { bail!("offline maintenance mode: {}", message); } else if self.ty == MaintenanceType::S3Refresh { bail!("S3 refresh maintenance mode: {}", message); - } else if self.ty == MaintenanceType::ReadOnly { - if let Some(Operation::Write) = operation { + } else if self.ty == MaintenanceType::ReadOnly + && let Some(Operation::Write) = operation { bail!("read-only maintenance mode: {}", message); } - } Ok(()) } } diff --git a/proxmox-api-macro/src/api/enums.rs b/proxmox-api-macro/src/api/enums.rs index ae5c05e1..378e7f05 100644 --- a/proxmox-api-macro/src/api/enums.rs +++ b/proxmox-api-macro/src/api/enums.rs @@ -137,8 +137,8 @@ fn handle_string_enum( syn::LitStr::new(&name.to_string(), name.span()) }; - if derives_default { - if let Some(attr) = variant.attrs.iter().find(|a| a.path().is_ident("default")) { + if derives_default + && let Some(attr) = variant.attrs.iter().find(|a| a.path().is_ident("default")) { if let Some(default_value) = &default_value { error!(attr => "multiple default values defined"); error!(default_value => "default previously defined here"); @@ -150,7 +150,6 @@ fn handle_string_enum( } } } - } variants.extend(quote_spanned! { variant.ident.span() => ::proxmox_schema::EnumEntry { diff --git a/proxmox-api-macro/src/api/method.rs b/proxmox-api-macro/src/api/method.rs index ab0801aa..c55a21d4 100644 --- a/proxmox-api-macro/src/api/method.rs +++ b/proxmox-api-macro/src/api/method.rs @@ -493,8 +493,8 @@ fn handle_function_signature(method_info: &mut MethodInfo) -> Result bool { - if let syn::Type::Reference(r) = ty { - if let syn::Type::Path(p) = &*r.elem { + if let syn::Type::Reference(r) = ty + && let syn::Type::Path(p) = &*r.elem { if p.qself.is_some() { return false; } @@ -502,20 +502,16 @@ fn is_api_method_type(ty: &syn::Type) -> bool { return ps.ident == "ApiMethod"; } } - } false } fn is_rpc_env_type(ty: &syn::Type) -> bool { - if let syn::Type::Reference(r) = ty { - if let syn::Type::TraitObject(t) = &*r.elem { - if let Some(syn::TypeParamBound::Trait(b)) = t.bounds.first() { - if let Some(ps) = b.path.segments.last() { + if let syn::Type::Reference(r) = ty + && let syn::Type::TraitObject(t) = &*r.elem + && let Some(syn::TypeParamBound::Trait(b)) = t.bounds.first() + && let Some(ps) = b.path.segments.last() { return ps.ident == "RpcEnvironment"; } - } - } - } false } @@ -945,8 +941,8 @@ struct DefaultParameters<'a>(&'a Schema); impl VisitMut for DefaultParameters<'_> { fn visit_expr_mut(&mut self, i: &mut syn::Expr) { - if let syn::Expr::Macro(exprmac) = i { - if exprmac.mac.path.is_ident("api_get_default") { + if let syn::Expr::Macro(exprmac) = i + && exprmac.mac.path.is_ident("api_get_default") { // replace api_get_default macros with the actual default found in the #[api] // macro. match self.get_default(mem::take(&mut exprmac.mac.tokens)) { @@ -957,7 +953,6 @@ impl VisitMut for DefaultParameters<'_> { } } } - } visit_mut::visit_expr_mut(self, i) } diff --git a/proxmox-api-macro/src/serde.rs b/proxmox-api-macro/src/serde.rs index 0412b945..52dd8fed 100644 --- a/proxmox-api-macro/src/serde.rs +++ b/proxmox-api-macro/src/serde.rs @@ -229,11 +229,10 @@ impl FieldAttrib { } pub fn check_non_option_type(&self) { - if let Some(span) = self.has_skip_serializing_if { - if !self.has_default { + if let Some(span) = self.has_skip_serializing_if + && !self.has_default { error!(span, "`skip_serializing_if` without `default`"); } - } } } diff --git a/proxmox-api-macro/src/util.rs b/proxmox-api-macro/src/util.rs index 9ed3fa0b..042684ff 100644 --- a/proxmox-api-macro/src/util.rs +++ b/proxmox-api-macro/src/util.rs @@ -434,19 +434,17 @@ pub fn derive_descriptions( let mut parts = doc_comment.split("\nReturns:"); - if let Some(first) = parts.next() { - if input_schema.description.is_none() { + if let Some(first) = parts.next() + && input_schema.description.is_none() { input_schema.description = Maybe::Derived(syn::LitStr::new(first.trim(), doc_span)); } - } if let Some(second) = parts.next() { - if let Some(returns_schema) = returns_schema { - if returns_schema.description.is_none() { + if let Some(returns_schema) = returns_schema + && returns_schema.description.is_none() { returns_schema.description = Maybe::Derived(syn::LitStr::new(second.trim(), doc_span)); } - } if parts.next().is_some() { bail!( @@ -519,13 +517,11 @@ pub fn is_option_type(ty: &syn::Type) -> Option<&syn::Type> { return None; } - if let syn::PathArguments::AngleBracketed(generic) = &segs.last().unwrap().arguments { - if generic.args.len() == 1 { - if let syn::GenericArgument::Type(ty) = generic.args.first().unwrap() { + if let syn::PathArguments::AngleBracketed(generic) = &segs.last().unwrap().arguments + && generic.args.len() == 1 + && let syn::GenericArgument::Type(ty) = generic.args.first().unwrap() { return Some(ty); } - } - } } None } @@ -747,20 +743,18 @@ where for arg in std::mem::take(&mut args).into_pairs() { match arg { Pair::Punctuated(item, punct) => { - if let syn::Meta::Path(path) = &item { - if !func(path) { + if let syn::Meta::Path(path) = &item + && !func(path) { continue; } - } args.push_value(item); args.push_punct(punct); } Pair::End(item) => { - if let syn::Meta::Path(path) = &item { - if !func(path) { + if let syn::Meta::Path(path) = &item + && !func(path) { continue; } - } args.push_value(item); } } diff --git a/proxmox-apt/src/cache.rs b/proxmox-apt/src/cache.rs index bd8d6c89..bd12eb22 100644 --- a/proxmox-apt/src/cache.rs +++ b/proxmox-apt/src/cache.rs @@ -247,11 +247,10 @@ where // versions anyway let mut pkg_iter = origin.file(); let pkg_file = pkg_iter.next(); - if let Some(pkg_file) = pkg_file { - if let Some(origin_name) = pkg_file.origin() { + if let Some(pkg_file) = pkg_file + && let Some(origin_name) = pkg_file.origin() { origin_res = origin_name; } - } } if let Some(depends) = depends { diff --git a/proxmox-apt/src/cache_api.rs b/proxmox-apt/src/cache_api.rs index 0c55fbc9..d2c7dbfc 100644 --- a/proxmox-apt/src/cache_api.rs +++ b/proxmox-apt/src/cache_api.rs @@ -13,11 +13,10 @@ pub fn list_available_apt_update>( apt_state_file: P, ) -> Result, Error> { let apt_state_file = apt_state_file.as_ref(); - if let Ok(false) = crate::cache::pkg_cache_expired(apt_state_file) { - if let Ok(Some(cache)) = crate::cache::read_pkg_state(apt_state_file) { + if let Ok(false) = crate::cache::pkg_cache_expired(apt_state_file) + && let Ok(Some(cache)) = crate::cache::read_pkg_state(apt_state_file) { return Ok(cache.package_status); } - } let cache = crate::cache::update_cache(apt_state_file)?; diff --git a/proxmox-apt/src/deb822/release_file.rs b/proxmox-apt/src/deb822/release_file.rs index d7b6009c..e5e9ed74 100644 --- a/proxmox-apt/src/deb822/release_file.rs +++ b/proxmox-apt/src/deb822/release_file.rs @@ -150,12 +150,11 @@ impl FileReferenceType { } "debian-installer" => { // another layer, then like regular repo but pointing at udebs - if let Some((dir, rest)) = rest.split_once('/') { - if let Some(arch) = dir.strip_prefix("binary-") { + if let Some((dir, rest)) = rest.split_once('/') + && let Some(arch) = dir.strip_prefix("binary-") { // Packages or compat-Release return parse_binary_dir(rest, arch); } - } // all the rest Ok(FileReferenceType::Unknown) diff --git a/proxmox-apt/src/repositories/file.rs b/proxmox-apt/src/repositories/file.rs index 1c8afce7..abf9e55e 100644 --- a/proxmox-apt/src/repositories/file.rs +++ b/proxmox-apt/src/repositories/file.rs @@ -350,14 +350,13 @@ impl APTRepositoryFileImpl for APTRepositoryFile { add_info("warning", message_new(base_suite)); } - if let Some(require_suffix) = require_suffix { - if suffix != require_suffix { + if let Some(require_suffix) = require_suffix + && suffix != require_suffix { add_info( "warning", format!("expected suite '{current_codename}{require_suffix}'"), ); } - } } } diff --git a/proxmox-apt/src/repositories/file/list_parser.rs b/proxmox-apt/src/repositories/file/list_parser.rs index 6eb57157..b800473c 100644 --- a/proxmox-apt/src/repositories/file/list_parser.rs +++ b/proxmox-apt/src/repositories/file/list_parser.rs @@ -165,12 +165,11 @@ impl APTListFileParser { line = line.trim_matches(|c| char::is_ascii_whitespace(&c)); // check for commented out repository first - if let Some(commented_out) = line.strip_prefix('#') { - if let Ok(Some(mut repo)) = self.parse_one_line(commented_out) { + if let Some(commented_out) = line.strip_prefix('#') + && let Ok(Some(mut repo)) = self.parse_one_line(commented_out) { repo.set_enabled(false); return Ok(Some(repo)); } - } let mut repo = APTRepository::new(APTRepositoryFileType::List); diff --git a/proxmox-apt/src/repositories/repository.rs b/proxmox-apt/src/repositories/repository.rs index 24e7943b..4ec1c4e7 100644 --- a/proxmox-apt/src/repositories/repository.rs +++ b/proxmox-apt/src/repositories/repository.rs @@ -224,11 +224,10 @@ fn uri_to_filename(uri: &str) -> String { filename = &filename[(begin + 3)..]; } - if uri.starts_with("http://") || uri.starts_with("https://") { - if let Some(begin) = filename.find('@') { + if (uri.starts_with("http://") || uri.starts_with("https://")) + && let Some(begin) = filename.find('@') { filename = &filename[(begin + 1)..]; } - } // APT seems to only strip one final slash, so do the same filename = filename.strip_suffix('/').unwrap_or(filename); diff --git a/proxmox-config-digest/src/lib.rs b/proxmox-config-digest/src/lib.rs index a34a3a90..993e31cc 100644 --- a/proxmox-config-digest/src/lib.rs +++ b/proxmox-config-digest/src/lib.rs @@ -41,11 +41,10 @@ impl ConfigDigest { /// /// This function fails with a reasonable error message if checksums do not match. pub fn detect_modification(&self, user_digest: Option<&Self>) -> Result<(), Error> { - if let Some(user_digest) = user_digest { - if user_digest != self { + if let Some(user_digest) = user_digest + && user_digest != self { bail!("detected modified configuration - file changed by other user? Try again."); } - } Ok(()) } } diff --git a/proxmox-ldap/src/sync.rs b/proxmox-ldap/src/sync.rs index f0d43e14..87841ec3 100644 --- a/proxmox-ldap/src/sync.rs +++ b/proxmox-ldap/src/sync.rs @@ -339,13 +339,12 @@ impl LdapRealmSyncJob { user_config.sections.remove(&tokenid_string); - if !self.dry_run { - if let Err(e) = + if !self.dry_run + && let Err(e) = proxmox_access_control::token_shadow::delete_secret(&tokenid) { log::warn!("could not delete token for user {userid}: {e}",) } - } if self.general_sync_settings.should_remove_acls() { acl_config.delete_authid(&tokenid); diff --git a/proxmox-rrd/src/cache/journal.rs b/proxmox-rrd/src/cache/journal.rs index 0753d015..a78d06ee 100644 --- a/proxmox-rrd/src/cache/journal.rs +++ b/proxmox-rrd/src/cache/journal.rs @@ -170,19 +170,16 @@ impl JournalState { Some(_) => (), } - if let Some(extension) = path.extension() { - if let Some(extension) = extension.to_str() { - if let Some(rest) = extension.strip_prefix("journal-") { - if let Ok(time) = u64::from_str_radix(rest, 16) { + if let Some(extension) = path.extension() + && let Some(extension) = extension.to_str() + && let Some(rest) = extension.strip_prefix("journal-") + && let Ok(time) = u64::from_str_radix(rest, 16) { list.push(JournalFileInfo { time, name: format!("rrd.{extension}"), path: path.to_owned(), }); } - } - } - } } list.sort_unstable_by_key(|entry| entry.time); Ok(list) diff --git a/proxmox-section-config/src/lib.rs b/proxmox-section-config/src/lib.rs index 2222fbf1..3fca933d 100644 --- a/proxmox-section-config/src/lib.rs +++ b/proxmox-section-config/src/lib.rs @@ -433,12 +433,11 @@ impl SectionConfig { id_property: &Option| -> Result<(), Error> { for (name, optional, _prop_schema) in schema.properties() { - if let Some(id_property) = id_property { - if name == id_property { + if let Some(id_property) = id_property + && name == id_property { // the id_property is the section header, skip for requirement check continue; } - } if !*optional && value[name] == Value::Null { return Err(format_err!( "property '{}' is missing and it is not optional.", diff --git a/proxmox-section-config/src/typed.rs b/proxmox-section-config/src/typed.rs index 5250fd86..b06d290e 100644 --- a/proxmox-section-config/src/typed.rs +++ b/proxmox-section-config/src/typed.rs @@ -215,11 +215,10 @@ impl SectionConfigData { { let removed_value = self.sections.remove(key); // only update the order vector if we actually removed something - if removed_value.is_some() { - if let Some(pos) = self.order.iter().position(|k| k.borrow() == key) { + if removed_value.is_some() + && let Some(pos) = self.order.iter().position(|k| k.borrow() == key) { self.order.remove(pos); } - } removed_value } } diff --git a/proxmox-tfa/src/api/mod.rs b/proxmox-tfa/src/api/mod.rs index 5d1386fa..5b2841be 100644 --- a/proxmox-tfa/src/api/mod.rs +++ b/proxmox-tfa/src/api/mod.rs @@ -434,11 +434,10 @@ impl TfaConfig { save = true; } - if save { - if let Err(err) = data.save() { + if save + && let Err(err) = data.save() { log::error!("failed to store user challenge data: {err}"); } - } r } Ok(r) => r, @@ -993,8 +992,7 @@ impl TfaUserData { if let Some(entry) = self .enabled_u2f_entries() .find(|e| e.key.key_handle == response.key_handle()) - { - if u2f + && u2f .auth_verify_obj(&entry.public_key, &challenge.challenge, response)? .is_some() { @@ -1017,7 +1015,6 @@ impl TfaUserData { return Ok(()); } - } bail!("u2f verification failed"); } @@ -1089,8 +1086,8 @@ impl TfaUserData { userid: &str, value: &str, ) -> Result<(), Error> { - if let Some(r) = &mut self.recovery { - if r.verify(value)? { + if let Some(r) = &mut self.recovery + && r.verify(value)? { // On success we reset the failure state. self.totp_locked = false; self.tfa_locked_until = None; @@ -1103,7 +1100,6 @@ impl TfaUserData { } return Ok(()); } - } bail!("recovery verification failed"); } diff --git a/proxmox-tfa/src/api/webauthn.rs b/proxmox-tfa/src/api/webauthn.rs index 56cf9073..8343d721 100644 --- a/proxmox-tfa/src/api/webauthn.rs +++ b/proxmox-tfa/src/api/webauthn.rs @@ -196,11 +196,10 @@ fn force_allow_backup_eligibility( ) -> Result { let mut state = serde_json::to_value(&state).context("failed to convert authentication state to json")?; - if let Some(obj) = state.get_mut("ast") { - if let Some(allow) = obj.get_mut("allow_backup_eligible_upgrade") { + if let Some(obj) = state.get_mut("ast") + && let Some(allow) = obj.get_mut("allow_backup_eligible_upgrade") { *allow = serde_json::Value::Bool(true); } - } serde_json::from_value(state).context("failed to convert json back to authentication state") } diff --git a/pve-api-types/src/types/array.rs b/pve-api-types/src/types/array.rs index 6f468fbf..75a98af4 100644 --- a/pve-api-types/src/types/array.rs +++ b/pve-api-types/src/types/array.rs @@ -174,8 +174,8 @@ impl ArrayMap { let mut this = ArrayMap::default(); while let Some((key, value)) = map.next_entry::, T>()? { - if let Some(id) = key.as_ref().strip_prefix(self.prefix) { - if let Ok(id) = id.parse::() { + if let Some(id) = key.as_ref().strip_prefix(self.prefix) + && let Ok(id) = id.parse::() { if this.insert(id, value).map_err(A::Error::custom)?.is_some() { return Err(A::Error::custom(format!( "multiple '{}{id}' elements", @@ -184,7 +184,6 @@ impl ArrayMap { } continue; } - } return Err(A::Error::custom(format!( "invalid array element name {key}" ))); diff --git a/pve-api-types/src/types/verifiers.rs b/pve-api-types/src/types/verifiers.rs index c45063b5..18d16470 100644 --- a/pve-api-types/src/types/verifiers.rs +++ b/pve-api-types/src/types/verifiers.rs @@ -152,9 +152,9 @@ pub fn verify_cidrv6(s: &str) -> Result<(), Error> { pub fn verify_ip_or_cidr(s: &str) -> Result<(), Error> { if verify_cidr(s).is_ok() { - return Ok(()); + Ok(()) } else if verify_ip(s).is_ok() { - return Ok(()); + Ok(()) } else { bail!("not a valid IP address or CIDR notation"); } @@ -217,11 +217,10 @@ pub fn verify_lxc_mp_string(s: &str) -> Result<(), Error> { } pub fn verify_ip_with_ll_iface(s: &str) -> Result<(), Error> { - if let Some(percent) = s.find('%') { - if FE80_RE.is_match(s) && IFACE_RE.is_match(&s[(percent + 1)..]) { + if let Some(percent) = s.find('%') + && FE80_RE.is_match(s) && IFACE_RE.is_match(&s[(percent + 1)..]) { return verify_ipv6(&s[..percent]); } - } verify_ip(s) } -- 2.47.3 _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel