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 B79051FF13C for ; Thu, 19 Mar 2026 10:46:41 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id D39321739E; Thu, 19 Mar 2026 10:46:56 +0100 (CET) From: Lukas Wagner To: pdm-devel@lists.proxmox.com Subject: [PATCH proxmox v2 09/25] disks: clippy: collapse if-let chains where possible Date: Thu, 19 Mar 2026 10:45:29 +0100 Message-ID: <20260319094617.169594-10-l.wagner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260319094617.169594-1-l.wagner@proxmox.com> References: <20260319094617.169594-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: 1773913541059 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.049 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 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: KM4YITO7EIFWXAOTFIMBONEOZDN67XML X-Message-ID-Hash: KM4YITO7EIFWXAOTFIMBONEOZDN67XML 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 Reviewed-by: Arthur Bied-Charreton Tested-by: Arthur Bied-Charreton --- 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