mirror of
https://git.proxmox.com/git/proxmox
synced 2025-06-13 14:48:37 +00:00
clippy 1.65 fixes
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
parent
50aa62b764
commit
538578c558
@ -177,7 +177,7 @@ where
|
|||||||
let mut encoder = Builder::new(target);
|
let mut encoder = Builder::new(target);
|
||||||
let mut hardlinks: HashMap<u64, HashMap<u64, PathBuf>> = HashMap::new(); // dev -> inode -> first path
|
let mut hardlinks: HashMap<u64, HashMap<u64, PathBuf>> = 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 {
|
let entry = match entry {
|
||||||
Ok(entry) => entry,
|
Ok(entry) => entry,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
|
@ -631,7 +631,7 @@ where
|
|||||||
let base_path = source.parent().unwrap_or_else(|| Path::new("/"));
|
let base_path = source.parent().unwrap_or_else(|| Path::new("/"));
|
||||||
let mut encoder = ZipEncoder::new(target);
|
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 {
|
let entry = match entry {
|
||||||
Ok(entry) => entry,
|
Ok(entry) => entry,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
@ -658,10 +658,10 @@ where
|
|||||||
|
|
||||||
if entry.file_type().is_file() {
|
if entry.file_type().is_file() {
|
||||||
let file = tokio::fs::File::open(entry.path()).await?;
|
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?;
|
encoder.add_entry(ze, Some(file)).await?;
|
||||||
} else if entry.file_type().is_dir() {
|
} 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<tokio::fs::File> = None;
|
let content: Option<tokio::fs::File> = None;
|
||||||
encoder.add_entry(ze, content).await?;
|
encoder.add_entry(ze, content).await?;
|
||||||
}
|
}
|
||||||
|
@ -234,7 +234,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[allow(clippy::blacklisted_name)]
|
#[allow(clippy::disallowed_names)]
|
||||||
fn test_extraction() {
|
fn test_extraction() {
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ impl<'a> Iterator for PropertyIterator<'a> {
|
|||||||
// value without key and quoted
|
// value without key and quoted
|
||||||
None
|
None
|
||||||
} else {
|
} 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) if self.data.as_bytes()[pos] == b',' => None,
|
||||||
Some(pos) => Some(ascii_split_off(&mut self.data, pos)),
|
Some(pos) => Some(ascii_split_off(&mut self.data, pos)),
|
||||||
None => None,
|
None => None,
|
||||||
|
@ -317,7 +317,7 @@ impl SectionConfig {
|
|||||||
let mut done = HashSet::new();
|
let mut done = HashSet::new();
|
||||||
|
|
||||||
for section_id in &config.order {
|
for section_id in &config.order {
|
||||||
if config.sections.get(section_id) == None {
|
if config.sections.get(section_id).is_none() {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
list.push(section_id);
|
list.push(section_id);
|
||||||
|
@ -76,7 +76,7 @@ fn parse_register_response(
|
|||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
let mut md5hash = String::new();
|
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) {
|
for caps in ATTR_RE.captures_iter(body) {
|
||||||
let (key, value) = (&caps[1], &caps[2]);
|
let (key, value) = (&caps[1], &caps[2]);
|
||||||
@ -90,7 +90,7 @@ fn parse_register_response(
|
|||||||
}
|
}
|
||||||
"message" => info.message = Some(value.into()),
|
"message" => info.message = Some(value.into()),
|
||||||
"validdirectory" => {
|
"validdirectory" => {
|
||||||
if value.split(',').find(is_server_id) == None {
|
if !value.split(',').any(is_server_id) {
|
||||||
bail!("Server ID does not match");
|
bail!("Server ID does not match");
|
||||||
}
|
}
|
||||||
info.serverid = Some(server_id.to_owned());
|
info.serverid = Some(server_id.to_owned());
|
||||||
|
@ -111,7 +111,7 @@ pub fn write_subscription<P: AsRef<Path>>(
|
|||||||
file_opts: CreateOptions,
|
file_opts: CreateOptions,
|
||||||
info: &SubscriptionInfo,
|
info: &SubscriptionInfo,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let raw = if info.key == None || info.checktime == None {
|
let raw = if info.key.is_none() || info.checktime.is_none() {
|
||||||
String::new()
|
String::new()
|
||||||
} else if let SubscriptionStatus::New = info.status {
|
} else if let SubscriptionStatus::New = info.status {
|
||||||
format!("{}\n", info.key.as_ref().unwrap())
|
format!("{}\n", info.key.as_ref().unwrap())
|
||||||
|
@ -108,7 +108,7 @@ pub struct SubscriptionInfo {
|
|||||||
impl SubscriptionInfo {
|
impl SubscriptionInfo {
|
||||||
/// Returns the canonicalized signed data and, if available, signature contained in `self`.
|
/// Returns the canonicalized signed data and, if available, signature contained in `self`.
|
||||||
pub fn signed_data(&self) -> Result<(Vec<u8>, Option<String>), Error> {
|
pub fn signed_data(&self) -> Result<(Vec<u8>, Option<String>), Error> {
|
||||||
let mut data = serde_json::to_value(&self)?;
|
let mut data = serde_json::to_value(self)?;
|
||||||
let signature = data
|
let signature = data
|
||||||
.as_object_mut()
|
.as_object_mut()
|
||||||
.ok_or_else(|| format_err!("subscription info not a JSON object"))?
|
.ok_or_else(|| format_err!("subscription info not a JSON object"))?
|
||||||
@ -255,7 +255,7 @@ pub fn get_hardware_address() -> Result<String, Error> {
|
|||||||
.map_err(|e| format_err!("Error getting host key - {}", e))?;
|
.map_err(|e| format_err!("Error getting host key - {}", e))?;
|
||||||
let digest = md5sum(&contents).map_err(|e| format_err!("Error digesting 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<i64, Error> {
|
fn parse_next_due(value: &str) -> Result<i64, Error> {
|
||||||
|
@ -169,7 +169,7 @@ pub fn check_process_running_pstart(pid: libc::pid_t, pstart: u64) -> Option<Pid
|
|||||||
|
|
||||||
pub fn read_proc_uptime() -> Result<(f64, f64), Error> {
|
pub fn read_proc_uptime() -> Result<(f64, f64), Error> {
|
||||||
let path = "/proc/uptime";
|
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::<f64>());
|
let mut values = line.split_whitespace().map(|v| v.parse::<f64>());
|
||||||
|
|
||||||
match (values.next(), values.next()) {
|
match (values.next(), values.next()) {
|
||||||
@ -421,7 +421,7 @@ pub struct ProcFsMemInfo {
|
|||||||
|
|
||||||
pub fn read_meminfo() -> Result<ProcFsMemInfo, Error> {
|
pub fn read_meminfo() -> Result<ProcFsMemInfo, Error> {
|
||||||
let path = "/proc/meminfo";
|
let path = "/proc/meminfo";
|
||||||
let file = OpenOptions::new().read(true).open(&path)?;
|
let file = OpenOptions::new().read(true).open(path)?;
|
||||||
|
|
||||||
let mut meminfo = ProcFsMemInfo {
|
let mut meminfo = ProcFsMemInfo {
|
||||||
memtotal: 0,
|
memtotal: 0,
|
||||||
@ -479,7 +479,7 @@ pub fn read_cpuinfo() -> Result<ProcFsCPUInfo, Error> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let path = "/proc/cpuinfo";
|
let path = "/proc/cpuinfo";
|
||||||
let file = OpenOptions::new().read(true).open(&path)?;
|
let file = OpenOptions::new().read(true).open(path)?;
|
||||||
|
|
||||||
let mut cpuinfo = ProcFsCPUInfo {
|
let mut cpuinfo = ProcFsCPUInfo {
|
||||||
user_hz: *CLOCK_TICKS,
|
user_hz: *CLOCK_TICKS,
|
||||||
@ -549,7 +549,7 @@ pub struct ProcFsNetDev {
|
|||||||
|
|
||||||
pub fn read_proc_net_dev() -> Result<Vec<ProcFsNetDev>, Error> {
|
pub fn read_proc_net_dev() -> Result<Vec<ProcFsNetDev>, Error> {
|
||||||
let path = "/proc/net/dev";
|
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();
|
let mut result = Vec::new();
|
||||||
for line in BufReader::new(&file).lines().skip(2) {
|
for line in BufReader::new(&file).lines().skip(2) {
|
||||||
@ -607,7 +607,7 @@ pub struct ProcFsNetRoute {
|
|||||||
|
|
||||||
pub fn read_proc_net_route() -> Result<Vec<ProcFsNetRoute>, Error> {
|
pub fn read_proc_net_route() -> Result<Vec<ProcFsNetRoute>, Error> {
|
||||||
let path = "/proc/net/route";
|
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();
|
let mut result = Vec::new();
|
||||||
for line in BufReader::new(&file).lines().skip(1) {
|
for line in BufReader::new(&file).lines().skip(1) {
|
||||||
@ -693,7 +693,7 @@ pub struct ProcFsNetIPv6Route {
|
|||||||
|
|
||||||
pub fn read_proc_net_ipv6_route() -> Result<Vec<ProcFsNetIPv6Route>, Error> {
|
pub fn read_proc_net_ipv6_route() -> Result<Vec<ProcFsNetIPv6Route>, Error> {
|
||||||
let path = "/proc/net/ipv6_route";
|
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();
|
let mut result = Vec::new();
|
||||||
for line in BufReader::new(&file).lines() {
|
for line in BufReader::new(&file).lines() {
|
||||||
|
Loading…
Reference in New Issue
Block a user