From 20813274287f0d7f6cc625cddd5cd4cebf2f0eba Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Wed, 14 Oct 2020 14:22:38 +0200 Subject: [PATCH] more clippy lints Signed-off-by: Wolfgang Bumiller --- src/api2/admin/datastore.rs | 8 ++++---- src/api2/node/rrd.rs | 6 ++---- src/client/pull.rs | 30 ++++++++++++++++-------------- src/client/task_log.rs | 4 ++-- src/config/cached_user_info.rs | 6 ++---- src/config/network.rs | 8 ++++++-- src/config/network/helper.rs | 2 +- 7 files changed, 33 insertions(+), 31 deletions(-) diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs index 5824611b..de39cd1b 100644 --- a/src/api2/admin/datastore.rs +++ b/src/api2/admin/datastore.rs @@ -164,8 +164,8 @@ fn list_groups( let list_all = (user_privs & PRIV_DATASTORE_AUDIT) != 0; let owner = datastore.get_owner(group)?; - if !list_all { - if owner != userid { continue; } + if !list_all && owner != userid { + continue; } let result_item = GroupListItem { @@ -355,8 +355,8 @@ pub fn list_snapshots ( let list_all = (user_privs & PRIV_DATASTORE_AUDIT) != 0; let owner = datastore.get_owner(group)?; - if !list_all { - if owner != userid { continue; } + if !list_all && owner != userid { + continue; } let mut size = None; diff --git a/src/api2/node/rrd.rs b/src/api2/node/rrd.rs index cc18f30e..692a84a1 100644 --- a/src/api2/node/rrd.rs +++ b/src/api2/node/rrd.rs @@ -31,10 +31,8 @@ pub fn create_value_from_rrd( } else { result.push(json!({ "time": t })); } - } else { - if let Some(value) = list[index] { - result[index][name] = value.into(); - } + } else if let Some(value) = list[index] { + result[index][name] = value.into(); } t += reso; } diff --git a/src/client/pull.rs b/src/client/pull.rs index c059da52..a1d5ea48 100644 --- a/src/client/pull.rs +++ b/src/client/pull.rs @@ -531,20 +531,22 @@ pub async fn pull_store( item.backup_type, item.backup_id, userid, owner)); errors = true; // do not stop here, instead continue - } else { - - if let Err(err) = pull_group( - worker, - client, - src_repo, - tgt_store.clone(), - &group, - delete, - Some((groups_done, group_count)), - ).await { - worker.log(format!("sync group {}/{} failed - {}", item.backup_type, item.backup_id, err)); - errors = true; // do not stop here, instead continue - } + } else if let Err(err) = pull_group( + worker, + client, + src_repo, + tgt_store.clone(), + &group, + delete, + Some((groups_done, group_count)), + ).await { + worker.log(format!( + "sync group {}/{} failed - {}", + item.backup_type, + item.backup_id, + err, + )); + errors = true; // do not stop here, instead continue } } diff --git a/src/client/task_log.rs b/src/client/task_log.rs index 4db2a8e0..7f16d84d 100644 --- a/src/client/task_log.rs +++ b/src/client/task_log.rs @@ -43,8 +43,8 @@ pub async fn display_task_log( } else { break; } - } else { - if lines != limit { bail!("got wrong number of lines from server ({} != {})", lines, limit); } + } else if lines != limit { + bail!("got wrong number of lines from server ({} != {})", lines, limit); } } diff --git a/src/config/cached_user_info.rs b/src/config/cached_user_info.rs index 026c3e47..cf9c534d 100644 --- a/src/config/cached_user_info.rs +++ b/src/config/cached_user_info.rs @@ -64,10 +64,8 @@ impl CachedUserInfo { return false; } if let Some(expire) = info.expire { - if expire > 0 { - if expire <= now() { - return false; - } + if expire > 0 && expire <= now() { + return false; } } return true; diff --git a/src/config/network.rs b/src/config/network.rs index 98313442..458dfe11 100644 --- a/src/config/network.rs +++ b/src/config/network.rs @@ -289,8 +289,12 @@ impl Interface { if let Some(method6) = self.method6 { let mut skip_v6 = false; // avoid empty inet6 manual entry - if self.method.is_some() && method6 == NetworkConfigMethod::Manual { - if self.comments6.is_none() && self.options6.is_empty() { skip_v6 = true; } + if self.method.is_some() + && method6 == NetworkConfigMethod::Manual + && self.comments6.is_none() + && self.options6.is_empty() + { + skip_v6 = true; } if !skip_v6 { diff --git a/src/config/network/helper.rs b/src/config/network/helper.rs index b14cde6e..3d59e392 100644 --- a/src/config/network/helper.rs +++ b/src/config/network/helper.rs @@ -10,7 +10,7 @@ use regex::Regex; use proxmox::*; // for IP macros -pub static IPV4_REVERSE_MASK: &[&'static str] = &[ +pub static IPV4_REVERSE_MASK: &[&str] = &[ "0.0.0.0", "128.0.0.0", "192.0.0.0",