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 BE93D1FF13F for ; Thu, 12 Mar 2026 14:52:55 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 7B786170D7; Thu, 12 Mar 2026 14:52:45 +0100 (CET) From: Lukas Wagner To: pdm-devel@lists.proxmox.com Subject: [PATCH proxmox 10/26] disks: clippy: collapse if-let chains where possible Date: Thu, 12 Mar 2026 14:52:11 +0100 Message-ID: <20260312135229.420729-11-l.wagner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260312135229.420729-1-l.wagner@proxmox.com> References: <20260312135229.420729-1-l.wagner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1773323523042 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.047 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 RCVD_IN_MSPIKE_H2 0.001 Average reputation (+2) SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: LRPKMT75HZDZRFNFJFB4F77RI2M4AOTZ X-Message-ID-Hash: LRPKMT75HZDZRFNFJFB4F77RI2M4AOTZ X-MailFrom: l.wagner@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Signed-off-by: Lukas Wagner --- proxmox-disks/src/lib.rs | 21 ++++++++++----------- proxmox-disks/src/lvm.rs | 10 +++++----- proxmox-disks/src/smart.rs | 8 ++++---- proxmox-disks/src/zfs.rs | 10 +++++----- 4 files changed, 24 insertions(+), 25 deletions(-) diff --git a/proxmox-disks/src/lib.rs b/proxmox-disks/src/lib.rs index 74907711..41e95b40 100644 --- a/proxmox-disks/src/lib.rs +++ b/proxmox-disks/src/lib.rs @@ -1009,21 +1009,20 @@ fn get_disks( let name = item.file_name().to_str().unwrap().to_string(); - if let Some(ref disks) = disks { - if !disks.contains(&name) { - continue; - } + if let Some(ref disks) = disks + && !disks.contains(&name) + { + continue; } let sys_path = format!("/sys/block/{name}"); - if let Ok(target) = std::fs::read_link(&sys_path) { - if let Some(target) = target.to_str() { - if ISCSI_PATH_REGEX.is_match(target) { - continue; - } // skip iSCSI devices - } - } + if let Ok(target) = std::fs::read_link(&sys_path) + && let Some(target) = target.to_str() + && ISCSI_PATH_REGEX.is_match(target) + { + continue; + } // skip iSCSI devices let disk = disk_manager.clone().disk_by_sys_path(&sys_path)?; diff --git a/proxmox-disks/src/lvm.rs b/proxmox-disks/src/lvm.rs index 1456a21c..4c1ed4a4 100644 --- a/proxmox-disks/src/lvm.rs +++ b/proxmox-disks/src/lvm.rs @@ -34,11 +34,11 @@ pub fn get_lvm_devices(lsblk_info: &[LsblkInfo]) -> Result, Error> let mut device_set: HashSet = HashSet::new(); for info in lsblk_info.iter() { - if let Some(partition_type) = &info.partition_type { - if LVM_UUIDS.contains(partition_type.as_str()) { - let meta = std::fs::metadata(&info.path)?; - device_set.insert(meta.rdev()); - } + if let Some(partition_type) = &info.partition_type + && LVM_UUIDS.contains(partition_type.as_str()) + { + let meta = std::fs::metadata(&info.path)?; + device_set.insert(meta.rdev()); } } diff --git a/proxmox-disks/src/smart.rs b/proxmox-disks/src/smart.rs index 247bc4d3..e27348a6 100644 --- a/proxmox-disks/src/smart.rs +++ b/proxmox-disks/src/smart.rs @@ -174,10 +174,10 @@ pub fn get_smart_data(disk_path: &Path, health_only: bool) -> Result) -> Result