clippy: remove explicit returns

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
Fabian Grünbichler 2021-01-19 10:50:42 +01:00
parent d8d8af9826
commit 38556bf60d
13 changed files with 28 additions and 28 deletions

View File

@ -46,7 +46,7 @@ fn apt_update_available(_param: Value) -> Result<Value, Error> {
let cache = apt::update_cache()?; let cache = apt::update_cache()?;
return Ok(json!(cache.package_status)); Ok(json!(cache.package_status))
} }
fn do_apt_update(worker: &WorkerTask, quiet: bool) -> Result<(), Error> { fn do_apt_update(worker: &WorkerTask, quiet: bool) -> Result<(), Error> {
@ -205,7 +205,7 @@ fn apt_get_changelog(
if changelog_url.starts_with("http://download.proxmox.com/") { if changelog_url.starts_with("http://download.proxmox.com/") {
let changelog = crate::tools::runtime::block_on(http::get_string(changelog_url, None)) let changelog = crate::tools::runtime::block_on(http::get_string(changelog_url, None))
.map_err(|err| format_err!("Error downloading changelog from '{}': {}", changelog_url, err))?; .map_err(|err| format_err!("Error downloading changelog from '{}': {}", changelog_url, err))?;
return Ok(json!(changelog)); Ok(json!(changelog))
} else if changelog_url.starts_with("https://enterprise.proxmox.com/") { } else if changelog_url.starts_with("https://enterprise.proxmox.com/") {
let sub = match subscription::read_subscription()? { let sub = match subscription::read_subscription()? {
@ -229,7 +229,7 @@ fn apt_get_changelog(
let changelog = crate::tools::runtime::block_on(http::get_string(changelog_url, Some(&auth_header))) let changelog = crate::tools::runtime::block_on(http::get_string(changelog_url, Some(&auth_header)))
.map_err(|err| format_err!("Error downloading changelog from '{}': {}", changelog_url, err))?; .map_err(|err| format_err!("Error downloading changelog from '{}': {}", changelog_url, err))?;
return Ok(json!(changelog)); Ok(json!(changelog))
} else { } else {
let mut command = std::process::Command::new("apt-get"); let mut command = std::process::Command::new("apt-get");
@ -237,7 +237,7 @@ fn apt_get_changelog(
command.arg("-qq"); // don't display download progress command.arg("-qq"); // don't display download progress
command.arg(name); command.arg(name);
let output = crate::tools::run_command(command, None)?; let output = crate::tools::run_command(command, None)?;
return Ok(json!(output)); Ok(json!(output))
} }
} }

View File

@ -406,7 +406,7 @@ fn restore_snapshot_archive<'a>(
let mut decoder = pxar::decoder::sync::Decoder::from_std(reader)?; let mut decoder = pxar::decoder::sync::Decoder::from_std(reader)?;
match try_restore_snapshot_archive(&mut decoder, snapshot_path) { match try_restore_snapshot_archive(&mut decoder, snapshot_path) {
Ok(()) => return Ok(true), Ok(()) => Ok(true),
Err(err) => { Err(err) => {
let reader = decoder.input(); let reader = decoder.input();
@ -421,7 +421,7 @@ fn restore_snapshot_archive<'a>(
} }
// else the archive is corrupt // else the archive is corrupt
return Err(err); Err(err)
} }
} }
} }

View File

@ -239,7 +239,7 @@ async fn get_status(
} }
let text = value.as_str().unwrap().to_string(); let text = value.as_str().unwrap().to_string();
if text.is_empty() { if text.is_empty() {
return Ok(String::from("--FULL--")); Ok(String::from("--FULL--"))
} else { } else {
Ok(text) Ok(text)
} }

View File

@ -435,7 +435,7 @@ impl AclTree {
/// Iterates over the tree looking for a node matching `path`. /// Iterates over the tree looking for a node matching `path`.
pub fn find_node(&mut self, path: &str) -> Option<&mut AclTreeNode> { pub fn find_node(&mut self, path: &str) -> Option<&mut AclTreeNode> {
let path = split_acl_path(path); let path = split_acl_path(path);
return self.get_node(&path); self.get_node(&path)
} }
fn get_node(&mut self, path: &[&str]) -> Option<&mut AclTreeNode> { fn get_node(&mut self, path: &[&str]) -> Option<&mut AclTreeNode> {

View File

@ -98,7 +98,7 @@ impl CachedUserInfo {
} }
} }
return true; true
} }
pub fn check_privs( pub fn check_privs(

View File

@ -61,7 +61,7 @@ lazy_static! {
pub fn parse_cidr(cidr: &str) -> Result<(String, u8, bool), Error> { pub fn parse_cidr(cidr: &str) -> Result<(String, u8, bool), Error> {
let (address, mask, is_v6) = parse_address_or_cidr(cidr)?; let (address, mask, is_v6) = parse_address_or_cidr(cidr)?;
if let Some(mask) = mask { if let Some(mask) = mask {
return Ok((address, mask, is_v6)); Ok((address, mask, is_v6))
} else { } else {
bail!("missing netmask in '{}'", cidr); bail!("missing netmask in '{}'", cidr);
} }
@ -98,18 +98,18 @@ pub fn parse_address_or_cidr(cidr: &str) -> Result<(String, Option<u8>, bool), E
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::from_str_radix(mask.as_str(), 10)?;
check_netmask(mask, false)?; check_netmask(mask, false)?;
return Ok((address.to_string(), Some(mask), false)); Ok((address.to_string(), Some(mask), false))
} else { } else {
return Ok((address.to_string(), None, false)); Ok((address.to_string(), None, false))
} }
} 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::from_str_radix(mask.as_str(), 10)?;
check_netmask(mask, true)?; check_netmask(mask, true)?;
return Ok((address.to_string(), Some(mask), true)); Ok((address.to_string(), Some(mask), true))
} else { } else {
return Ok((address.to_string(), None, true)); Ok((address.to_string(), None, true))
} }
} else { } else {
bail!("invalid address/mask '{}'", cidr); bail!("invalid address/mask '{}'", cidr);

View File

@ -114,14 +114,14 @@ impl <R: BufRead> Iterator for Lexer<R> {
Some(ref mut cur_line) => { Some(ref mut cur_line) => {
if cur_line.is_empty() { if cur_line.is_empty() {
self.cur_line = None; self.cur_line = None;
return Some(Ok((Token::Newline, String::from("\n")))); Some(Ok((Token::Newline, String::from("\n"))))
} else { } else {
let (token, text) = cur_line.pop_front().unwrap(); let (token, text) = cur_line.pop_front().unwrap();
return Some(Ok((token, text))); Some(Ok((token, text)))
} }
} }
None => { None => {
return None; None
} }
} }
} }

View File

@ -29,7 +29,7 @@ impl <R: BufRead> NetworkParser<R> {
bail!("input error - {}", err); bail!("input error - {}", err);
} }
Some(Ok((token, _))) => { Some(Ok((token, _))) => {
return Ok(*token); Ok(*token)
} }
None => { None => {
bail!("got unexpected end of stream (inside peek)"); bail!("got unexpected end of stream (inside peek)");
@ -44,7 +44,7 @@ impl <R: BufRead> NetworkParser<R> {
} }
Some(Ok((token, text))) => { Some(Ok((token, text))) => {
if token == Token::Newline { self.line_nr += 1; } if token == Token::Newline { self.line_nr += 1; }
return Ok((token, text)); Ok((token, text))
} }
None => { None => {
bail!("got unexpected end of stream (inside peek)"); bail!("got unexpected end of stream (inside peek)");

View File

@ -33,7 +33,7 @@ pub fn do_verification_job(
let raw_verify_state = manifest.unprotected["verify_state"].clone(); let raw_verify_state = manifest.unprotected["verify_state"].clone();
match serde_json::from_value::<SnapshotVerifyState>(raw_verify_state) { match serde_json::from_value::<SnapshotVerifyState>(raw_verify_state) {
Err(_) => return true, // no last verification, always include Err(_) => true, // no last verification, always include
Ok(last_verify) => { Ok(last_verify) => {
match outdated_after { match outdated_after {
None => false, // never re-verify if ignored and no max age None => false, // never re-verify if ignored and no max age

View File

@ -246,13 +246,13 @@ pub fn required_media_changer(
) -> Result<(Box<dyn MediaChange>, String), Error> { ) -> Result<(Box<dyn MediaChange>, String), Error> {
match media_changer(config, drive) { match media_changer(config, drive) {
Ok(Some(result)) => { Ok(Some(result)) => {
return Ok(result); Ok(result)
} }
Ok(None) => { Ok(None) => {
bail!("drive '{}' has no associated changer device", drive); bail!("drive '{}' has no associated changer device", drive);
}, },
Err(err) => { Err(err) => {
return Err(err); Err(err)
} }
} }
} }
@ -327,7 +327,7 @@ pub fn request_and_load_media(
let media_id = check_label(handle.as_mut(), &label.uuid)?; let media_id = check_label(handle.as_mut(), &label.uuid)?;
return Ok((handle, media_id)); Ok((handle, media_id))
} }
"linux" => { "linux" => {
let drive_config = LinuxTapeDrive::deserialize(config)?; let drive_config = LinuxTapeDrive::deserialize(config)?;

View File

@ -179,7 +179,7 @@ impl <R: Read> Read for BlockedReader<R> {
} }
if rest <= 0 { if rest <= 0 {
return Ok(0); Ok(0)
} else { } else {
let copy_len = if (buffer.len() as isize) < rest { let copy_len = if (buffer.len() as isize) < rest {
buffer.len() buffer.len()
@ -189,7 +189,7 @@ impl <R: Read> Read for BlockedReader<R> {
buffer[..copy_len].copy_from_slice( buffer[..copy_len].copy_from_slice(
&self.buffer.payload[self.read_pos..(self.read_pos + copy_len)]); &self.buffer.payload[self.read_pos..(self.read_pos + copy_len)]);
self.read_pos += copy_len; self.read_pos += copy_len;
return Ok(copy_len); Ok(copy_len)
} }
} }
} }

View File

@ -226,7 +226,7 @@ pub fn list_installed_apt_packages<F: Fn(FilterData) -> bool>(
} }
} }
return ret; ret
} }
fn query_detailed_info<'a, F, V>( fn query_detailed_info<'a, F, V>(
@ -366,5 +366,5 @@ where
} }
} }
return None; None
} }

View File

@ -725,7 +725,7 @@ pub fn get_disk_usage_info(
filter.push(disk.to_string()); filter.push(disk.to_string());
let mut map = get_disks(Some(filter), no_smart)?; let mut map = get_disks(Some(filter), no_smart)?;
if let Some(info) = map.remove(disk) { if let Some(info) = map.remove(disk) {
return Ok(info); Ok(info)
} else { } else {
bail!("failed to get disk usage info - internal error"); // should not happen bail!("failed to get disk usage info - internal error"); // should not happen
} }