various clippy fixes

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
Fabian Grünbichler 2024-06-06 11:21:24 +02:00
parent 7a8e948ee7
commit 6f532dfb7d
14 changed files with 28 additions and 36 deletions

View File

@ -865,7 +865,7 @@ pub fn parse_str_value_to_option<T: Parse>(
path: &syn::Path,
nv: syn::parse::ParseStream<'_>,
) {
duplicate(&*target, &path);
duplicate(&*target, path);
match nv.parse().and_then(|lit| parse_lit_str(&lit)) {
Ok(value) => *target = Some(value),
Err(err) => crate::add_error(err),

View File

@ -125,7 +125,7 @@ fn test_digest() -> Result<(), Error> {
std::fs::copy(path, new_path)?;
// modify the repo
let mut repo = file.repositories.first_mut().unwrap();
let repo = file.repositories.first_mut().unwrap();
repo.enabled = !repo.enabled;
// ...then it should work
@ -183,7 +183,7 @@ fn test_check_repositories() -> Result<(), Error> {
));
let absolute_suite_list = read_dir.join("absolute_suite.list");
let mut file = APTRepositoryFile::new(&absolute_suite_list)?.unwrap();
let mut file = APTRepositoryFile::new(absolute_suite_list)?.unwrap();
file.parse()?;
let infos = check_repositories(&[file], DebianCodename::Bullseye);
@ -327,7 +327,7 @@ fn test_get_cached_origin() -> Result<(), Error> {
));
let pve_list = read_dir.join("pve.list");
let mut file = APTRepositoryFile::new(&pve_list)?.unwrap();
let mut file = APTRepositoryFile::new(pve_list)?.unwrap();
file.parse()?;
let origins = [
@ -366,7 +366,7 @@ fn test_standard_repositories() -> Result<(), Error> {
];
let absolute_suite_list = read_dir.join("absolute_suite.list");
let mut file = APTRepositoryFile::new(&absolute_suite_list)?.unwrap();
let mut file = APTRepositoryFile::new(absolute_suite_list)?.unwrap();
file.parse()?;
let std_repos = standard_repositories(&[file], "pve", DebianCodename::Bullseye);
@ -374,7 +374,7 @@ fn test_standard_repositories() -> Result<(), Error> {
assert_eq!(std_repos, &expected[0..=5]);
let absolute_suite_list = read_dir.join("absolute_suite.list");
let mut file = APTRepositoryFile::new(&absolute_suite_list)?.unwrap();
let mut file = APTRepositoryFile::new(absolute_suite_list)?.unwrap();
file.parse()?;
let std_repos = standard_repositories(&[file], "pve", DebianCodename::Bookworm);
@ -382,7 +382,7 @@ fn test_standard_repositories() -> Result<(), Error> {
assert_eq!(std_repos, expected);
let pve_list = read_dir.join("pve.list");
let mut file = APTRepositoryFile::new(&pve_list)?.unwrap();
let mut file = APTRepositoryFile::new(pve_list)?.unwrap();
file.parse()?;
let file_vec = vec![file];
@ -399,7 +399,7 @@ fn test_standard_repositories() -> Result<(), Error> {
assert_eq!(std_repos, &expected[0..=5]);
let pve_alt_list = read_dir.join("pve-alt.list");
let mut file = APTRepositoryFile::new(&pve_alt_list)?.unwrap();
let mut file = APTRepositoryFile::new(pve_alt_list)?.unwrap();
file.parse()?;
expected[0].status = Some(true);
@ -411,7 +411,7 @@ fn test_standard_repositories() -> Result<(), Error> {
assert_eq!(std_repos, &expected[0..=5]);
let pve_alt_list = read_dir.join("ceph-quincy-bookworm.list");
let mut file = APTRepositoryFile::new(&pve_alt_list)?.unwrap();
let mut file = APTRepositoryFile::new(pve_alt_list)?.unwrap();
file.parse()?;
expected[0].status = None;
@ -426,7 +426,7 @@ fn test_standard_repositories() -> Result<(), Error> {
assert_eq!(std_repos, expected);
let pve_alt_list = read_dir.join("ceph-quincy-nosub-bookworm.list");
let mut file = APTRepositoryFile::new(&pve_alt_list)?.unwrap();
let mut file = APTRepositoryFile::new(pve_alt_list)?.unwrap();
file.parse()?;
expected[0].status = None;
@ -441,7 +441,7 @@ fn test_standard_repositories() -> Result<(), Error> {
assert_eq!(std_repos, expected);
let pve_alt_list = read_dir.join("ceph-reef-enterprise-bookworm.list");
let mut file = APTRepositoryFile::new(&pve_alt_list)?.unwrap();
let mut file = APTRepositoryFile::new(pve_alt_list)?.unwrap();
file.parse()?;
expected[0].status = None;

View File

@ -54,7 +54,7 @@ pub use byte_vec::ByteVecExt;
pub unsafe fn uninitialized(len: usize) -> Vec<u8> {
unsafe {
let data = std::alloc::alloc(std::alloc::Layout::array::<u8>(len).unwrap());
Vec::from_raw_parts(data as *mut u8, len, len)
Vec::from_raw_parts(data, len, len)
}
}

View File

@ -14,7 +14,7 @@ struct GlauthServer {
impl GlauthServer {
fn new(path: &str) -> Result<Self, Error> {
let glauth_bin = std::env::var("GLAUTH_BIN").context("GLAUTH_BIN is not set")?;
let handle = Command::new(&glauth_bin)
let handle = Command::new(glauth_bin)
.arg("-c")
.arg(path)
.stdin(Stdio::null())
@ -155,16 +155,10 @@ fn test_search() -> Result<(), Error> {
.attributes
.get("mail")
.unwrap()
.get(0)
.first()
.unwrap()
.ends_with("@example.com"));
assert!(a
.attributes
.get("sn")
.unwrap()
.get(0)
.unwrap()
.eq("User".into()));
assert!(a.attributes.get("sn").unwrap().first().unwrap().eq("User"));
}
Ok(())

View File

@ -102,7 +102,7 @@ pub fn update_endpoint(
config,
&GotifyPrivateConfig {
name: name.into(),
token: token.into(),
token,
},
)?;
}

View File

@ -12,13 +12,13 @@ use crate::Error;
/// Section config schema for the public config file.
pub fn config_parser() -> &'static SectionConfig {
static CONFIG: OnceLock<SectionConfig> = OnceLock::new();
CONFIG.get_or_init(|| config_init())
CONFIG.get_or_init(config_init)
}
/// Section config schema for the private config file.
pub fn private_config_parser() -> &'static SectionConfig {
static CONFIG: OnceLock<SectionConfig> = OnceLock::new();
CONFIG.get_or_init(|| private_config_init())
CONFIG.get_or_init(private_config_init)
}
fn config_init() -> SectionConfig {

View File

@ -495,7 +495,7 @@ impl Service<Uri> for PrivilegedAddr {
fn call(&mut self, _req: Uri) -> Self::Future {
match self {
PrivilegedAddr::Tcp(addr) => {
let addr = addr.clone();
let addr = *addr;
Box::pin(async move {
tokio::net::TcpStream::connect(addr)
.await

View File

@ -155,7 +155,7 @@ impl Service<Request<Body>> for RedirectService {
Response::builder()
.status(status_code)
.header("Location", String::from(location_value))
.header("Location", location_value)
.body(Body::empty())?
} else {
Response::builder()

View File

@ -850,7 +850,7 @@ impl WorkerTask {
file_opts: setup.file_opts.clone(),
..Default::default()
};
let logger = FileLogger::new(&path, logger_options)?;
let logger = FileLogger::new(path, logger_options)?;
let worker = Arc::new(Self {
setup,

View File

@ -62,8 +62,8 @@ impl Cache {
) -> Result<Self, Error> {
let basedir = basedir.as_ref().to_owned();
let file_options = file_options.unwrap_or_else(CreateOptions::new);
let dir_options = dir_options.unwrap_or_else(CreateOptions::new);
let file_options = file_options.unwrap_or_default();
let dir_options = dir_options.unwrap_or_default();
create_path(
&basedir,

View File

@ -421,7 +421,7 @@ impl<'de, 'i, 's> de::SeqAccess<'de> for SeqAccess<'de, 'i, 's> {
return Ok(None);
}
while let Some(el_range) = next_str_entry(&self.input, &mut self.at, self.has_null) {
if let Some(el_range) = next_str_entry(&self.input, &mut self.at, self.has_null) {
if let Some(max) = self.schema.max_length {
if self.count == max {
return Err(Error::msg("too many elements"));

View File

@ -303,7 +303,7 @@ impl<'a> Iterator for SplitList<'a> {
type Item = &'a str;
fn next(&mut self) -> Option<&'a str> {
let range = super::next_str_entry(&self.input, &mut self.at, self.has_null)?;
let range = super::next_str_entry(self.input, &mut self.at, self.has_null)?;
Some(&self.input[range])
}
}

View File

@ -52,12 +52,10 @@ pub fn ensure_dir_exists<P: AsRef<Path>>(
Err(nix::errno::Errno::EEXIST) => {
if enforce_permissions {
return options.check(path);
} else {
if let Err(err) = options.check(path) {
} else if let Err(err) = options.check(path) {
log::error!("{err}");
}
}
}
Err(err) => bail!("unable to create directory {path:?} - {err}",),
}

View File

@ -656,7 +656,7 @@ fn test_algorithm_parsing() {
assert_eq!(hotp.issuer.as_deref(), Some(issuer));
assert_eq!(hotp.account_name.as_deref(), Some("user@hostname"));
assert_eq!(
&base32::encode(base32::Alphabet::RFC4648 { padding: false }, &hotp.secret()),
&base32::encode(base32::Alphabet::RFC4648 { padding: false }, hotp.secret()),
secret
)
}