pbs-config: clippy fixes

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2022-05-25 18:26:52 +02:00
parent b8858d5186
commit a19b8c2e24
5 changed files with 14 additions and 14 deletions

View File

@ -67,11 +67,11 @@ pub fn complete_datastore_name(_arg: &str, _param: &HashMap<String, String>) ->
} }
pub fn complete_acl_path(_arg: &str, _param: &HashMap<String, String>) -> Vec<String> { pub fn complete_acl_path(_arg: &str, _param: &HashMap<String, String>) -> Vec<String> {
let mut list = Vec::new(); let mut list = vec![
String::from("/"),
list.push(String::from("/")); String::from("/datastore"),
list.push(String::from("/datastore")); String::from("/datastore/"),
list.push(String::from("/datastore/")); ];
if let Ok((data, _digest)) = config() { if let Ok((data, _digest)) = config() {
for id in data.sections.keys() { for id in data.sections.keys() {

View File

@ -370,8 +370,8 @@ fn fingerprint_checks() -> Result<(), Error> {
131, 185, 101, 156, 10, 87, 174, 25, 144, 144, 21, 155, 131, 185, 101, 156, 10, 87, 174, 25, 144, 144, 21, 155,
]); ]);
let mut data = serde_json::to_vec(&key).expect("encoding KeyConfig failed"); let data = serde_json::to_vec(&key).expect("encoding KeyConfig failed");
decrypt_key(&mut data, &{ || Ok(Vec::new()) }) decrypt_key(&data, &{ || Ok(Vec::new()) })
.expect_err("decoding KeyConfig with wrong fingerprint worked"); .expect_err("decoding KeyConfig with wrong fingerprint worked");
let key = KeyConfig { let key = KeyConfig {
@ -383,8 +383,8 @@ fn fingerprint_checks() -> Result<(), Error> {
hint: None, hint: None,
}; };
let mut data = serde_json::to_vec(&key).expect("encoding KeyConfig failed"); let data = serde_json::to_vec(&key).expect("encoding KeyConfig failed");
let (key_data, created, fingerprint) = decrypt_key(&mut data, &{ || Ok(Vec::new()) }) let (key_data, created, fingerprint) = decrypt_key(&data, &{ || Ok(Vec::new()) })
.expect("decoding KeyConfig without fingerprint failed"); .expect("decoding KeyConfig without fingerprint failed");
assert_eq!(key.data, key_data); assert_eq!(key.data, key_data);

View File

@ -101,7 +101,7 @@ pub fn parse_address_or_cidr(cidr: &str) -> Result<(String, Option<u8>, bool), E
if let Some(caps) = CIDR_V4_REGEX.captures(cidr) { if let Some(caps) = CIDR_V4_REGEX.captures(cidr) {
let address = &caps[1]; let address = &caps[1];
if let Some(mask) = caps.get(2) { if let Some(mask) = caps.get(2) {
let mask = u8::from_str_radix(mask.as_str(), 10)?; let mask: u8 = mask.as_str().parse()?;
check_netmask(mask, false)?; check_netmask(mask, false)?;
Ok((address.to_string(), Some(mask), false)) Ok((address.to_string(), Some(mask), false))
} else { } else {
@ -110,7 +110,7 @@ pub fn parse_address_or_cidr(cidr: &str) -> Result<(String, Option<u8>, bool), E
} else if let Some(caps) = CIDR_V6_REGEX.captures(cidr) { } else if let Some(caps) = CIDR_V6_REGEX.captures(cidr) {
let address = &caps[1]; let address = &caps[1];
if let Some(mask) = caps.get(2) { if let Some(mask) = caps.get(2) {
let mask = u8::from_str_radix(mask.as_str(), 10)?; let mask: u8 = mask.as_str().parse()?;
check_netmask(mask, true)?; check_netmask(mask, true)?;
Ok((address.to_string(), Some(mask), true)) Ok((address.to_string(), Some(mask), true))
} else { } else {

View File

@ -164,7 +164,7 @@ impl<R: BufRead> NetworkParser<R> {
let mask = if let Some(mask) = IPV4_MASK_HASH_LOCALNET.get(netmask.as_str()) { let mask = if let Some(mask) = IPV4_MASK_HASH_LOCALNET.get(netmask.as_str()) {
*mask *mask
} else { } else {
match u8::from_str_radix(netmask.as_str(), 10) { match netmask.as_str().parse::<u8>() {
Ok(mask) => mask, Ok(mask) => mask,
Err(err) => { Err(err) => {
bail!("unable to parse netmask '{}' - {}", netmask, err); bail!("unable to parse netmask '{}' - {}", netmask, err);
@ -211,7 +211,7 @@ impl<R: BufRead> NetworkParser<R> {
self.eat(Token::MTU)?; self.eat(Token::MTU)?;
let mtu = self.next_text()?; let mtu = self.next_text()?;
let mtu = match u64::from_str_radix(&mtu, 10) { let mtu = match mtu.parse::<u64>() {
Ok(mtu) => mtu, Ok(mtu) => mtu,
Err(err) => { Err(err) => {
bail!("unable to parse mtu value '{}' - {}", mtu, err); bail!("unable to parse mtu value '{}' - {}", mtu, err);

View File

@ -41,7 +41,7 @@ pub fn lock_config() -> Result<BackupLockGuard, Error> {
pub fn config() -> Result<(SectionConfigData, [u8; 32]), Error> { pub fn config() -> Result<(SectionConfigData, [u8; 32]), Error> {
let content = proxmox_sys::fs::file_read_optional_string(VERIFICATION_CFG_FILENAME)?; let content = proxmox_sys::fs::file_read_optional_string(VERIFICATION_CFG_FILENAME)?;
let content = content.unwrap_or_else(String::new); let content = content.unwrap_or_default();
let digest = openssl::sha::sha256(content.as_bytes()); let digest = openssl::sha::sha256(content.as_bytes());
let data = CONFIG.parse(VERIFICATION_CFG_FILENAME, &content)?; let data = CONFIG.parse(VERIFICATION_CFG_FILENAME, &content)?;