From 54aec2fa8be5a2a34bd2bac380395612bf9bab44 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Wed, 14 Oct 2020 11:18:26 +0200 Subject: [PATCH] clippy fixups Signed-off-by: Wolfgang Bumiller --- src/auth.rs | 6 ++---- src/client/pull.rs | 10 ++++------ src/rrd/rrd.rs | 4 ++-- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/auth.rs b/src/auth.rs index 8f5d0353..faad760e 100644 --- a/src/auth.rs +++ b/src/auth.rs @@ -6,7 +6,6 @@ use std::process::{Command, Stdio}; use std::io::Write; use std::ffi::{CString, CStr}; -use base64; use anyhow::{bail, format_err, Error}; use serde_json::json; @@ -25,8 +24,7 @@ impl ProxmoxAuthenticator for PAM { let mut auth = pam::Authenticator::with_password("proxmox-backup-auth").unwrap(); auth.get_handler().set_credentials(username.as_str(), password); auth.authenticate()?; - return Ok(()); - + Ok(()) } fn store_password(&self, username: &UsernameRef, password: &str) -> Result<(), Error> { @@ -99,7 +97,7 @@ pub fn encrypt_pw(password: &str) -> Result { pub fn verify_crypt_pw(password: &str, enc_password: &str) -> Result<(), Error> { let verify = crypt(password.as_bytes(), enc_password)?; - if &verify != enc_password { + if verify != enc_password { bail!("invalid credentials"); } Ok(()) diff --git a/src/client/pull.rs b/src/client/pull.rs index d69cf485..c059da52 100644 --- a/src/client/pull.rs +++ b/src/client/pull.rs @@ -251,8 +251,8 @@ async fn pull_snapshot( Err(err) => { match err.downcast_ref::() { Some(HttpError { code, message }) => { - match code { - &StatusCode::NOT_FOUND => { + match *code { + StatusCode::NOT_FOUND => { worker.log(format!("skipping snapshot {} - vanished since start of sync", snapshot)); return Ok(()); }, @@ -434,7 +434,7 @@ pub async fn pull_group( let snapshot = BackupDir::new(item.backup_type, item.backup_id, item.backup_time)?; // in-progress backups can't be synced - if let None = item.size { + if item.size.is_none() { worker.log(format!("skipping snapshot {} - in-progress backup", snapshot)); continue; } @@ -520,9 +520,8 @@ pub async fn pull_store( } let group_count = list.len(); - let mut groups_done = 0; - for item in list { + for (groups_done, item) in list.into_iter().enumerate() { let group = BackupGroup::new(&item.backup_type, &item.backup_id); let (owner, _lock_guard) = tgt_store.create_locked_backup_group(&group, &userid)?; @@ -547,7 +546,6 @@ pub async fn pull_store( errors = true; // do not stop here, instead continue } } - groups_done += 1; } if delete { diff --git a/src/rrd/rrd.rs b/src/rrd/rrd.rs index 86d6b50b..c8b16471 100644 --- a/src/rrd/rrd.rs +++ b/src/rrd/rrd.rs @@ -272,7 +272,7 @@ impl RRD { t += reso; index = (index + 1) % RRD_DATA_ENTRIES; } - (start, reso, list.into()) + (start, reso, list) } pub fn from_raw(mut raw: &[u8]) -> Result { @@ -289,7 +289,7 @@ impl RRD { } if rrd.magic != PROXMOX_RRD_MAGIC_1_0 { - let msg = format!("wrong magic number"); + let msg = "wrong magic number".to_string(); return Err(std::io::Error::new(std::io::ErrorKind::Other, msg)); }