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 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 {
|
||||
Ok(entry) => entry,
|
||||
Err(err) => {
|
||||
|
@ -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<tokio::fs::File> = None;
|
||||
encoder.add_entry(ze, content).await?;
|
||||
}
|
||||
|
@ -234,7 +234,7 @@ where
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[allow(clippy::blacklisted_name)]
|
||||
#[allow(clippy::disallowed_names)]
|
||||
fn test_extraction() {
|
||||
use serde::Deserialize;
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
|
@ -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());
|
||||
|
@ -111,7 +111,7 @@ pub fn write_subscription<P: AsRef<Path>>(
|
||||
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())
|
||||
|
@ -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<u8>, Option<String>), 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<String, Error> {
|
||||
.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<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> {
|
||||
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>());
|
||||
|
||||
match (values.next(), values.next()) {
|
||||
@ -421,7 +421,7 @@ pub struct ProcFsMemInfo {
|
||||
|
||||
pub fn read_meminfo() -> Result<ProcFsMemInfo, Error> {
|
||||
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<ProcFsCPUInfo, Error> {
|
||||
}
|
||||
|
||||
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<Vec<ProcFsNetDev>, 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<Vec<ProcFsNetRoute>, 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<Vec<ProcFsNetIPv6Route>, 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() {
|
||||
|
Loading…
Reference in New Issue
Block a user