forked from proxmox-mirrors/proxmox
various clippy fixes
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
parent
7a8e948ee7
commit
6f532dfb7d
@ -865,7 +865,7 @@ pub fn parse_str_value_to_option<T: Parse>(
|
|||||||
path: &syn::Path,
|
path: &syn::Path,
|
||||||
nv: syn::parse::ParseStream<'_>,
|
nv: syn::parse::ParseStream<'_>,
|
||||||
) {
|
) {
|
||||||
duplicate(&*target, &path);
|
duplicate(&*target, path);
|
||||||
match nv.parse().and_then(|lit| parse_lit_str(&lit)) {
|
match nv.parse().and_then(|lit| parse_lit_str(&lit)) {
|
||||||
Ok(value) => *target = Some(value),
|
Ok(value) => *target = Some(value),
|
||||||
Err(err) => crate::add_error(err),
|
Err(err) => crate::add_error(err),
|
||||||
|
@ -125,7 +125,7 @@ fn test_digest() -> Result<(), Error> {
|
|||||||
std::fs::copy(path, new_path)?;
|
std::fs::copy(path, new_path)?;
|
||||||
|
|
||||||
// modify the repo
|
// modify the repo
|
||||||
let mut repo = file.repositories.first_mut().unwrap();
|
let repo = file.repositories.first_mut().unwrap();
|
||||||
repo.enabled = !repo.enabled;
|
repo.enabled = !repo.enabled;
|
||||||
|
|
||||||
// ...then it should work
|
// ...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 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()?;
|
file.parse()?;
|
||||||
|
|
||||||
let infos = check_repositories(&[file], DebianCodename::Bullseye);
|
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 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()?;
|
file.parse()?;
|
||||||
|
|
||||||
let origins = [
|
let origins = [
|
||||||
@ -366,7 +366,7 @@ fn test_standard_repositories() -> Result<(), Error> {
|
|||||||
];
|
];
|
||||||
|
|
||||||
let absolute_suite_list = read_dir.join("absolute_suite.list");
|
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()?;
|
file.parse()?;
|
||||||
|
|
||||||
let std_repos = standard_repositories(&[file], "pve", DebianCodename::Bullseye);
|
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]);
|
assert_eq!(std_repos, &expected[0..=5]);
|
||||||
|
|
||||||
let absolute_suite_list = read_dir.join("absolute_suite.list");
|
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()?;
|
file.parse()?;
|
||||||
|
|
||||||
let std_repos = standard_repositories(&[file], "pve", DebianCodename::Bookworm);
|
let std_repos = standard_repositories(&[file], "pve", DebianCodename::Bookworm);
|
||||||
@ -382,7 +382,7 @@ fn test_standard_repositories() -> Result<(), Error> {
|
|||||||
assert_eq!(std_repos, expected);
|
assert_eq!(std_repos, expected);
|
||||||
|
|
||||||
let pve_list = read_dir.join("pve.list");
|
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()?;
|
file.parse()?;
|
||||||
|
|
||||||
let file_vec = vec![file];
|
let file_vec = vec![file];
|
||||||
@ -399,7 +399,7 @@ fn test_standard_repositories() -> Result<(), Error> {
|
|||||||
assert_eq!(std_repos, &expected[0..=5]);
|
assert_eq!(std_repos, &expected[0..=5]);
|
||||||
|
|
||||||
let pve_alt_list = read_dir.join("pve-alt.list");
|
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()?;
|
file.parse()?;
|
||||||
|
|
||||||
expected[0].status = Some(true);
|
expected[0].status = Some(true);
|
||||||
@ -411,7 +411,7 @@ fn test_standard_repositories() -> Result<(), Error> {
|
|||||||
assert_eq!(std_repos, &expected[0..=5]);
|
assert_eq!(std_repos, &expected[0..=5]);
|
||||||
|
|
||||||
let pve_alt_list = read_dir.join("ceph-quincy-bookworm.list");
|
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()?;
|
file.parse()?;
|
||||||
|
|
||||||
expected[0].status = None;
|
expected[0].status = None;
|
||||||
@ -426,7 +426,7 @@ fn test_standard_repositories() -> Result<(), Error> {
|
|||||||
assert_eq!(std_repos, expected);
|
assert_eq!(std_repos, expected);
|
||||||
|
|
||||||
let pve_alt_list = read_dir.join("ceph-quincy-nosub-bookworm.list");
|
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()?;
|
file.parse()?;
|
||||||
|
|
||||||
expected[0].status = None;
|
expected[0].status = None;
|
||||||
@ -441,7 +441,7 @@ fn test_standard_repositories() -> Result<(), Error> {
|
|||||||
assert_eq!(std_repos, expected);
|
assert_eq!(std_repos, expected);
|
||||||
|
|
||||||
let pve_alt_list = read_dir.join("ceph-reef-enterprise-bookworm.list");
|
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()?;
|
file.parse()?;
|
||||||
|
|
||||||
expected[0].status = None;
|
expected[0].status = None;
|
||||||
|
@ -54,7 +54,7 @@ pub use byte_vec::ByteVecExt;
|
|||||||
pub unsafe fn uninitialized(len: usize) -> Vec<u8> {
|
pub unsafe fn uninitialized(len: usize) -> Vec<u8> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = std::alloc::alloc(std::alloc::Layout::array::<u8>(len).unwrap());
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ struct GlauthServer {
|
|||||||
impl GlauthServer {
|
impl GlauthServer {
|
||||||
fn new(path: &str) -> Result<Self, Error> {
|
fn new(path: &str) -> Result<Self, Error> {
|
||||||
let glauth_bin = std::env::var("GLAUTH_BIN").context("GLAUTH_BIN is not set")?;
|
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("-c")
|
||||||
.arg(path)
|
.arg(path)
|
||||||
.stdin(Stdio::null())
|
.stdin(Stdio::null())
|
||||||
@ -155,16 +155,10 @@ fn test_search() -> Result<(), Error> {
|
|||||||
.attributes
|
.attributes
|
||||||
.get("mail")
|
.get("mail")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.get(0)
|
.first()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.ends_with("@example.com"));
|
.ends_with("@example.com"));
|
||||||
assert!(a
|
assert!(a.attributes.get("sn").unwrap().first().unwrap().eq("User"));
|
||||||
.attributes
|
|
||||||
.get("sn")
|
|
||||||
.unwrap()
|
|
||||||
.get(0)
|
|
||||||
.unwrap()
|
|
||||||
.eq("User".into()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -102,7 +102,7 @@ pub fn update_endpoint(
|
|||||||
config,
|
config,
|
||||||
&GotifyPrivateConfig {
|
&GotifyPrivateConfig {
|
||||||
name: name.into(),
|
name: name.into(),
|
||||||
token: token.into(),
|
token,
|
||||||
},
|
},
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
@ -12,13 +12,13 @@ use crate::Error;
|
|||||||
/// Section config schema for the public config file.
|
/// Section config schema for the public config file.
|
||||||
pub fn config_parser() -> &'static SectionConfig {
|
pub fn config_parser() -> &'static SectionConfig {
|
||||||
static CONFIG: OnceLock<SectionConfig> = OnceLock::new();
|
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.
|
/// Section config schema for the private config file.
|
||||||
pub fn private_config_parser() -> &'static SectionConfig {
|
pub fn private_config_parser() -> &'static SectionConfig {
|
||||||
static CONFIG: OnceLock<SectionConfig> = OnceLock::new();
|
static CONFIG: OnceLock<SectionConfig> = OnceLock::new();
|
||||||
CONFIG.get_or_init(|| private_config_init())
|
CONFIG.get_or_init(private_config_init)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn config_init() -> SectionConfig {
|
fn config_init() -> SectionConfig {
|
||||||
|
@ -495,7 +495,7 @@ impl Service<Uri> for PrivilegedAddr {
|
|||||||
fn call(&mut self, _req: Uri) -> Self::Future {
|
fn call(&mut self, _req: Uri) -> Self::Future {
|
||||||
match self {
|
match self {
|
||||||
PrivilegedAddr::Tcp(addr) => {
|
PrivilegedAddr::Tcp(addr) => {
|
||||||
let addr = addr.clone();
|
let addr = *addr;
|
||||||
Box::pin(async move {
|
Box::pin(async move {
|
||||||
tokio::net::TcpStream::connect(addr)
|
tokio::net::TcpStream::connect(addr)
|
||||||
.await
|
.await
|
||||||
|
@ -155,7 +155,7 @@ impl Service<Request<Body>> for RedirectService {
|
|||||||
|
|
||||||
Response::builder()
|
Response::builder()
|
||||||
.status(status_code)
|
.status(status_code)
|
||||||
.header("Location", String::from(location_value))
|
.header("Location", location_value)
|
||||||
.body(Body::empty())?
|
.body(Body::empty())?
|
||||||
} else {
|
} else {
|
||||||
Response::builder()
|
Response::builder()
|
||||||
|
@ -850,7 +850,7 @@ impl WorkerTask {
|
|||||||
file_opts: setup.file_opts.clone(),
|
file_opts: setup.file_opts.clone(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
let logger = FileLogger::new(&path, logger_options)?;
|
let logger = FileLogger::new(path, logger_options)?;
|
||||||
|
|
||||||
let worker = Arc::new(Self {
|
let worker = Arc::new(Self {
|
||||||
setup,
|
setup,
|
||||||
|
@ -62,8 +62,8 @@ impl Cache {
|
|||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
let basedir = basedir.as_ref().to_owned();
|
let basedir = basedir.as_ref().to_owned();
|
||||||
|
|
||||||
let file_options = file_options.unwrap_or_else(CreateOptions::new);
|
let file_options = file_options.unwrap_or_default();
|
||||||
let dir_options = dir_options.unwrap_or_else(CreateOptions::new);
|
let dir_options = dir_options.unwrap_or_default();
|
||||||
|
|
||||||
create_path(
|
create_path(
|
||||||
&basedir,
|
&basedir,
|
||||||
|
@ -421,7 +421,7 @@ impl<'de, 'i, 's> de::SeqAccess<'de> for SeqAccess<'de, 'i, 's> {
|
|||||||
return Ok(None);
|
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 let Some(max) = self.schema.max_length {
|
||||||
if self.count == max {
|
if self.count == max {
|
||||||
return Err(Error::msg("too many elements"));
|
return Err(Error::msg("too many elements"));
|
||||||
|
@ -303,7 +303,7 @@ impl<'a> Iterator for SplitList<'a> {
|
|||||||
type Item = &'a str;
|
type Item = &'a str;
|
||||||
|
|
||||||
fn next(&mut self) -> Option<&'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])
|
Some(&self.input[range])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,10 +52,8 @@ pub fn ensure_dir_exists<P: AsRef<Path>>(
|
|||||||
Err(nix::errno::Errno::EEXIST) => {
|
Err(nix::errno::Errno::EEXIST) => {
|
||||||
if enforce_permissions {
|
if enforce_permissions {
|
||||||
return options.check(path);
|
return options.check(path);
|
||||||
} else {
|
} else if let Err(err) = options.check(path) {
|
||||||
if let Err(err) = options.check(path) {
|
log::error!("{err}");
|
||||||
log::error!("{err}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(err) => bail!("unable to create directory {path:?} - {err}",),
|
Err(err) => bail!("unable to create directory {path:?} - {err}",),
|
||||||
|
@ -656,7 +656,7 @@ fn test_algorithm_parsing() {
|
|||||||
assert_eq!(hotp.issuer.as_deref(), Some(issuer));
|
assert_eq!(hotp.issuer.as_deref(), Some(issuer));
|
||||||
assert_eq!(hotp.account_name.as_deref(), Some("user@hostname"));
|
assert_eq!(hotp.account_name.as_deref(), Some("user@hostname"));
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
&base32::encode(base32::Alphabet::RFC4648 { padding: false }, &hotp.secret()),
|
&base32::encode(base32::Alphabet::RFC4648 { padding: false }, hotp.secret()),
|
||||||
secret
|
secret
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user