applied clippy lints

This commit is contained in:
shimun 2020-04-07 20:06:24 +02:00
parent b94f45d1ff
commit 9307503bdc
Signed by: shimun
GPG Key ID: E81D8382DC2F971B
5 changed files with 16 additions and 19 deletions

View File

@ -138,7 +138,7 @@ impl SecretGeneration {
while let Ok(el) = start.elapsed() {
if el > timeout {
Err(error::Fido2LuksError::NoAuthenticatorError)?;
return Err(error::Fido2LuksError::NoAuthenticatorError);
}
if get_devices()
.map(|devices| !devices.is_empty())
@ -287,9 +287,9 @@ pub fn run_cli() -> Fido2LuksResult<()> {
.patch(&args, Some(false))
.obtain_secret("Password")?;
if *binary {
stdout.write(&secret[..])?;
stdout.write_all(&secret[..])?;
} else {
stdout.write(hex::encode(&secret[..]).as_bytes())?;
stdout.write_all(hex::encode(&secret[..]).as_bytes())?;
}
Ok(stdout.flush()?)
}
@ -363,14 +363,11 @@ pub fn run_cli() -> Fido2LuksResult<()> {
{
Err(e) => {
match e {
Fido2LuksError::WrongSecret if retries > 0 => (),
Fido2LuksError::WrongSecret if retries > 0 => {}
Fido2LuksError::AuthenticatorError { ref cause }
if cause.kind() == FidoErrorKind::Timeout && retries > 0 =>
{
()
}
if cause.kind() == FidoErrorKind::Timeout && retries > 0 => {}
e => break Err(e)?,
e => return Err(e),
}
retries -= 1;
eprintln!("{}", e);

View File

@ -24,7 +24,7 @@ impl Default for InputSalt {
impl From<&str> for InputSalt {
fn from(s: &str) -> Self {
let mut parts = s.split(":").into_iter();
let mut parts = s.split(':');
match parts.next() {
Some("ask") | Some("Ask") => InputSalt::AskPassword,
Some("file") => InputSalt::File {
@ -87,6 +87,7 @@ impl InputSalt {
#[derive(Debug, Clone)]
pub enum PasswordHelper {
Script(String),
#[allow(dead_code)]
Systemd,
Stdin,
}
@ -134,7 +135,7 @@ impl PasswordHelper {
Systemd => unimplemented!(),
Stdin => Ok(util::read_password("Password", true)?),
Script(password_helper) => {
let mut helper_parts = password_helper.split(" ");
let mut helper_parts = password_helper.split(' ');
let password = Command::new((&mut helper_parts).next().unwrap())
.args(helper_parts)

View File

@ -7,7 +7,7 @@ use ctap::{
};
use std::time::Duration;
const RP_ID: &'static str = "fido2luks";
const RP_ID: &str = "fido2luks";
pub fn make_credential_id(name: Option<&str>) -> Fido2LuksResult<FidoCredential> {
let mut request = FidoCredentialRequestBuilder::default().rp_id(RP_ID);
@ -52,7 +52,7 @@ pub fn get_devices() -> Fido2LuksResult<Vec<FidoDevice>> {
match FidoDevice::new(&di) {
Err(e) => match e.kind() {
FidoErrorKind::ParseCtap | FidoErrorKind::DeviceUnsupported => (),
err => Err(FidoError::from(err))?,
err => return Err(FidoError::from(err).into()),
},
Ok(dev) => devices.push(dev),
}

View File

@ -11,7 +11,7 @@ fn load_device_handle<P: AsRef<Path>>(path: P) -> Fido2LuksResult<CryptDevice> {
.into_iter()
.fold(None, |res, format| match res {
Some(Ok(())) => res,
Some(e) => Some(e.or(load(format))),
Some(e) => Some(e.or_else(|_| load(format))),
None => Some(load(format)),
})
.unwrap()?;
@ -58,9 +58,8 @@ pub fn remove_keyslots<P: AsRef<Path>>(path: P, exclude: &[u32]) -> Fido2LuksRes
}
_ => (),
}
match handle.status()? {
KeyslotInfo::ActiveLast => break,
_ => (),
if let KeyslotInfo::ActiveLast = handle.status()? {
break;
}
}
Ok(destroyed)

View File

@ -4,7 +4,7 @@ use std::fs::File;
use std::io::Read;
use std::path::PathBuf;
pub fn sha256<'a>(messages: &[&[u8]]) -> [u8; 32] {
pub fn sha256(messages: &[&[u8]]) -> [u8; 32] {
let mut digest = digest::Context::new(&digest::SHA256);
for m in messages.iter() {
digest.update(m);
@ -23,7 +23,7 @@ pub fn read_password(q: &str, verify: bool) -> Fido2LuksResult<String> {
{
Err(Fido2LuksError::AskPassError {
cause: AskPassError::Mismatch,
})?
})
}
pass => Ok(pass),
}