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> {
let mut list = Vec::new();
list.push(String::from("/"));
list.push(String::from("/datastore"));
list.push(String::from("/datastore/"));
let mut list = vec![
String::from("/"),
String::from("/datastore"),
String::from("/datastore/"),
];
if let Ok((data, _digest)) = config() {
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,
]);
let mut data = serde_json::to_vec(&key).expect("encoding KeyConfig failed");
decrypt_key(&mut data, &{ || Ok(Vec::new()) })
let data = serde_json::to_vec(&key).expect("encoding KeyConfig failed");
decrypt_key(&data, &{ || Ok(Vec::new()) })
.expect_err("decoding KeyConfig with wrong fingerprint worked");
let key = KeyConfig {
@ -383,8 +383,8 @@ fn fingerprint_checks() -> Result<(), Error> {
hint: None,
};
let mut data = serde_json::to_vec(&key).expect("encoding KeyConfig failed");
let (key_data, created, fingerprint) = decrypt_key(&mut data, &{ || Ok(Vec::new()) })
let data = serde_json::to_vec(&key).expect("encoding KeyConfig failed");
let (key_data, created, fingerprint) = decrypt_key(&data, &{ || Ok(Vec::new()) })
.expect("decoding KeyConfig without fingerprint failed");
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) {
let address = &caps[1];
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)?;
Ok((address.to_string(), Some(mask), false))
} 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) {
let address = &caps[1];
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)?;
Ok((address.to_string(), Some(mask), true))
} 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()) {
*mask
} else {
match u8::from_str_radix(netmask.as_str(), 10) {
match netmask.as_str().parse::<u8>() {
Ok(mask) => mask,
Err(err) => {
bail!("unable to parse netmask '{}' - {}", netmask, err);
@ -211,7 +211,7 @@ impl<R: BufRead> NetworkParser<R> {
self.eat(Token::MTU)?;
let mtu = self.next_text()?;
let mtu = match u64::from_str_radix(&mtu, 10) {
let mtu = match mtu.parse::<u64>() {
Ok(mtu) => mtu,
Err(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> {
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 data = CONFIG.parse(VERIFICATION_CFG_FILENAME, &content)?;