clippy: more misc fixes

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
Fabian Grünbichler 2021-01-25 14:43:00 +01:00 committed by Wolfgang Bumiller
parent 367c0ff7c6
commit 4d104cd4d8
5 changed files with 12 additions and 28 deletions

View File

@ -63,11 +63,8 @@ fn main() {
let mut rpcenv = CliEnvironment::new(); let mut rpcenv = CliEnvironment::new();
rpcenv.set_auth_id(Some(String::from("root@pam"))); rpcenv.set_auth_id(Some(String::from("root@pam")));
match proxmox_backup::tools::runtime::main(do_update(&mut rpcenv)) { if let Err(err) = proxmox_backup::tools::runtime::main(do_update(&mut rpcenv)) {
Err(err) => { eprintln!("error during update: {}", err);
eprintln!("error during update: {}", err); std::process::exit(1);
std::process::exit(1);
},
_ => (),
} }
} }

View File

@ -315,22 +315,13 @@ fn change_passphrase(
}, },
)] )]
/// Print the encryption key's metadata. /// Print the encryption key's metadata.
fn show_key( fn show_key(path: Option<String>, param: Value) -> Result<(), Error> {
path: Option<String>,
param: Value,
) -> Result<(), Error> {
let path = match path { let path = match path {
Some(path) => PathBuf::from(path), Some(path) => PathBuf::from(path),
None => { None => find_default_encryption_key()?
let path = find_default_encryption_key()? .ok_or_else(|| format_err!("no encryption file provided and no default file found"))?,
.ok_or_else(|| {
format_err!("no encryption file provided and no default file found")
})?;
path
}
}; };
let config: KeyConfig = serde_json::from_slice(&file_get_contents(path.clone())?)?; let config: KeyConfig = serde_json::from_slice(&file_get_contents(path.clone())?)?;
let output_format = get_output_format(&param); let output_format = get_output_format(&param);
@ -442,13 +433,8 @@ fn paper_key(
) -> Result<(), Error> { ) -> Result<(), Error> {
let path = match path { let path = match path {
Some(path) => PathBuf::from(path), Some(path) => PathBuf::from(path),
None => { None => find_default_encryption_key()?
let path = find_default_encryption_key()? .ok_or_else(|| format_err!("no encryption file provided and no default file found"))?,
.ok_or_else(|| {
format_err!("no encryption file provided and no default file found")
})?;
path
}
}; };
let data = file_get_contents(&path)?; let data = file_get_contents(&path)?;

View File

@ -345,7 +345,7 @@ fn unmap(
let mut any = false; let mut any = false;
for (backing, loopdev) in tools::fuse_loop::find_all_mappings()? { for (backing, loopdev) in tools::fuse_loop::find_all_mappings()? {
let name = tools::systemd::unescape_unit(&backing)?; let name = tools::systemd::unescape_unit(&backing)?;
println!("{}:\t{}", loopdev.unwrap_or("(unmapped)".to_owned()), name); println!("{}:\t{}", loopdev.unwrap_or_else(|| "(unmapped)".to_string()), name);
any = true; any = true;
} }
if !any { if !any {

View File

@ -133,7 +133,7 @@ fn list_permissions(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Val
let output_format = get_output_format(&param); let output_format = get_output_format(&param);
let info = &api2::access::API_METHOD_LIST_PERMISSIONS; let info = &api2::access::API_METHOD_LIST_PERMISSIONS;
let mut data = match info.handler { let data = match info.handler {
ApiHandler::Sync(handler) => (handler)(param, info, rpcenv)?, ApiHandler::Sync(handler) => (handler)(param, info, rpcenv)?,
_ => unreachable!(), _ => unreachable!(),
}; };
@ -161,7 +161,7 @@ fn list_permissions(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Val
} }
} }
} else { } else {
format_and_print_result(&mut data, &output_format); format_and_print_result(&data, &output_format);
} }
Ok(Value::Null) Ok(Value::Null)

View File

@ -1,3 +1,4 @@
#[allow(clippy::module_inception)]
mod rrd; mod rrd;
pub use rrd::*; pub use rrd::*;
mod cache; mod cache;