From 538578c5587fbc74495fe600094cf53005cf54df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= Date: Mon, 5 Dec 2022 11:17:37 +0100 Subject: [PATCH] clippy 1.65 fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fabian Grünbichler --- proxmox-compression/src/tar.rs | 2 +- proxmox-compression/src/zip.rs | 6 +++--- proxmox-schema/src/de.rs | 2 +- proxmox-schema/src/property_string.rs | 2 +- proxmox-section-config/src/lib.rs | 2 +- proxmox-subscription/src/check.rs | 4 ++-- proxmox-subscription/src/files.rs | 2 +- proxmox-subscription/src/subscription_info.rs | 4 ++-- proxmox-sys/src/linux/procfs/mod.rs | 12 ++++++------ 9 files changed, 18 insertions(+), 18 deletions(-) diff --git a/proxmox-compression/src/tar.rs b/proxmox-compression/src/tar.rs index 64197722..ba037cbc 100644 --- a/proxmox-compression/src/tar.rs +++ b/proxmox-compression/src/tar.rs @@ -177,7 +177,7 @@ where let mut encoder = Builder::new(target); let mut hardlinks: HashMap> = HashMap::new(); // dev -> inode -> first path - for entry in WalkDir::new(&source).into_iter() { + for entry in WalkDir::new(source).into_iter() { let entry = match entry { Ok(entry) => entry, Err(err) => { diff --git a/proxmox-compression/src/zip.rs b/proxmox-compression/src/zip.rs index 234cf4fb..c9ed80ed 100644 --- a/proxmox-compression/src/zip.rs +++ b/proxmox-compression/src/zip.rs @@ -631,7 +631,7 @@ where let base_path = source.parent().unwrap_or_else(|| Path::new("/")); let mut encoder = ZipEncoder::new(target); - for entry in WalkDir::new(&source).into_iter() { + for entry in WalkDir::new(source).into_iter() { let entry = match entry { Ok(entry) => entry, Err(err) => { @@ -658,10 +658,10 @@ where if entry.file_type().is_file() { let file = tokio::fs::File::open(entry.path()).await?; - let ze = ZipEntry::new(&entry_path_no_base, mtime, mode, true); + let ze = ZipEntry::new(entry_path_no_base, mtime, mode, true); encoder.add_entry(ze, Some(file)).await?; } else if entry.file_type().is_dir() { - let ze = ZipEntry::new(&entry_path_no_base, mtime, mode, false); + let ze = ZipEntry::new(entry_path_no_base, mtime, mode, false); let content: Option = None; encoder.add_entry(ze, content).await?; } diff --git a/proxmox-schema/src/de.rs b/proxmox-schema/src/de.rs index cb9a53e2..6c2edcd8 100644 --- a/proxmox-schema/src/de.rs +++ b/proxmox-schema/src/de.rs @@ -234,7 +234,7 @@ where } #[test] -#[allow(clippy::blacklisted_name)] +#[allow(clippy::disallowed_names)] fn test_extraction() { use serde::Deserialize; diff --git a/proxmox-schema/src/property_string.rs b/proxmox-schema/src/property_string.rs index 7b3aa61e..b4269448 100644 --- a/proxmox-schema/src/property_string.rs +++ b/proxmox-schema/src/property_string.rs @@ -34,7 +34,7 @@ impl<'a> Iterator for PropertyIterator<'a> { // value without key and quoted None } else { - let key = match self.data.find(&[',', '=']) { + let key = match self.data.find([',', '=']) { Some(pos) if self.data.as_bytes()[pos] == b',' => None, Some(pos) => Some(ascii_split_off(&mut self.data, pos)), None => None, diff --git a/proxmox-section-config/src/lib.rs b/proxmox-section-config/src/lib.rs index 91793a4c..1706718e 100644 --- a/proxmox-section-config/src/lib.rs +++ b/proxmox-section-config/src/lib.rs @@ -317,7 +317,7 @@ impl SectionConfig { let mut done = HashSet::new(); for section_id in &config.order { - if config.sections.get(section_id) == None { + if config.sections.get(section_id).is_none() { continue; }; list.push(section_id); diff --git a/proxmox-subscription/src/check.rs b/proxmox-subscription/src/check.rs index f65ee7f3..3838e9c2 100644 --- a/proxmox-subscription/src/check.rs +++ b/proxmox-subscription/src/check.rs @@ -76,7 +76,7 @@ fn parse_register_response( ..Default::default() }; let mut md5hash = String::new(); - let is_server_id = |id: &&str| *id == server_id; + let is_server_id = |id: &str| *id == server_id; for caps in ATTR_RE.captures_iter(body) { let (key, value) = (&caps[1], &caps[2]); @@ -90,7 +90,7 @@ fn parse_register_response( } "message" => info.message = Some(value.into()), "validdirectory" => { - if value.split(',').find(is_server_id) == None { + if !value.split(',').any(is_server_id) { bail!("Server ID does not match"); } info.serverid = Some(server_id.to_owned()); diff --git a/proxmox-subscription/src/files.rs b/proxmox-subscription/src/files.rs index 7767a3c6..37008f4a 100644 --- a/proxmox-subscription/src/files.rs +++ b/proxmox-subscription/src/files.rs @@ -111,7 +111,7 @@ pub fn write_subscription>( file_opts: CreateOptions, info: &SubscriptionInfo, ) -> Result<(), Error> { - let raw = if info.key == None || info.checktime == None { + let raw = if info.key.is_none() || info.checktime.is_none() { String::new() } else if let SubscriptionStatus::New = info.status { format!("{}\n", info.key.as_ref().unwrap()) diff --git a/proxmox-subscription/src/subscription_info.rs b/proxmox-subscription/src/subscription_info.rs index a5c32b1e..8c0bd3e3 100644 --- a/proxmox-subscription/src/subscription_info.rs +++ b/proxmox-subscription/src/subscription_info.rs @@ -108,7 +108,7 @@ pub struct SubscriptionInfo { impl SubscriptionInfo { /// Returns the canonicalized signed data and, if available, signature contained in `self`. pub fn signed_data(&self) -> Result<(Vec, Option), Error> { - let mut data = serde_json::to_value(&self)?; + let mut data = serde_json::to_value(self)?; let signature = data .as_object_mut() .ok_or_else(|| format_err!("subscription info not a JSON object"))? @@ -255,7 +255,7 @@ pub fn get_hardware_address() -> Result { .map_err(|e| format_err!("Error getting host key - {}", e))?; let digest = md5sum(&contents).map_err(|e| format_err!("Error digesting host key - {}", e))?; - Ok(hex::encode(&digest).to_uppercase()) + Ok(hex::encode(digest).to_uppercase()) } fn parse_next_due(value: &str) -> Result { diff --git a/proxmox-sys/src/linux/procfs/mod.rs b/proxmox-sys/src/linux/procfs/mod.rs index 3373dec0..2eeaed1f 100644 --- a/proxmox-sys/src/linux/procfs/mod.rs +++ b/proxmox-sys/src/linux/procfs/mod.rs @@ -169,7 +169,7 @@ pub fn check_process_running_pstart(pid: libc::pid_t, pstart: u64) -> Option Result<(f64, f64), Error> { let path = "/proc/uptime"; - let line = file_read_firstline(&path)?; + let line = file_read_firstline(path)?; let mut values = line.split_whitespace().map(|v| v.parse::()); match (values.next(), values.next()) { @@ -421,7 +421,7 @@ pub struct ProcFsMemInfo { pub fn read_meminfo() -> Result { let path = "/proc/meminfo"; - let file = OpenOptions::new().read(true).open(&path)?; + let file = OpenOptions::new().read(true).open(path)?; let mut meminfo = ProcFsMemInfo { memtotal: 0, @@ -479,7 +479,7 @@ pub fn read_cpuinfo() -> Result { } let path = "/proc/cpuinfo"; - let file = OpenOptions::new().read(true).open(&path)?; + let file = OpenOptions::new().read(true).open(path)?; let mut cpuinfo = ProcFsCPUInfo { user_hz: *CLOCK_TICKS, @@ -549,7 +549,7 @@ pub struct ProcFsNetDev { pub fn read_proc_net_dev() -> Result, Error> { let path = "/proc/net/dev"; - let file = OpenOptions::new().read(true).open(&path)?; + let file = OpenOptions::new().read(true).open(path)?; let mut result = Vec::new(); for line in BufReader::new(&file).lines().skip(2) { @@ -607,7 +607,7 @@ pub struct ProcFsNetRoute { pub fn read_proc_net_route() -> Result, Error> { let path = "/proc/net/route"; - let file = OpenOptions::new().read(true).open(&path)?; + let file = OpenOptions::new().read(true).open(path)?; let mut result = Vec::new(); for line in BufReader::new(&file).lines().skip(1) { @@ -693,7 +693,7 @@ pub struct ProcFsNetIPv6Route { pub fn read_proc_net_ipv6_route() -> Result, Error> { let path = "/proc/net/ipv6_route"; - let file = OpenOptions::new().read(true).open(&path)?; + let file = OpenOptions::new().read(true).open(path)?; let mut result = Vec::new(); for line in BufReader::new(&file).lines() {